blob: 1be3ea32047495379f2468854972c968136699a4 [file] [log] [blame]
David Herrmanne7b960702014-07-24 12:10:04 +02001#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 Herrmann9fc5cde2014-08-29 12:12:28 +020026/*
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 Herrmanncc5ea592014-08-29 12:12:32 +020031#include <linux/list.h>
Sam Ravnborgb8d11482019-05-26 19:35:33 +020032
33#include <drm/drm.h>
34#include <drm/drm_device.h>
Daniel Vetter4f03b1f2014-09-10 12:43:49 +020035#include <drm/drm_legacy.h>
David Herrmanncc5ea592014-08-29 12:12:32 +020036
37struct agp_memory;
David Herrmanne7b960702014-07-24 12:10:04 +020038struct drm_device;
39struct drm_file;
Sam Ravnborgb8d11482019-05-26 19:35:33 +020040struct drm_buf_desc;
David Herrmanne7b960702014-07-24 12:10:04 +020041
42/*
43 * Generic DRM Contexts
44 */
45
46#define DRM_KERNEL_CONTEXT 0
47#define DRM_RESERVED_CONTEXTS 1
48
Dave Airlie61ae2272019-04-18 17:10:40 +100049#if IS_ENABLED(CONFIG_DRM_LEGACY)
Daniel Vetterba6976c2015-06-23 11:22:36 +020050void drm_legacy_ctxbitmap_init(struct drm_device *dev);
David Herrmanne7b960702014-07-24 12:10:04 +020051void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
David Herrmanne7b960702014-07-24 12:10:04 +020052void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
Dave Airlie61ae2272019-04-18 17:10:40 +100053#else
54static inline void drm_legacy_ctxbitmap_init(struct drm_device *dev) {}
55static inline void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev) {}
56static inline void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file) {}
57#endif
David Herrmanne7b960702014-07-24 12:10:04 +020058
Dave Airlie61ae2272019-04-18 17:10:40 +100059void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
60
61#if IS_ENABLED(CONFIG_DRM_LEGACY)
David Herrmanne7b960702014-07-24 12:10:04 +020062int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
63int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
64int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
65int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
66int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
67int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
68
69int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
70int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
Dave Airlie61ae2272019-04-18 17:10:40 +100071#endif
David Herrmanne7b960702014-07-24 12:10:04 +020072
David Herrmann9fc5cde2014-08-29 12:12:28 +020073/*
74 * Generic Buffer Management
75 */
76
77#define DRM_MAP_HASH_OFFSET 0x10000000
78
Dave Airlie83c163f2019-04-23 09:56:01 +100079#if IS_ENABLED(CONFIG_DRM_LEGACY)
Dave Airliefabb0e22019-04-23 09:40:54 +100080static inline int drm_legacy_create_map_hash(struct drm_device *dev)
81{
82 return drm_ht_create(&dev->map_hash, 12);
83}
84
85static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
86{
87 drm_ht_remove(&dev->map_hash);
88}
Dave Airlie83c163f2019-04-23 09:56:01 +100089#else
90static inline int drm_legacy_create_map_hash(struct drm_device *dev)
91{
92 return 0;
93}
94
95static inline void drm_legacy_remove_map_hash(struct drm_device *dev) {}
96#endif
Dave Airliefabb0e22019-04-23 09:40:54 +100097
Dave Airlie61ae2272019-04-18 17:10:40 +100098
99#if IS_ENABLED(CONFIG_DRM_LEGACY)
Daniel Vetterec1f52e2016-04-26 19:29:36 +0200100int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
101 struct drm_file *file_priv);
David Herrmann9fc5cde2014-08-29 12:12:28 +0200102int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
103int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
Dave Airlie61ae2272019-04-18 17:10:40 +1000104
David Herrmann9fc5cde2014-08-29 12:12:28 +0200105int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
106int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
107int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
108int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
109int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
110int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
Dave Airlie61ae2272019-04-18 17:10:40 +1000111#endif
David Herrmann9fc5cde2014-08-29 12:12:28 +0200112
Al Viro5c7640a2017-05-24 17:54:09 -0400113int __drm_legacy_infobufs(struct drm_device *, void *, int *,
114 int (*)(void *, int, struct drm_buf_entry *));
Al Viro87d3ce12017-05-25 16:24:20 -0400115int __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 Viro5c7640a2017-05-24 17:54:09 -0400119
Dave Airlie61ae2272019-04-18 17:10:40 +1000120#if IS_ENABLED(CONFIG_DRM_LEGACY)
Dave Airlie15e60852019-04-23 08:42:23 +1000121void drm_legacy_master_rmmaps(struct drm_device *dev,
122 struct drm_master *master);
Dave Airlie35a28022019-04-23 08:45:12 +1000123void drm_legacy_rmmaps(struct drm_device *dev);
Dave Airlie61ae2272019-04-18 17:10:40 +1000124#else
125static inline void drm_legacy_master_rmmaps(struct drm_device *dev,
126 struct drm_master *master) {}
127static inline void drm_legacy_rmmaps(struct drm_device *dev) {}
128#endif
Dave Airlie15e60852019-04-23 08:42:23 +1000129
Dave Airlie61ae2272019-04-18 17:10:40 +1000130#if IS_ENABLED(CONFIG_DRM_VM) && IS_ENABLED(CONFIG_DRM_LEGACY)
Daniel Vettera677f4c2014-09-10 12:43:48 +0200131void drm_legacy_vma_flush(struct drm_device *d);
Benjamin Gaignard99c48e12017-01-04 10:12:56 +0100132#else
133static inline void drm_legacy_vma_flush(struct drm_device *d)
134{
135 /* do nothing */
136}
137#endif
Daniel Vettera677f4c2014-09-10 12:43:48 +0200138
David Herrmanncc5ea592014-08-29 12:12:32 +0200139/*
140 * AGP Support
141 */
142
143struct 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 Vetter1a75a222016-06-14 20:50:57 +0200151/* drm_lock.c */
Dave Airlie61ae2272019-04-18 17:10:40 +1000152#if IS_ENABLED(CONFIG_DRM_LEGACY)
David Herrmannbb6d8222014-08-29 12:12:46 +0200153int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
154int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
Daniel Vetter1a75a222016-06-14 20:50:57 +0200155void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
Dave Airlie61ae2272019-04-18 17:10:40 +1000156#else
157static inline void drm_legacy_lock_release(struct drm_device *dev, struct file *filp) {}
158#endif
David Herrmannbb6d8222014-08-29 12:12:46 +0200159
Daniel Vettera2661622014-09-11 07:41:51 +0200160/* DMA support */
Dave Airlie61ae2272019-04-18 17:10:40 +1000161#if IS_ENABLED(CONFIG_DRM_LEGACY)
Daniel Vettera2661622014-09-11 07:41:51 +0200162int drm_legacy_dma_setup(struct drm_device *dev);
163void drm_legacy_dma_takedown(struct drm_device *dev);
Dave Airlie61ae2272019-04-18 17:10:40 +1000164#else
165static inline int drm_legacy_dma_setup(struct drm_device *dev)
166{
167 return 0;
168}
169#endif
170
Daniel Vettera2661622014-09-11 07:41:51 +0200171void drm_legacy_free_buffer(struct drm_device *dev,
172 struct drm_buf * buf);
Dave Airlie61ae2272019-04-18 17:10:40 +1000173#if IS_ENABLED(CONFIG_DRM_LEGACY)
Daniel Vettera2661622014-09-11 07:41:51 +0200174void drm_legacy_reclaim_buffers(struct drm_device *dev,
175 struct drm_file *filp);
Dave Airlie61ae2272019-04-18 17:10:40 +1000176#else
177static inline void drm_legacy_reclaim_buffers(struct drm_device *dev,
178 struct drm_file *filp) {}
179#endif
Daniel Vettera2661622014-09-11 07:41:51 +0200180
Daniel Vetter9ec4e2f2014-09-11 07:42:43 +0200181/* Scatter Gather Support */
Dave Airlie61ae2272019-04-18 17:10:40 +1000182#if IS_ENABLED(CONFIG_DRM_LEGACY)
Daniel Vetter9ec4e2f2014-09-11 07:42:43 +0200183void drm_legacy_sg_cleanup(struct drm_device *dev);
184int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
185 struct drm_file *file_priv);
186int drm_legacy_sg_free(struct drm_device *dev, void *data,
187 struct drm_file *file_priv);
Dave Airlie61ae2272019-04-18 17:10:40 +1000188#endif
Daniel Vetter9ec4e2f2014-09-11 07:42:43 +0200189
Dave Airlie61ae2272019-04-18 17:10:40 +1000190#if IS_ENABLED(CONFIG_DRM_LEGACY)
Dave Airlie8437dd72019-04-23 09:47:27 +1000191void drm_legacy_init_members(struct drm_device *dev);
192void drm_legacy_destroy_members(struct drm_device *dev);
Dave Airlie1fa32cb2019-04-23 09:48:13 +1000193void drm_legacy_dev_reinit(struct drm_device *dev);
Daniel Vetter094aa542019-05-02 15:56:03 +0200194int drm_legacy_setup(struct drm_device * dev);
Dave Airlie61ae2272019-04-18 17:10:40 +1000195#else
196static inline void drm_legacy_init_members(struct drm_device *dev) {}
197static inline void drm_legacy_destroy_members(struct drm_device *dev) {}
198static inline void drm_legacy_dev_reinit(struct drm_device *dev) {}
Daniel Vetter094aa542019-05-02 15:56:03 +0200199static inline int drm_legacy_setup(struct drm_device * dev) { return 0; }
Dave Airlie61ae2272019-04-18 17:10:40 +1000200#endif
Dave Airlie8437dd72019-04-23 09:47:27 +1000201
Dave Airlie61ae2272019-04-18 17:10:40 +1000202#if IS_ENABLED(CONFIG_DRM_LEGACY)
Dave Airlie058ca502019-04-23 09:36:54 +1000203void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
Dave Airlie61ae2272019-04-18 17:10:40 +1000204#else
205static inline void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) {}
206#endif
207
Dave Airlieee22f762019-04-23 10:01:50 +1000208#if IS_ENABLED(CONFIG_DRM_LEGACY)
209void drm_master_legacy_init(struct drm_master *master);
210#else
211static inline void drm_master_legacy_init(struct drm_master *master) {}
212#endif
213
David Herrmanne7b960702014-07-24 12:10:04 +0200214#endif /* __DRM_LEGACY_H__ */