drm/legacy: move init/destroy of struct members into legacy file
[linux-block.git] / drivers / gpu / drm / drm_legacy.h
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
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  */
31 #include <linux/list.h>
32 #include <drm/drm_legacy.h>
33
34 struct agp_memory;
35 struct drm_device;
36 struct drm_file;
37
38 /*
39  * Generic DRM Contexts
40  */
41
42 #define DRM_KERNEL_CONTEXT              0
43 #define DRM_RESERVED_CONTEXTS           1
44
45 void drm_legacy_ctxbitmap_init(struct drm_device *dev);
46 void drm_legacy_ctxbitmap_cleanup(struct drm_device *dev);
47 void drm_legacy_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
48 void drm_legacy_ctxbitmap_flush(struct drm_device *dev, struct drm_file *file);
49
50 int drm_legacy_resctx(struct drm_device *d, void *v, struct drm_file *f);
51 int drm_legacy_addctx(struct drm_device *d, void *v, struct drm_file *f);
52 int drm_legacy_getctx(struct drm_device *d, void *v, struct drm_file *f);
53 int drm_legacy_switchctx(struct drm_device *d, void *v, struct drm_file *f);
54 int drm_legacy_newctx(struct drm_device *d, void *v, struct drm_file *f);
55 int drm_legacy_rmctx(struct drm_device *d, void *v, struct drm_file *f);
56
57 int drm_legacy_setsareactx(struct drm_device *d, void *v, struct drm_file *f);
58 int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f);
59
60 /*
61  * Generic Buffer Management
62  */
63
64 #define DRM_MAP_HASH_OFFSET 0x10000000
65
66 static inline int drm_legacy_create_map_hash(struct drm_device *dev)
67 {
68         return drm_ht_create(&dev->map_hash, 12);
69 }
70
71 static inline void drm_legacy_remove_map_hash(struct drm_device *dev)
72 {
73         drm_ht_remove(&dev->map_hash);
74 }
75
76 int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
77                             struct drm_file *file_priv);
78 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
79 int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f);
80 int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);
81 int drm_legacy_infobufs(struct drm_device *d, void *v, struct drm_file *f);
82 int drm_legacy_markbufs(struct drm_device *d, void *v, struct drm_file *f);
83 int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f);
84 int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f);
85 int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f);
86
87 int __drm_legacy_infobufs(struct drm_device *, void *, int *,
88                           int (*)(void *, int, struct drm_buf_entry *));
89 int __drm_legacy_mapbufs(struct drm_device *, void *, int *,
90                           void __user **,
91                           int (*)(void *, int, unsigned long, struct drm_buf *),
92                           struct drm_file *);
93
94 void drm_legacy_master_rmmaps(struct drm_device *dev,
95                               struct drm_master *master);
96 void drm_legacy_rmmaps(struct drm_device *dev);
97
98 #ifdef CONFIG_DRM_VM
99 void drm_legacy_vma_flush(struct drm_device *d);
100 #else
101 static inline void drm_legacy_vma_flush(struct drm_device *d)
102 {
103         /* do nothing */
104 }
105 #endif
106
107 /*
108  * AGP Support
109  */
110
111 struct drm_agp_mem {
112         unsigned long handle;
113         struct agp_memory *memory;
114         unsigned long bound;
115         int pages;
116         struct list_head head;
117 };
118
119 /* drm_lock.c */
120 int drm_legacy_lock(struct drm_device *d, void *v, struct drm_file *f);
121 int drm_legacy_unlock(struct drm_device *d, void *v, struct drm_file *f);
122 void drm_legacy_lock_release(struct drm_device *dev, struct file *filp);
123
124 /* DMA support */
125 int drm_legacy_dma_setup(struct drm_device *dev);
126 void drm_legacy_dma_takedown(struct drm_device *dev);
127 void drm_legacy_free_buffer(struct drm_device *dev,
128                             struct drm_buf * buf);
129 void drm_legacy_reclaim_buffers(struct drm_device *dev,
130                                 struct drm_file *filp);
131
132 /* Scatter Gather Support */
133 void drm_legacy_sg_cleanup(struct drm_device *dev);
134 int drm_legacy_sg_alloc(struct drm_device *dev, void *data,
135                         struct drm_file *file_priv);
136 int drm_legacy_sg_free(struct drm_device *dev, void *data,
137                        struct drm_file *file_priv);
138
139 void drm_legacy_init_members(struct drm_device *dev);
140 void drm_legacy_destroy_members(struct drm_device *dev);
141
142 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master);
143 #endif /* __DRM_LEGACY_H__ */