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