1#ifndef __DRM_DRM_LEGACY_H__
2#define __DRM_DRM_LEGACY_H__
3
4#include <drm/drm_auth.h>
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50struct drm_buf {
51 int idx;
52 int total;
53 int order;
54 int used;
55 unsigned long offset;
56 void *address;
57 unsigned long bus_address;
58 struct drm_buf *next;
59 __volatile__ int waiting;
60 __volatile__ int pending;
61 struct drm_file *file_priv;
62 int context;
63 int while_locked;
64 enum {
65 DRM_LIST_NONE = 0,
66 DRM_LIST_FREE = 1,
67 DRM_LIST_WAIT = 2,
68 DRM_LIST_PEND = 3,
69 DRM_LIST_PRIO = 4,
70 DRM_LIST_RECLAIM = 5
71 } list;
72
73 int dev_priv_size;
74 void *dev_private;
75};
76
77typedef struct drm_dma_handle {
78 dma_addr_t busaddr;
79 void *vaddr;
80 size_t size;
81} drm_dma_handle_t;
82
83
84
85
86struct drm_buf_entry {
87 int buf_size;
88 int buf_count;
89 struct drm_buf *buflist;
90 int seg_count;
91 int page_order;
92 struct drm_dma_handle **seglist;
93
94 int low_mark;
95 int high_mark;
96};
97
98
99
100
101struct drm_device_dma {
102
103 struct drm_buf_entry bufs[DRM_MAX_ORDER + 1];
104 int buf_count;
105 struct drm_buf **buflist;
106 int seg_count;
107 int page_count;
108 unsigned long *pagelist;
109 unsigned long byte_count;
110 enum {
111 _DRM_DMA_USE_AGP = 0x01,
112 _DRM_DMA_USE_SG = 0x02,
113 _DRM_DMA_USE_FB = 0x04,
114 _DRM_DMA_USE_PCI_RO = 0x08
115 } flags;
116
117};
118
119
120
121
122struct drm_sg_mem {
123 unsigned long handle;
124 void *virtual;
125 int pages;
126 struct page **pagelist;
127 dma_addr_t *busaddr;
128};
129
130
131
132
133struct drm_local_map {
134 resource_size_t offset;
135 unsigned long size;
136 enum drm_map_type type;
137 enum drm_map_flags flags;
138 void *handle;
139
140 int mtrr;
141};
142
143typedef struct drm_local_map drm_local_map_t;
144
145
146
147
148struct drm_map_list {
149 struct list_head head;
150 struct drm_hash_item hash;
151 struct drm_local_map *map;
152 uint64_t user_token;
153 struct drm_master *master;
154};
155
156int drm_legacy_addmap(struct drm_device *d, resource_size_t offset,
157 unsigned int size, enum drm_map_type type,
158 enum drm_map_flags flags, struct drm_local_map **map_p);
159void drm_legacy_rmmap(struct drm_device *d, struct drm_local_map *map);
160int drm_legacy_rmmap_locked(struct drm_device *d, struct drm_local_map *map);
161void drm_legacy_master_rmmaps(struct drm_device *dev,
162 struct drm_master *master);
163struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
164int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma);
165
166int drm_legacy_addbufs_agp(struct drm_device *d, struct drm_buf_desc *req);
167int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req);
168
169
170
171
172
173
174
175#define LOCK_TEST_WITH_RETURN( dev, _file_priv ) \
176do { \
177 if (!_DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock) || \
178 _file_priv->master->lock.file_priv != _file_priv) { \
179 DRM_ERROR( "%s called without lock held, held %d owner %p %p\n",\
180 __func__, _DRM_LOCK_IS_HELD(_file_priv->master->lock.hw_lock->lock),\
181 _file_priv->master->lock.file_priv, _file_priv); \
182 return -EINVAL; \
183 } \
184} while (0)
185
186void drm_legacy_idlelock_take(struct drm_lock_data *lock);
187void drm_legacy_idlelock_release(struct drm_lock_data *lock);
188
189
190void __drm_legacy_pci_free(struct drm_device *dev, drm_dma_handle_t * dmah);
191
192
193void drm_legacy_ioremap(struct drm_local_map *map, struct drm_device *dev);
194void drm_legacy_ioremap_wc(struct drm_local_map *map, struct drm_device *dev);
195void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev);
196
197static __inline__ struct drm_local_map *drm_legacy_findmap(struct drm_device *dev,
198 unsigned int token)
199{
200 struct drm_map_list *_entry;
201 list_for_each_entry(_entry, &dev->maplist, head)
202 if (_entry->user_token == token)
203 return _entry->map;
204 return NULL;
205}
206
207#endif
208