rev |
line source |
slaxemulator@6303
|
1 diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
|
slaxemulator@6303
|
2 index a8e072d..3446390 100644
|
slaxemulator@6303
|
3 --- a/intel/intel_bufmgr_gem.c
|
slaxemulator@6303
|
4 +++ b/intel/intel_bufmgr_gem.c
|
slaxemulator@6303
|
5 @@ -93,6 +93,7 @@ typedef struct _drm_intel_bufmgr_gem {
|
slaxemulator@6303
|
6 /** Array of lists of cached gem objects of power-of-two sizes */
|
slaxemulator@6303
|
7 struct drm_intel_gem_bo_bucket cache_bucket[14 * 4];
|
slaxemulator@6303
|
8 int num_buckets;
|
slaxemulator@6303
|
9 + time_t time;
|
slaxemulator@6303
|
10
|
slaxemulator@6303
|
11 uint64_t gtt_size;
|
slaxemulator@6303
|
12 int available_fences;
|
slaxemulator@6303
|
13 @@ -132,6 +133,7 @@ struct _drm_intel_bo_gem {
|
slaxemulator@6303
|
14 */
|
slaxemulator@6303
|
15 uint32_t tiling_mode;
|
slaxemulator@6303
|
16 uint32_t swizzle_mode;
|
slaxemulator@6303
|
17 + unsigned long stride;
|
slaxemulator@6303
|
18
|
slaxemulator@6303
|
19 time_t free_time;
|
slaxemulator@6303
|
20
|
slaxemulator@6303
|
21 @@ -200,8 +202,9 @@ drm_intel_gem_bo_get_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
|
slaxemulator@6303
|
22 uint32_t * swizzle_mode);
|
slaxemulator@6303
|
23
|
slaxemulator@6303
|
24 static int
|
slaxemulator@6303
|
25 -drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
|
slaxemulator@6303
|
26 - uint32_t stride);
|
slaxemulator@6303
|
27 +drm_intel_gem_bo_set_tiling_internal(drm_intel_bo *bo,
|
slaxemulator@6303
|
28 + uint32_t tiling_mode,
|
slaxemulator@6303
|
29 + uint32_t stride);
|
slaxemulator@6303
|
30
|
slaxemulator@6303
|
31 static void drm_intel_gem_bo_unreference_locked_timed(drm_intel_bo *bo,
|
slaxemulator@6303
|
32 time_t time);
|
slaxemulator@6303
|
33 @@ -251,7 +254,7 @@ drm_intel_gem_bo_tile_size(drm_intel_bufmgr_gem *bufmgr_gem, unsigned long size,
|
slaxemulator@6303
|
34 */
|
slaxemulator@6303
|
35 static unsigned long
|
slaxemulator@6303
|
36 drm_intel_gem_bo_tile_pitch(drm_intel_bufmgr_gem *bufmgr_gem,
|
slaxemulator@6303
|
37 - unsigned long pitch, uint32_t tiling_mode)
|
slaxemulator@6303
|
38 + unsigned long pitch, uint32_t *tiling_mode)
|
slaxemulator@6303
|
39 {
|
slaxemulator@6303
|
40 unsigned long tile_width;
|
slaxemulator@6303
|
41 unsigned long i;
|
slaxemulator@6303
|
42 @@ -259,10 +262,10 @@ drm_intel_gem_bo_tile_pitch(drm_intel_bufmgr_gem *bufmgr_gem,
|
slaxemulator@6303
|
43 /* If untiled, then just align it so that we can do rendering
|
slaxemulator@6303
|
44 * to it with the 3D engine.
|
slaxemulator@6303
|
45 */
|
slaxemulator@6303
|
46 - if (tiling_mode == I915_TILING_NONE)
|
slaxemulator@6303
|
47 + if (*tiling_mode == I915_TILING_NONE)
|
slaxemulator@6303
|
48 return ALIGN(pitch, 64);
|
slaxemulator@6303
|
49
|
slaxemulator@6303
|
50 - if (tiling_mode == I915_TILING_X)
|
slaxemulator@6303
|
51 + if (*tiling_mode == I915_TILING_X)
|
slaxemulator@6303
|
52 tile_width = 512;
|
slaxemulator@6303
|
53 else
|
slaxemulator@6303
|
54 tile_width = 128;
|
slaxemulator@6303
|
55 @@ -271,6 +274,14 @@ drm_intel_gem_bo_tile_pitch(drm_intel_bufmgr_gem *bufmgr_gem,
|
slaxemulator@6303
|
56 if (bufmgr_gem->gen >= 4)
|
slaxemulator@6303
|
57 return ROUND_UP_TO(pitch, tile_width);
|
slaxemulator@6303
|
58
|
slaxemulator@6303
|
59 + /* The older hardware has a maximum pitch of 8192 with tiled
|
slaxemulator@6303
|
60 + * surfaces, so fallback to untiled if it's too large.
|
slaxemulator@6303
|
61 + */
|
slaxemulator@6303
|
62 + if (pitch > 8192) {
|
slaxemulator@6303
|
63 + *tiling_mode = I915_TILING_NONE;
|
slaxemulator@6303
|
64 + return ALIGN(pitch, 64);
|
slaxemulator@6303
|
65 + }
|
slaxemulator@6303
|
66 +
|
slaxemulator@6303
|
67 /* Pre-965 needs power of two tile width */
|
slaxemulator@6303
|
68 for (i = tile_width; i < pitch; i <<= 1)
|
slaxemulator@6303
|
69 ;
|
slaxemulator@6303
|
70 @@ -549,7 +560,9 @@ static drm_intel_bo *
|
slaxemulator@6303
|
71 drm_intel_gem_bo_alloc_internal(drm_intel_bufmgr *bufmgr,
|
slaxemulator@6303
|
72 const char *name,
|
slaxemulator@6303
|
73 unsigned long size,
|
slaxemulator@6303
|
74 - unsigned long flags)
|
slaxemulator@6303
|
75 + unsigned long flags,
|
slaxemulator@6303
|
76 + uint32_t tiling_mode,
|
slaxemulator@6303
|
77 + unsigned long stride)
|
slaxemulator@6303
|
78 {
|
slaxemulator@6303
|
79 drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bufmgr;
|
slaxemulator@6303
|
80 drm_intel_bo_gem *bo_gem;
|
slaxemulator@6303
|
81 @@ -615,6 +628,13 @@ retry:
|
slaxemulator@6303
|
82 bucket);
|
slaxemulator@6303
|
83 goto retry;
|
slaxemulator@6303
|
84 }
|
slaxemulator@6303
|
85 +
|
slaxemulator@6303
|
86 + if (drm_intel_gem_bo_set_tiling_internal(&bo_gem->bo,
|
slaxemulator@6303
|
87 + tiling_mode,
|
slaxemulator@6303
|
88 + stride)) {
|
slaxemulator@6303
|
89 + drm_intel_gem_bo_free(&bo_gem->bo);
|
slaxemulator@6303
|
90 + goto retry;
|
slaxemulator@6303
|
91 + }
|
slaxemulator@6303
|
92 }
|
slaxemulator@6303
|
93 }
|
slaxemulator@6303
|
94 pthread_mutex_unlock(&bufmgr_gem->lock);
|
slaxemulator@6303
|
95 @@ -642,6 +662,17 @@ retry:
|
slaxemulator@6303
|
96 return NULL;
|
slaxemulator@6303
|
97 }
|
slaxemulator@6303
|
98 bo_gem->bo.bufmgr = bufmgr;
|
slaxemulator@6303
|
99 +
|
slaxemulator@6303
|
100 + bo_gem->tiling_mode = I915_TILING_NONE;
|
slaxemulator@6303
|
101 + bo_gem->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
|
slaxemulator@6303
|
102 + bo_gem->stride = 0;
|
slaxemulator@6303
|
103 +
|
slaxemulator@6303
|
104 + if (drm_intel_gem_bo_set_tiling_internal(&bo_gem->bo,
|
slaxemulator@6303
|
105 + tiling_mode,
|
slaxemulator@6303
|
106 + stride)) {
|
slaxemulator@6303
|
107 + drm_intel_gem_bo_free(&bo_gem->bo);
|
slaxemulator@6303
|
108 + return NULL;
|
slaxemulator@6303
|
109 + }
|
slaxemulator@6303
|
110 }
|
slaxemulator@6303
|
111
|
slaxemulator@6303
|
112 bo_gem->name = name;
|
slaxemulator@6303
|
113 @@ -650,8 +681,6 @@ retry:
|
slaxemulator@6303
|
114 bo_gem->reloc_tree_fences = 0;
|
slaxemulator@6303
|
115 bo_gem->used_as_reloc_target = 0;
|
slaxemulator@6303
|
116 bo_gem->has_error = 0;
|
slaxemulator@6303
|
117 - bo_gem->tiling_mode = I915_TILING_NONE;
|
slaxemulator@6303
|
118 - bo_gem->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
|
slaxemulator@6303
|
119 bo_gem->reusable = 1;
|
slaxemulator@6303
|
120
|
slaxemulator@6303
|
121 drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem);
|
slaxemulator@6303
|
122 @@ -669,7 +698,8 @@ drm_intel_gem_bo_alloc_for_render(drm_intel_bufmgr *bufmgr,
|
slaxemulator@6303
|
123 unsigned int alignment)
|
slaxemulator@6303
|
124 {
|
slaxemulator@6303
|
125 return drm_intel_gem_bo_alloc_internal(bufmgr, name, size,
|
slaxemulator@6303
|
126 - BO_ALLOC_FOR_RENDER);
|
slaxemulator@6303
|
127 + BO_ALLOC_FOR_RENDER,
|
slaxemulator@6303
|
128 + I915_TILING_NONE, 0);
|
slaxemulator@6303
|
129 }
|
slaxemulator@6303
|
130
|
slaxemulator@6303
|
131 static drm_intel_bo *
|
slaxemulator@6303
|
132 @@ -678,7 +708,8 @@ drm_intel_gem_bo_alloc(drm_intel_bufmgr *bufmgr,
|
slaxemulator@6303
|
133 unsigned long size,
|
slaxemulator@6303
|
134 unsigned int alignment)
|
slaxemulator@6303
|
135 {
|
slaxemulator@6303
|
136 - return drm_intel_gem_bo_alloc_internal(bufmgr, name, size, 0);
|
slaxemulator@6303
|
137 + return drm_intel_gem_bo_alloc_internal(bufmgr, name, size, 0,
|
slaxemulator@6303
|
138 + I915_TILING_NONE, 0);
|
slaxemulator@6303
|
139 }
|
slaxemulator@6303
|
140
|
slaxemulator@6303
|
141 static drm_intel_bo *
|
slaxemulator@6303
|
142 @@ -687,10 +718,8 @@ drm_intel_gem_bo_alloc_tiled(drm_intel_bufmgr *bufmgr, const char *name,
|
slaxemulator@6303
|
143 unsigned long *pitch, unsigned long flags)
|
slaxemulator@6303
|
144 {
|
slaxemulator@6303
|
145 drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *)bufmgr;
|
slaxemulator@6303
|
146 - drm_intel_bo *bo;
|
slaxemulator@6303
|
147 unsigned long size, stride;
|
slaxemulator@6303
|
148 uint32_t tiling;
|
slaxemulator@6303
|
149 - int ret;
|
slaxemulator@6303
|
150
|
slaxemulator@6303
|
151 do {
|
slaxemulator@6303
|
152 unsigned long aligned_y;
|
slaxemulator@6303
|
153 @@ -717,24 +746,17 @@ drm_intel_gem_bo_alloc_tiled(drm_intel_bufmgr *bufmgr, const char *name,
|
slaxemulator@6303
|
154 aligned_y = ALIGN(y, 32);
|
slaxemulator@6303
|
155
|
slaxemulator@6303
|
156 stride = x * cpp;
|
slaxemulator@6303
|
157 - stride = drm_intel_gem_bo_tile_pitch(bufmgr_gem, stride, tiling);
|
slaxemulator@6303
|
158 + stride = drm_intel_gem_bo_tile_pitch(bufmgr_gem, stride, tiling_mode);
|
slaxemulator@6303
|
159 size = stride * aligned_y;
|
slaxemulator@6303
|
160 size = drm_intel_gem_bo_tile_size(bufmgr_gem, size, tiling_mode);
|
slaxemulator@6303
|
161 } while (*tiling_mode != tiling);
|
slaxemulator@6303
|
162 -
|
slaxemulator@6303
|
163 - bo = drm_intel_gem_bo_alloc_internal(bufmgr, name, size, flags);
|
slaxemulator@6303
|
164 - if (!bo)
|
slaxemulator@6303
|
165 - return NULL;
|
slaxemulator@6303
|
166 -
|
slaxemulator@6303
|
167 - ret = drm_intel_gem_bo_set_tiling(bo, tiling_mode, stride);
|
slaxemulator@6303
|
168 - if (ret != 0) {
|
slaxemulator@6303
|
169 - drm_intel_gem_bo_unreference(bo);
|
slaxemulator@6303
|
170 - return NULL;
|
slaxemulator@6303
|
171 - }
|
slaxemulator@6303
|
172 -
|
slaxemulator@6303
|
173 *pitch = stride;
|
slaxemulator@6303
|
174
|
slaxemulator@6303
|
175 - return bo;
|
slaxemulator@6303
|
176 + if (tiling == I915_TILING_NONE)
|
slaxemulator@6303
|
177 + stride = 0;
|
slaxemulator@6303
|
178 +
|
slaxemulator@6303
|
179 + return drm_intel_gem_bo_alloc_internal(bufmgr, name, size, flags,
|
slaxemulator@6303
|
180 + tiling, stride);
|
slaxemulator@6303
|
181 }
|
slaxemulator@6303
|
182
|
slaxemulator@6303
|
183 /**
|
slaxemulator@6303
|
184 @@ -791,6 +813,7 @@ drm_intel_bo_gem_create_from_name(drm_intel_bufmgr *bufmgr,
|
slaxemulator@6303
|
185 }
|
slaxemulator@6303
|
186 bo_gem->tiling_mode = get_tiling.tiling_mode;
|
slaxemulator@6303
|
187 bo_gem->swizzle_mode = get_tiling.swizzle_mode;
|
slaxemulator@6303
|
188 + /* XXX stride is unknown */
|
slaxemulator@6303
|
189 drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem);
|
slaxemulator@6303
|
190
|
slaxemulator@6303
|
191 DBG("bo_create_from_handle: %d (%s)\n", handle, bo_gem->name);
|
slaxemulator@6303
|
192 @@ -829,6 +852,9 @@ drm_intel_gem_cleanup_bo_cache(drm_intel_bufmgr_gem *bufmgr_gem, time_t time)
|
slaxemulator@6303
|
193 {
|
slaxemulator@6303
|
194 int i;
|
slaxemulator@6303
|
195
|
slaxemulator@6303
|
196 + if (bufmgr_gem->time == time)
|
slaxemulator@6303
|
197 + return;
|
slaxemulator@6303
|
198 +
|
slaxemulator@6303
|
199 for (i = 0; i < bufmgr_gem->num_buckets; i++) {
|
slaxemulator@6303
|
200 struct drm_intel_gem_bo_bucket *bucket =
|
slaxemulator@6303
|
201 &bufmgr_gem->cache_bucket[i];
|
slaxemulator@6303
|
202 @@ -846,6 +872,8 @@ drm_intel_gem_cleanup_bo_cache(drm_intel_bufmgr_gem *bufmgr_gem, time_t time)
|
slaxemulator@6303
|
203 drm_intel_gem_bo_free(&bo_gem->bo);
|
slaxemulator@6303
|
204 }
|
slaxemulator@6303
|
205 }
|
slaxemulator@6303
|
206 +
|
slaxemulator@6303
|
207 + bufmgr_gem->time = time;
|
slaxemulator@6303
|
208 }
|
slaxemulator@6303
|
209
|
slaxemulator@6303
|
210 static void
|
slaxemulator@6303
|
211 @@ -854,7 +882,6 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
|
slaxemulator@6303
|
212 drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
|
slaxemulator@6303
|
213 drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
|
slaxemulator@6303
|
214 struct drm_intel_gem_bo_bucket *bucket;
|
slaxemulator@6303
|
215 - uint32_t tiling_mode;
|
slaxemulator@6303
|
216 int i;
|
slaxemulator@6303
|
217
|
slaxemulator@6303
|
218 /* Unreference all the target buffers */
|
slaxemulator@6303
|
219 @@ -883,9 +910,7 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
|
slaxemulator@6303
|
220
|
slaxemulator@6303
|
221 bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, bo->size);
|
slaxemulator@6303
|
222 /* Put the buffer into our internal cache for reuse if we can. */
|
slaxemulator@6303
|
223 - tiling_mode = I915_TILING_NONE;
|
slaxemulator@6303
|
224 if (bufmgr_gem->bo_reuse && bo_gem->reusable && bucket != NULL &&
|
slaxemulator@6303
|
225 - drm_intel_gem_bo_set_tiling(bo, &tiling_mode, 0) == 0 &&
|
slaxemulator@6303
|
226 drm_intel_gem_bo_madvise_internal(bufmgr_gem, bo_gem,
|
slaxemulator@6303
|
227 I915_MADV_DONTNEED)) {
|
slaxemulator@6303
|
228 bo_gem->free_time = time;
|
slaxemulator@6303
|
229 @@ -894,8 +919,6 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
|
slaxemulator@6303
|
230 bo_gem->validate_index = -1;
|
slaxemulator@6303
|
231
|
slaxemulator@6303
|
232 DRMLISTADDTAIL(&bo_gem->head, &bucket->head);
|
slaxemulator@6303
|
233 -
|
slaxemulator@6303
|
234 - drm_intel_gem_cleanup_bo_cache(bufmgr_gem, time);
|
slaxemulator@6303
|
235 } else {
|
slaxemulator@6303
|
236 drm_intel_gem_bo_free(bo);
|
slaxemulator@6303
|
237 }
|
slaxemulator@6303
|
238 @@ -925,6 +948,7 @@ static void drm_intel_gem_bo_unreference(drm_intel_bo *bo)
|
slaxemulator@6303
|
239
|
slaxemulator@6303
|
240 pthread_mutex_lock(&bufmgr_gem->lock);
|
slaxemulator@6303
|
241 drm_intel_gem_bo_unreference_final(bo, time.tv_sec);
|
slaxemulator@6303
|
242 + drm_intel_gem_cleanup_bo_cache(bufmgr_gem, time.tv_sec);
|
slaxemulator@6303
|
243 pthread_mutex_unlock(&bufmgr_gem->lock);
|
slaxemulator@6303
|
244 }
|
slaxemulator@6303
|
245 }
|
slaxemulator@6303
|
246 @@ -982,12 +1006,9 @@ static int drm_intel_gem_bo_map(drm_intel_bo *bo, int write_enable)
|
slaxemulator@6303
|
247 &set_domain);
|
slaxemulator@6303
|
248 } while (ret == -1 && errno == EINTR);
|
slaxemulator@6303
|
249 if (ret != 0) {
|
slaxemulator@6303
|
250 - ret = -errno;
|
slaxemulator@6303
|
251 fprintf(stderr, "%s:%d: Error setting to CPU domain %d: %s\n",
|
slaxemulator@6303
|
252 __FILE__, __LINE__, bo_gem->gem_handle,
|
slaxemulator@6303
|
253 strerror(errno));
|
slaxemulator@6303
|
254 - pthread_mutex_unlock(&bufmgr_gem->lock);
|
slaxemulator@6303
|
255 - return ret;
|
slaxemulator@6303
|
256 }
|
slaxemulator@6303
|
257
|
slaxemulator@6303
|
258 pthread_mutex_unlock(&bufmgr_gem->lock);
|
slaxemulator@6303
|
259 @@ -1062,9 +1083,7 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
|
slaxemulator@6303
|
260 DRM_IOCTL_I915_GEM_SET_DOMAIN,
|
slaxemulator@6303
|
261 &set_domain);
|
slaxemulator@6303
|
262 } while (ret == -1 && errno == EINTR);
|
slaxemulator@6303
|
263 -
|
slaxemulator@6303
|
264 if (ret != 0) {
|
slaxemulator@6303
|
265 - ret = -errno;
|
slaxemulator@6303
|
266 fprintf(stderr, "%s:%d: Error setting domain %d: %s\n",
|
slaxemulator@6303
|
267 __FILE__, __LINE__, bo_gem->gem_handle,
|
slaxemulator@6303
|
268 strerror(errno));
|
slaxemulator@6303
|
269 @@ -1072,7 +1091,7 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo)
|
slaxemulator@6303
|
270
|
slaxemulator@6303
|
271 pthread_mutex_unlock(&bufmgr_gem->lock);
|
slaxemulator@6303
|
272
|
slaxemulator@6303
|
273 - return ret;
|
slaxemulator@6303
|
274 + return 0;
|
slaxemulator@6303
|
275 }
|
slaxemulator@6303
|
276
|
slaxemulator@6303
|
277 int drm_intel_gem_bo_unmap_gtt(drm_intel_bo *bo)
|
slaxemulator@6303
|
278 @@ -1587,7 +1606,7 @@ drm_intel_gem_bo_mrb_exec2(drm_intel_bo *bo, int used,
|
slaxemulator@6303
|
279
|
slaxemulator@6303
|
280 if (ret != 0) {
|
slaxemulator@6303
|
281 ret = -errno;
|
slaxemulator@6303
|
282 - if (ret == -ENOMEM) {
|
slaxemulator@6303
|
283 + if (ret == -ENOSPC) {
|
slaxemulator@6303
|
284 fprintf(stderr,
|
slaxemulator@6303
|
285 "Execbuffer fails to pin. "
|
slaxemulator@6303
|
286 "Estimate: %u. Actual: %u. Available: %u\n",
|
slaxemulator@6303
|
287 @@ -1671,34 +1690,56 @@ drm_intel_gem_bo_unpin(drm_intel_bo *bo)
|
slaxemulator@6303
|
288 }
|
slaxemulator@6303
|
289
|
slaxemulator@6303
|
290 static int
|
slaxemulator@6303
|
291 -drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
|
slaxemulator@6303
|
292 - uint32_t stride)
|
slaxemulator@6303
|
293 +drm_intel_gem_bo_set_tiling_internal(drm_intel_bo *bo,
|
slaxemulator@6303
|
294 + uint32_t tiling_mode,
|
slaxemulator@6303
|
295 + uint32_t stride)
|
slaxemulator@6303
|
296 {
|
slaxemulator@6303
|
297 drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
|
slaxemulator@6303
|
298 drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
|
slaxemulator@6303
|
299 struct drm_i915_gem_set_tiling set_tiling;
|
slaxemulator@6303
|
300 int ret;
|
slaxemulator@6303
|
301
|
slaxemulator@6303
|
302 - if (bo_gem->global_name == 0 && *tiling_mode == bo_gem->tiling_mode)
|
slaxemulator@6303
|
303 + if (bo_gem->global_name == 0 &&
|
slaxemulator@6303
|
304 + tiling_mode == bo_gem->tiling_mode &&
|
slaxemulator@6303
|
305 + stride == bo_gem->stride)
|
slaxemulator@6303
|
306 return 0;
|
slaxemulator@6303
|
307
|
slaxemulator@6303
|
308 memset(&set_tiling, 0, sizeof(set_tiling));
|
slaxemulator@6303
|
309 - set_tiling.handle = bo_gem->gem_handle;
|
slaxemulator@6303
|
310 -
|
slaxemulator@6303
|
311 do {
|
slaxemulator@6303
|
312 - set_tiling.tiling_mode = *tiling_mode;
|
slaxemulator@6303
|
313 + set_tiling.handle = bo_gem->gem_handle;
|
slaxemulator@6303
|
314 + set_tiling.tiling_mode = tiling_mode;
|
slaxemulator@6303
|
315 set_tiling.stride = stride;
|
slaxemulator@6303
|
316
|
slaxemulator@6303
|
317 ret = ioctl(bufmgr_gem->fd,
|
slaxemulator@6303
|
318 DRM_IOCTL_I915_GEM_SET_TILING,
|
slaxemulator@6303
|
319 &set_tiling);
|
slaxemulator@6303
|
320 } while (ret == -1 && errno == EINTR);
|
slaxemulator@6303
|
321 - if (ret == 0) {
|
slaxemulator@6303
|
322 - bo_gem->tiling_mode = set_tiling.tiling_mode;
|
slaxemulator@6303
|
323 - bo_gem->swizzle_mode = set_tiling.swizzle_mode;
|
slaxemulator@6303
|
324 + if (ret == -1)
|
slaxemulator@6303
|
325 + return -errno;
|
slaxemulator@6303
|
326 +
|
slaxemulator@6303
|
327 + bo_gem->tiling_mode = set_tiling.tiling_mode;
|
slaxemulator@6303
|
328 + bo_gem->swizzle_mode = set_tiling.swizzle_mode;
|
slaxemulator@6303
|
329 + bo_gem->stride = set_tiling.stride;
|
slaxemulator@6303
|
330 + return 0;
|
slaxemulator@6303
|
331 +}
|
slaxemulator@6303
|
332 +
|
slaxemulator@6303
|
333 +static int
|
slaxemulator@6303
|
334 +drm_intel_gem_bo_set_tiling(drm_intel_bo *bo, uint32_t * tiling_mode,
|
slaxemulator@6303
|
335 + uint32_t stride)
|
slaxemulator@6303
|
336 +{
|
slaxemulator@6303
|
337 + drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr;
|
slaxemulator@6303
|
338 + drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo;
|
slaxemulator@6303
|
339 + int ret;
|
slaxemulator@6303
|
340 +
|
slaxemulator@6303
|
341 + /* Linear buffers have no stride. By ensuring that we only ever use
|
slaxemulator@6303
|
342 + * stride 0 with linear buffers, we simplify our code.
|
slaxemulator@6303
|
343 + */
|
slaxemulator@6303
|
344 + if (*tiling_mode == I915_TILING_NONE)
|
slaxemulator@6303
|
345 + stride = 0;
|
slaxemulator@6303
|
346 +
|
slaxemulator@6303
|
347 + ret = drm_intel_gem_bo_set_tiling_internal(bo, *tiling_mode, stride);
|
slaxemulator@6303
|
348 + if (ret == 0)
|
slaxemulator@6303
|
349 drm_intel_bo_gem_set_in_aperture_size(bufmgr_gem, bo_gem);
|
slaxemulator@6303
|
350 - } else
|
slaxemulator@6303
|
351 - ret = -errno;
|
slaxemulator@6303
|
352
|
slaxemulator@6303
|
353 *tiling_mode = bo_gem->tiling_mode;
|
slaxemulator@6303
|
354 return ret;
|
slaxemulator@6303
|
355 diff --git a/xf86drmMode.c b/xf86drmMode.c
|
slaxemulator@6303
|
356 index f330e6f..ecb1fd5 100644
|
slaxemulator@6303
|
357 --- a/xf86drmMode.c
|
slaxemulator@6303
|
358 +++ b/xf86drmMode.c
|
slaxemulator@6303
|
359 @@ -52,6 +52,12 @@
|
slaxemulator@6303
|
360 #define U642VOID(x) ((void *)(unsigned long)(x))
|
slaxemulator@6303
|
361 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
|
slaxemulator@6303
|
362
|
slaxemulator@6303
|
363 +static inline DRM_IOCTL(int fd, int cmd, void *arg)
|
slaxemulator@6303
|
364 +{
|
slaxemulator@6303
|
365 + int ret = drmIoctl(fd, cmd, arg);
|
slaxemulator@6303
|
366 + return ret < 0 ? -errno : ret;
|
slaxemulator@6303
|
367 +}
|
slaxemulator@6303
|
368 +
|
slaxemulator@6303
|
369 /*
|
slaxemulator@6303
|
370 * Util functions
|
slaxemulator@6303
|
371 */
|
slaxemulator@6303
|
372 @@ -242,7 +248,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
|
slaxemulator@6303
|
373 f.depth = depth;
|
slaxemulator@6303
|
374 f.handle = bo_handle;
|
slaxemulator@6303
|
375
|
slaxemulator@6303
|
376 - if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_ADDFB, &f)))
|
slaxemulator@6303
|
377 + if ((ret = DRM_IOCTL(fd, DRM_IOCTL_MODE_ADDFB, &f)))
|
slaxemulator@6303
|
378 return ret;
|
slaxemulator@6303
|
379
|
slaxemulator@6303
|
380 *buf_id = f.fb_id;
|
slaxemulator@6303
|
381 @@ -251,7 +257,7 @@ int drmModeAddFB(int fd, uint32_t width, uint32_t height, uint8_t depth,
|
slaxemulator@6303
|
382
|
slaxemulator@6303
|
383 int drmModeRmFB(int fd, uint32_t bufferId)
|
slaxemulator@6303
|
384 {
|
slaxemulator@6303
|
385 - return drmIoctl(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
|
slaxemulator@6303
|
386 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_RMFB, &bufferId);
|
slaxemulator@6303
|
387
|
slaxemulator@6303
|
388
|
slaxemulator@6303
|
389 }
|
slaxemulator@6303
|
390 @@ -289,7 +295,7 @@ int drmModeDirtyFB(int fd, uint32_t bufferId,
|
slaxemulator@6303
|
391 dirty.clips_ptr = VOID2U64(clips);
|
slaxemulator@6303
|
392 dirty.num_clips = num_clips;
|
slaxemulator@6303
|
393
|
slaxemulator@6303
|
394 - return drmIoctl(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty);
|
slaxemulator@6303
|
395 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_DIRTYFB, &dirty);
|
slaxemulator@6303
|
396 }
|
slaxemulator@6303
|
397
|
slaxemulator@6303
|
398
|
slaxemulator@6303
|
399 @@ -344,7 +350,7 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
|
slaxemulator@6303
|
400 } else
|
slaxemulator@6303
|
401 crtc.mode_valid = 0;
|
slaxemulator@6303
|
402
|
slaxemulator@6303
|
403 - return drmIoctl(fd, DRM_IOCTL_MODE_SETCRTC, &crtc);
|
slaxemulator@6303
|
404 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETCRTC, &crtc);
|
slaxemulator@6303
|
405 }
|
slaxemulator@6303
|
406
|
slaxemulator@6303
|
407 /*
|
slaxemulator@6303
|
408 @@ -361,7 +367,7 @@ int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width
|
slaxemulator@6303
|
409 arg.height = height;
|
slaxemulator@6303
|
410 arg.handle = bo_handle;
|
slaxemulator@6303
|
411
|
slaxemulator@6303
|
412 - return drmIoctl(fd, DRM_IOCTL_MODE_CURSOR, &arg);
|
slaxemulator@6303
|
413 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_CURSOR, &arg);
|
slaxemulator@6303
|
414 }
|
slaxemulator@6303
|
415
|
slaxemulator@6303
|
416 int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y)
|
slaxemulator@6303
|
417 @@ -373,7 +379,7 @@ int drmModeMoveCursor(int fd, uint32_t crtcId, int x, int y)
|
slaxemulator@6303
|
418 arg.x = x;
|
slaxemulator@6303
|
419 arg.y = y;
|
slaxemulator@6303
|
420
|
slaxemulator@6303
|
421 - return drmIoctl(fd, DRM_IOCTL_MODE_CURSOR, &arg);
|
slaxemulator@6303
|
422 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_CURSOR, &arg);
|
slaxemulator@6303
|
423 }
|
slaxemulator@6303
|
424
|
slaxemulator@6303
|
425 /*
|
slaxemulator@6303
|
426 @@ -510,7 +516,7 @@ int drmModeAttachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_inf
|
slaxemulator@6303
|
427 memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo));
|
slaxemulator@6303
|
428 res.connector_id = connector_id;
|
slaxemulator@6303
|
429
|
slaxemulator@6303
|
430 - return drmIoctl(fd, DRM_IOCTL_MODE_ATTACHMODE, &res);
|
slaxemulator@6303
|
431 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_ATTACHMODE, &res);
|
slaxemulator@6303
|
432 }
|
slaxemulator@6303
|
433
|
slaxemulator@6303
|
434 int drmModeDetachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_info)
|
slaxemulator@6303
|
435 @@ -520,7 +526,7 @@ int drmModeDetachMode(int fd, uint32_t connector_id, drmModeModeInfoPtr mode_inf
|
slaxemulator@6303
|
436 memcpy(&res.mode, mode_info, sizeof(struct drm_mode_modeinfo));
|
slaxemulator@6303
|
437 res.connector_id = connector_id;
|
slaxemulator@6303
|
438
|
slaxemulator@6303
|
439 - return drmIoctl(fd, DRM_IOCTL_MODE_DETACHMODE, &res);
|
slaxemulator@6303
|
440 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_DETACHMODE, &res);
|
slaxemulator@6303
|
441 }
|
slaxemulator@6303
|
442
|
slaxemulator@6303
|
443
|
slaxemulator@6303
|
444 @@ -637,16 +643,12 @@ int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property
|
slaxemulator@6303
|
445 uint64_t value)
|
slaxemulator@6303
|
446 {
|
slaxemulator@6303
|
447 struct drm_mode_connector_set_property osp;
|
slaxemulator@6303
|
448 - int ret;
|
slaxemulator@6303
|
449
|
slaxemulator@6303
|
450 osp.connector_id = connector_id;
|
slaxemulator@6303
|
451 osp.prop_id = property_id;
|
slaxemulator@6303
|
452 osp.value = value;
|
slaxemulator@6303
|
453
|
slaxemulator@6303
|
454 - if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_SETPROPERTY, &osp)))
|
slaxemulator@6303
|
455 - return ret;
|
slaxemulator@6303
|
456 -
|
slaxemulator@6303
|
457 - return 0;
|
slaxemulator@6303
|
458 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETPROPERTY, &osp);
|
slaxemulator@6303
|
459 }
|
slaxemulator@6303
|
460
|
slaxemulator@6303
|
461 /*
|
slaxemulator@6303
|
462 @@ -715,7 +717,6 @@ int drmCheckModesettingSupported(const char *busid)
|
slaxemulator@6303
|
463 int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
|
slaxemulator@6303
|
464 uint16_t *red, uint16_t *green, uint16_t *blue)
|
slaxemulator@6303
|
465 {
|
slaxemulator@6303
|
466 - int ret;
|
slaxemulator@6303
|
467 struct drm_mode_crtc_lut l;
|
slaxemulator@6303
|
468
|
slaxemulator@6303
|
469 l.crtc_id = crtc_id;
|
slaxemulator@6303
|
470 @@ -724,16 +725,12 @@ int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,
|
slaxemulator@6303
|
471 l.green = VOID2U64(green);
|
slaxemulator@6303
|
472 l.blue = VOID2U64(blue);
|
slaxemulator@6303
|
473
|
slaxemulator@6303
|
474 - if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_GETGAMMA, &l)))
|
slaxemulator@6303
|
475 - return ret;
|
slaxemulator@6303
|
476 -
|
slaxemulator@6303
|
477 - return 0;
|
slaxemulator@6303
|
478 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_GETGAMMA, &l);
|
slaxemulator@6303
|
479 }
|
slaxemulator@6303
|
480
|
slaxemulator@6303
|
481 int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
|
slaxemulator@6303
|
482 uint16_t *red, uint16_t *green, uint16_t *blue)
|
slaxemulator@6303
|
483 {
|
slaxemulator@6303
|
484 - int ret;
|
slaxemulator@6303
|
485 struct drm_mode_crtc_lut l;
|
slaxemulator@6303
|
486
|
slaxemulator@6303
|
487 l.crtc_id = crtc_id;
|
slaxemulator@6303
|
488 @@ -742,10 +739,7 @@ int drmModeCrtcSetGamma(int fd, uint32_t crtc_id, uint32_t size,
|
slaxemulator@6303
|
489 l.green = VOID2U64(green);
|
slaxemulator@6303
|
490 l.blue = VOID2U64(blue);
|
slaxemulator@6303
|
491
|
slaxemulator@6303
|
492 - if ((ret = drmIoctl(fd, DRM_IOCTL_MODE_SETGAMMA, &l)))
|
slaxemulator@6303
|
493 - return ret;
|
slaxemulator@6303
|
494 -
|
slaxemulator@6303
|
495 - return 0;
|
slaxemulator@6303
|
496 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_SETGAMMA, &l);
|
slaxemulator@6303
|
497 }
|
slaxemulator@6303
|
498
|
slaxemulator@6303
|
499 int drmHandleEvent(int fd, drmEventContextPtr evctx)
|
slaxemulator@6303
|
500 @@ -810,5 +804,5 @@ int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id,
|
slaxemulator@6303
|
501 flip.flags = flags;
|
slaxemulator@6303
|
502 flip.reserved = 0;
|
slaxemulator@6303
|
503
|
slaxemulator@6303
|
504 - return drmIoctl(fd, DRM_IOCTL_MODE_PAGE_FLIP, &flip);
|
slaxemulator@6303
|
505 + return DRM_IOCTL(fd, DRM_IOCTL_MODE_PAGE_FLIP, &flip);
|
slaxemulator@6303
|
506 }
|