David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 1 | #ifndef __DRM_LEGACY_H__ |
| 2 | #define __DRM_LEGACY_H__ |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 2014 David Herrmann <dh.herrmann@gmail.com> |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 | * OTHER DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | |
David Herrmann | 9fc5cde | 2014-08-29 12:12:28 +0200 | [diff] [blame] | 26 | /* |
| 27 | * This file contains legacy interfaces that modern drm drivers |
| 28 | * should no longer be using. They cannot be removed as legacy |
| 29 | * drivers use them, and removing them are API breaks. |
| 30 | */ |
David Herrmann | cc5ea59 | 2014-08-29 12:12:32 +0200 | [diff] [blame] | 31 | #include <linux/list.h> |
Sam Ravnborg | b8d1148 | 2019-05-26 19:35:33 +0200 | [diff] [blame] | 32 | |
| 33 | #include <drm/drm.h> |
| 34 | #include <drm/drm_device.h> |
Daniel Vetter | 4f03b1f | 2014-09-10 12:43:49 +0200 | [diff] [blame] | 35 | #include <drm/drm_legacy.h> |
David Herrmann | cc5ea59 | 2014-08-29 12:12:32 +0200 | [diff] [blame] | 36 | |
| 37 | struct agp_memory; |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 38 | struct drm_device; |
| 39 | struct drm_file; |
Sam Ravnborg | b8d1148 | 2019-05-26 19:35:33 +0200 | [diff] [blame] | 40 | struct drm_buf_desc; |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 41 | |
| 42 | /* |
| 43 | * Generic DRM Contexts |
| 44 | */ |
| 45 | |
| 46 | #define DRM_KERNEL_CONTEXT 0 |
| 47 | #define DRM_RESERVED_CONTEXTS 1 |
| 48 | |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 49 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Daniel Vetter | ba6976c | 2015-06-23 11:22:36 +0200 | [diff] [blame] | 50 | void drm_legacy_ctxbitmap_init(struct drm_device *dev); |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 51 | void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev); |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 52 | void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 53 | #else |
| 54 | static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {} |
| 55 | static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {} |
| 56 | static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {} |
| 57 | #endif |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 58 | |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 59 | void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
| 60 | |
| 61 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 62 | int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f); |
| 63 | int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f); |
| 64 | int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f); |
| 65 | int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f); |
| 66 | int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f); |
| 67 | int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f); |
| 68 | |
| 69 | int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f); |
| 70 | int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 71 | #endif |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 72 | |
David Herrmann | 9fc5cde | 2014-08-29 12:12:28 +0200 | [diff] [blame] | 73 | /* |
| 74 | * Generic Buffer Management |
| 75 | */ |
| 76 | |
| 77 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
| 78 | |
Dave Airlie | 83c163f | 2019-04-23 09:56:01 +1000 | [diff] [blame] | 79 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Dave Airlie | fabb0e2 | 2019-04-23 09:40:54 +1000 | [diff] [blame] | 80 | static inline int drm_legacy_create_map_hash(struct drm_device *dev) |
| 81 | { |
| 82 | return drm_ht_create(&dev->map_hash, 12); |
| 83 | } |
| 84 | |
| 85 | static inline void drm_legacy_remove_map_hash(struct drm_device *dev) |
| 86 | { |
| 87 | drm_ht_remove(&dev->map_hash); |
| 88 | } |
Dave Airlie | 83c163f | 2019-04-23 09:56:01 +1000 | [diff] [blame] | 89 | #else |
| 90 | static inline int drm_legacy_create_map_hash(struct drm_device *dev) |
| 91 | { |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {} |
| 96 | #endif |
Dave Airlie | fabb0e2 | 2019-04-23 09:40:54 +1000 | [diff] [blame] | 97 | |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 98 | |
| 99 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Daniel Vetter | ec1f52e | 2016-04-26 19:29:36 +0200 | [diff] [blame] | 100 | int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, |
| 101 | struct drm_file *file_priv); |
David Herrmann | 9fc5cde | 2014-08-29 12:12:28 +0200 | [diff] [blame] | 102 | int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); |
| 103 | int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 104 | |
David Herrmann | 9fc5cde | 2014-08-29 12:12:28 +0200 | [diff] [blame] | 105 | int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f); |
| 106 | int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f); |
| 107 | int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f); |
| 108 | int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f); |
| 109 | int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f); |
| 110 | int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 111 | #endif |
David Herrmann | 9fc5cde | 2014-08-29 12:12:28 +0200 | [diff] [blame] | 112 | |
Al Viro | 5c7640a | 2017-05-24 17:54:09 -0400 | [diff] [blame] | 113 | int __drm_legacy_infobufs(struct drm_device *, void *, int *, |
| 114 | int (*)(void *, int, struct drm_buf_entry *)); |
Al Viro | 87d3ce1 | 2017-05-25 16:24:20 -0400 | [diff] [blame] | 115 | int __drm_legacy_mapbufs(struct drm_device *, void *, int *, |
| 116 | void __user **, |
| 117 | int (*)(void *, int, unsigned long, struct drm_buf *), |
| 118 | struct drm_file *); |
Al Viro | 5c7640a | 2017-05-24 17:54:09 -0400 | [diff] [blame] | 119 | |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 120 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Dave Airlie | 15e6085 | 2019-04-23 08:42:23 +1000 | [diff] [blame] | 121 | void drm_legacy_master_rmmaps(struct drm_device *dev, |
| 122 | struct drm_master *master); |
Dave Airlie | 35a2802 | 2019-04-23 08:45:12 +1000 | [diff] [blame] | 123 | void drm_legacy_rmmaps(struct drm_device *dev); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 124 | #else |
| 125 | static inline void drm_legacy_master_rmmaps(struct drm_device *dev, |
| 126 | struct drm_master *master) {} |
| 127 | static inline void drm_legacy_rmmaps(struct drm_device *dev) {} |
| 128 | #endif |
Dave Airlie | 15e6085 | 2019-04-23 08:42:23 +1000 | [diff] [blame] | 129 | |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 130 | #if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY) |
Daniel Vetter | a677f4c | 2014-09-10 12:43:48 +0200 | [diff] [blame] | 131 | void drm_legacy_vma_flush(struct drm_device *d); |
Benjamin Gaignard | 99c48e1 | 2017-01-04 10:12:56 +0100 | [diff] [blame] | 132 | #else |
| 133 | static inline void drm_legacy_vma_flush(struct drm_device *d) |
| 134 | { |
| 135 | /* do nothing */ |
| 136 | } |
| 137 | #endif |
Daniel Vetter | a677f4c | 2014-09-10 12:43:48 +0200 | [diff] [blame] | 138 | |
David Herrmann | cc5ea59 | 2014-08-29 12:12:32 +0200 | [diff] [blame] | 139 | /* |
| 140 | * AGP Support |
| 141 | */ |
| 142 | |
| 143 | struct drm_agp_mem { |
| 144 | unsigned long handle; |
| 145 | struct agp_memory *memory; |
| 146 | unsigned long bound; |
| 147 | int pages; |
| 148 | struct list_head head; |
| 149 | }; |
| 150 | |
Daniel Vetter | 1a75a22 | 2016-06-14 20:50:57 +0200 | [diff] [blame] | 151 | /* drm_lock.c */ |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 152 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
David Herrmann | bb6d822 | 2014-08-29 12:12:46 +0200 | [diff] [blame] | 153 | int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f); |
| 154 | int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f); |
Daniel Vetter | 1a75a22 | 2016-06-14 20:50:57 +0200 | [diff] [blame] | 155 | void drm_legacy_lock_release(struct drm_device *dev, struct file *filp); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 156 | #else |
| 157 | static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {} |
| 158 | #endif |
David Herrmann | bb6d822 | 2014-08-29 12:12:46 +0200 | [diff] [blame] | 159 | |
Daniel Vetter | a266162 | 2014-09-11 07:41:51 +0200 | [diff] [blame] | 160 | /* DMA support */ |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 161 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Daniel Vetter | a266162 | 2014-09-11 07:41:51 +0200 | [diff] [blame] | 162 | int drm_legacy_dma_setup(struct drm_device *dev); |
| 163 | void drm_legacy_dma_takedown(struct drm_device *dev); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 164 | #else |
| 165 | static inline int drm_legacy_dma_setup(struct drm_device *dev) |
| 166 | { |
| 167 | return 0; |
| 168 | } |
| 169 | #endif |
| 170 | |
Daniel Vetter | a266162 | 2014-09-11 07:41:51 +0200 | [diff] [blame] | 171 | void drm_legacy_free_buffer(struct drm_device *dev, |
| 172 | struct drm_buf * buf); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 173 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Daniel Vetter | a266162 | 2014-09-11 07:41:51 +0200 | [diff] [blame] | 174 | void drm_legacy_reclaim_buffers(struct drm_device *dev, |
| 175 | struct drm_file *filp); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 176 | #else |
| 177 | static inline void drm_legacy_reclaim_buffers(struct drm_device *dev, |
| 178 | struct drm_file *filp) {} |
| 179 | #endif |
Daniel Vetter | a266162 | 2014-09-11 07:41:51 +0200 | [diff] [blame] | 180 | |
Daniel Vetter | 9ec4e2f | 2014-09-11 07:42:43 +0200 | [diff] [blame] | 181 | /* Scatter Gather Support */ |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 182 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Daniel Vetter | 9ec4e2f | 2014-09-11 07:42:43 +0200 | [diff] [blame] | 183 | void drm_legacy_sg_cleanup(struct drm_device *dev); |
| 184 | int drm_legacy_sg_alloc(struct drm_device *dev, void *data, |
| 185 | struct drm_file *file_priv); |
| 186 | int drm_legacy_sg_free(struct drm_device *dev, void *data, |
| 187 | struct drm_file *file_priv); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 188 | #endif |
Daniel Vetter | 9ec4e2f | 2014-09-11 07:42:43 +0200 | [diff] [blame] | 189 | |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 190 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Dave Airlie | 8437dd7 | 2019-04-23 09:47:27 +1000 | [diff] [blame] | 191 | void drm_legacy_init_members(struct drm_device *dev); |
| 192 | void drm_legacy_destroy_members(struct drm_device *dev); |
Dave Airlie | 1fa32cb | 2019-04-23 09:48:13 +1000 | [diff] [blame] | 193 | void drm_legacy_dev_reinit(struct drm_device *dev); |
Daniel Vetter | 094aa54 | 2019-05-02 15:56:03 +0200 | [diff] [blame] | 194 | int drm_legacy_setup(struct drm_device * dev); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 195 | #else |
| 196 | static inline void drm_legacy_init_members(struct drm_device *dev) {} |
| 197 | static inline void drm_legacy_destroy_members(struct drm_device *dev) {} |
| 198 | static inline void drm_legacy_dev_reinit(struct drm_device *dev) {} |
Daniel Vetter | 094aa54 | 2019-05-02 15:56:03 +0200 | [diff] [blame] | 199 | static inline int drm_legacy_setup(struct drm_device * dev) { return 0; } |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 200 | #endif |
Dave Airlie | 8437dd7 | 2019-04-23 09:47:27 +1000 | [diff] [blame] | 201 | |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 202 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
Dave Airlie | 058ca50 | 2019-04-23 09:36:54 +1000 | [diff] [blame] | 203 | void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master); |
Dave Airlie | 61ae227 | 2019-04-18 17:10:40 +1000 | [diff] [blame] | 204 | #else |
| 205 | static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {} |
| 206 | #endif |
| 207 | |
Dave Airlie | ee22f76 | 2019-04-23 10:01:50 +1000 | [diff] [blame] | 208 | #if IS_ENABLED(CONFIG_DRM_LEGACY) |
| 209 | void drm_master_legacy_init(struct drm_master *master); |
| 210 | #else |
| 211 | static inline void drm_master_legacy_init(struct drm_master *master) {} |
| 212 | #endif |
| 213 | |
David Herrmann | e7b96070 | 2014-07-24 12:10:04 +0200 | [diff] [blame] | 214 | #endif /* __DRM_LEGACY_H__ */ |