blob: b7f591c5f28244f1e9934dc09cd8fea2da9e46dc [file] [log] [blame]
Stéphane Marchesin25a26062014-09-12 16:18:59 -07001/*
Daniele Castagna7a755de2016-12-16 17:32:30 -05002 * Copyright 2014 The Chromium OS Authors. All rights reserved.
Stéphane Marchesin25a26062014-09-12 16:18:59 -07003 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
Gurchetan Singh46faf6b2016-08-05 14:40:07 -07007#ifdef DRV_I915
Stéphane Marchesin25a26062014-09-12 16:18:59 -07008
9#include <errno.h>
Gurchetan Singh82a8eed2017-01-03 13:01:37 -080010#include <i915_drm.h>
11#include <intel_bufmgr.h>
Stéphane Marchesin25a26062014-09-12 16:18:59 -070012#include <string.h>
Gurchetan Singhef920532016-08-12 16:38:25 -070013#include <sys/mman.h>
Stéphane Marchesin25a26062014-09-12 16:18:59 -070014#include <xf86drm.h>
Stéphane Marchesin25a26062014-09-12 16:18:59 -070015
Gurchetan Singh46faf6b2016-08-05 14:40:07 -070016#include "drv_priv.h"
Stéphane Marchesin25a26062014-09-12 16:18:59 -070017#include "helpers.h"
18#include "util.h"
19
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080020static const uint32_t tileable_formats[] = { DRM_FORMAT_ARGB1555, DRM_FORMAT_ABGR8888,
21 DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
22 DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB1555,
23 DRM_FORMAT_XRGB8888, DRM_FORMAT_UYVY,
24 DRM_FORMAT_YUYV };
Gurchetan Singh6b41fb52017-03-01 20:14:39 -080025
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080026static const uint32_t linear_only_formats[] = { DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_YVU420,
27 DRM_FORMAT_YVU420_ANDROID };
Gurchetan Singh179687e2016-10-28 10:07:35 -070028
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080029struct i915_device {
Stéphane Marchesin25a26062014-09-12 16:18:59 -070030 int gen;
Gurchetan Singh82a8eed2017-01-03 13:01:37 -080031 drm_intel_bufmgr *mgr;
32 uint32_t count;
33};
34
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080035struct i915_bo {
Gurchetan Singh82a8eed2017-01-03 13:01:37 -080036 drm_intel_bo *ibos[DRV_MAX_PLANES];
Stéphane Marchesin25a26062014-09-12 16:18:59 -070037};
38
Stéphane Marchesin25a26062014-09-12 16:18:59 -070039static int get_gen(int device_id)
40{
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080041 const uint16_t gen3_ids[] = { 0x2582, 0x2592, 0x2772, 0x27A2, 0x27AE,
42 0x29C2, 0x29B2, 0x29D2, 0xA001, 0xA011 };
Stéphane Marchesina39dfde2014-09-15 15:38:25 -070043 unsigned i;
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080044 for (i = 0; i < ARRAY_SIZE(gen3_ids); i++)
Stéphane Marchesin25a26062014-09-12 16:18:59 -070045 if (gen3_ids[i] == device_id)
46 return 3;
47
48 return 4;
49}
50
Gurchetan Singh6b41fb52017-03-01 20:14:39 -080051static int i915_add_kms_item(struct driver *drv, const struct kms_item *item)
52{
53 uint32_t i;
54 struct combination *combo;
55
56 /*
57 * Older hardware can't scanout Y-tiled formats. Newer devices can, and
58 * report this functionality via format modifiers.
59 */
60 for (i = 0; i < drv->backend->combos.size; i++) {
61 combo = &drv->backend->combos.data[i];
62 if (combo->format == item->format) {
63 if ((combo->metadata.tiling == I915_TILING_Y &&
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080064 item->modifier == I915_FORMAT_MOD_Y_TILED) ||
Gurchetan Singh6b41fb52017-03-01 20:14:39 -080065 (combo->metadata.tiling == I915_TILING_X &&
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080066 item->modifier == I915_FORMAT_MOD_X_TILED)) {
Gurchetan Singh6b41fb52017-03-01 20:14:39 -080067 combo->metadata.modifier = item->modifier;
68 combo->usage |= item->usage;
69 } else if (combo->metadata.tiling != I915_TILING_Y) {
70 combo->usage |= item->usage;
71 }
72 }
73 }
74
75 return 0;
76}
77
78static int i915_add_combinations(struct driver *drv)
79{
80 int ret;
81 uint32_t i, num_items;
82 struct kms_item *items;
83 struct format_metadata metadata;
84 uint64_t flags = BO_COMMON_USE_MASK;
85
86 metadata.tiling = I915_TILING_NONE;
87 metadata.priority = 1;
88 metadata.modifier = DRM_FORMAT_MOD_NONE;
89
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080090 ret = drv_add_combinations(drv, linear_only_formats, ARRAY_SIZE(linear_only_formats),
91 &metadata, flags);
92 if (ret)
93 return ret;
94
95 ret = drv_add_combinations(drv, tileable_formats, ARRAY_SIZE(tileable_formats), &metadata,
Gurchetan Singh6b41fb52017-03-01 20:14:39 -080096 flags);
97 if (ret)
98 return ret;
99
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800100 drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
101 drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800102
103 flags &= ~BO_USE_SW_WRITE_OFTEN;
104 flags &= ~BO_USE_SW_READ_OFTEN;
105 flags &= ~BO_USE_LINEAR;
106
107 metadata.tiling = I915_TILING_X;
108 metadata.priority = 2;
109
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800110 ret = drv_add_combinations(drv, tileable_formats, ARRAY_SIZE(tileable_formats), &metadata,
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800111 flags);
112 if (ret)
113 return ret;
114
115 metadata.tiling = I915_TILING_Y;
116 metadata.priority = 3;
117
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800118 ret = drv_add_combinations(drv, tileable_formats, ARRAY_SIZE(tileable_formats), &metadata,
119 flags);
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800120 if (ret)
121 return ret;
122
123 items = drv_query_kms(drv, &num_items);
124 if (!items || !num_items)
125 return 0;
126
127 for (i = 0; i < num_items; i++) {
128 ret = i915_add_kms_item(drv, &items[i]);
129 if (ret) {
130 free(items);
131 return ret;
132 }
133 }
134
135 free(items);
136 return 0;
137}
138
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800139static int i915_align_dimensions(struct bo *bo, uint32_t tiling, uint32_t *stride,
140 uint32_t *aligned_height)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700141{
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700142 struct i915_device *i915 = bo->drv->priv;
143 uint32_t horizontal_alignment = 4;
144 uint32_t vertical_alignment = 4;
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700145
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700146 switch (tiling) {
Gurchetan Singhd6fb5772016-08-29 19:13:51 -0700147 default:
148 case I915_TILING_NONE:
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700149 horizontal_alignment = 64;
Gurchetan Singhd6fb5772016-08-29 19:13:51 -0700150 break;
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800151
Gurchetan Singhd6fb5772016-08-29 19:13:51 -0700152 case I915_TILING_X:
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700153 horizontal_alignment = 512;
154 vertical_alignment = 8;
Gurchetan Singhd6fb5772016-08-29 19:13:51 -0700155 break;
156
157 case I915_TILING_Y:
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700158 if (i915->gen == 3) {
159 horizontal_alignment = 512;
160 vertical_alignment = 8;
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800161 } else {
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700162 horizontal_alignment = 128;
163 vertical_alignment = 32;
Gurchetan Singhd6fb5772016-08-29 19:13:51 -0700164 }
165 break;
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700166 }
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800167
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700168 *aligned_height = ALIGN(bo->height, vertical_alignment);
169 if (i915->gen > 3) {
170 *stride = ALIGN(*stride, horizontal_alignment);
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800171 } else {
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700172 while (*stride > horizontal_alignment)
173 horizontal_alignment <<= 1;
174
175 *stride = horizontal_alignment;
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800176 }
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800177
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700178 if (i915->gen <= 3 && *stride > 8192)
179 return -EINVAL;
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800180
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700181 return 0;
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700182}
183
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800184static int i915_init(struct driver *drv)
185{
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800186 struct i915_device *i915_dev;
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800187 drm_i915_getparam_t get_param;
188 int device_id;
189 int ret;
190
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800191 i915_dev = calloc(1, sizeof(*i915_dev));
192 if (!i915_dev)
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800193 return -1;
194
195 memset(&get_param, 0, sizeof(get_param));
196 get_param.param = I915_PARAM_CHIPSET_ID;
197 get_param.value = &device_id;
198 ret = drmIoctl(drv->fd, DRM_IOCTL_I915_GETPARAM, &get_param);
199 if (ret) {
200 fprintf(stderr, "drv: DRM_IOCTL_I915_GETPARAM failed\n");
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800201 free(i915_dev);
202 return -EINVAL;
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800203 }
204
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800205 i915_dev->gen = get_gen(device_id);
206 i915_dev->count = 0;
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800207
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800208 i915_dev->mgr = drm_intel_bufmgr_gem_init(drv->fd, 16 * 1024);
209 if (!i915_dev->mgr) {
210 fprintf(stderr, "drv: drm_intel_bufmgr_gem_init failed\n");
211 free(i915_dev);
212 return -EINVAL;
213 }
214
215 drv->priv = i915_dev;
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800216
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800217 return i915_add_combinations(drv);
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800218}
219
220static void i915_close(struct driver *drv)
221{
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800222 struct i915_device *i915_dev = drv->priv;
223 drm_intel_bufmgr_destroy(i915_dev->mgr);
224 free(i915_dev);
Gurchetan Singh3eb8d8f2017-01-03 13:36:13 -0800225 drv->priv = NULL;
226}
227
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800228static int i915_bo_create(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
229 uint32_t flags)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700230{
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700231 int ret;
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800232 size_t plane;
233 char name[20];
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700234 uint32_t stride;
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800235 uint32_t tiling_mode;
236 struct i915_bo *i915_bo;
237
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700238 stride = drv_stride_from_format(format, width, 0);
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800239 struct i915_device *i915_dev = (struct i915_device *)bo->drv->priv;
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700240
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800241 if (flags & (BO_USE_CURSOR | BO_USE_LINEAR | BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN))
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700242 tiling_mode = I915_TILING_NONE;
Gurchetan Singh458976f2016-11-23 17:32:33 -0800243 else if (flags & BO_USE_SCANOUT)
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700244 tiling_mode = I915_TILING_X;
Gurchetan Singh6bab0c12016-10-13 19:08:48 -0700245 else
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700246 tiling_mode = I915_TILING_Y;
247
Gurchetan Singh507f5dd2017-03-16 13:14:30 -0700248 /*
249 * Align the Y plane to 128 bytes so the chroma planes would be aligned
250 * to 64 byte boundaries. This is an Intel HW requirement.
251 */
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800252 if (format == DRM_FORMAT_YVU420 || format == DRM_FORMAT_YVU420_ANDROID) {
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700253 stride = ALIGN(stride, 128);
Gurchetan Singh507f5dd2017-03-16 13:14:30 -0700254 tiling_mode = I915_TILING_NONE;
255 }
256
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700257 ret = i915_align_dimensions(bo, tiling_mode, &stride, &height);
258 if (ret)
259 return ret;
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800260
Gurchetan Singh6423ecb2017-03-29 08:23:40 -0700261 drv_bo_from_format(bo, stride, height, format);
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800262
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800263 snprintf(name, sizeof(name), "i915-buffer-%u", i915_dev->count);
264 i915_dev->count++;
Stéphane Marchesin5d867a42014-11-24 17:09:49 -0800265
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800266 i915_bo = calloc(1, sizeof(*i915_bo));
267 if (!i915_bo)
268 return -ENOMEM;
269
270 bo->priv = i915_bo;
271
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800272 i915_bo->ibos[0] = drm_intel_bo_alloc(i915_dev->mgr, name, bo->total_size, 0);
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800273 if (!i915_bo->ibos[0]) {
274 fprintf(stderr, "drv: drm_intel_bo_alloc failed");
275 free(i915_bo);
276 bo->priv = NULL;
277 return -ENOMEM;
Ilja H. Friedelf9d2ab72015-04-09 14:08:36 -0700278 }
Gurchetan Singh83dc4fb2016-07-19 15:52:33 -0700279
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800280 for (plane = 0; plane < bo->num_planes; plane++) {
281 if (plane > 0)
282 drm_intel_bo_reference(i915_bo->ibos[0]);
Daniel Nicoara1de26dc2014-09-25 18:53:19 -0400283
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800284 bo->handles[plane].u32 = i915_bo->ibos[0]->handle;
285 i915_bo->ibos[plane] = i915_bo->ibos[0];
286 }
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700287
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800288 bo->tiling = tiling_mode;
289
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800290 ret = drm_intel_bo_set_tiling(i915_bo->ibos[0], &bo->tiling, bo->strides[0]);
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800291
292 if (ret || bo->tiling != tiling_mode) {
293 fprintf(stderr, "drv: drm_intel_gem_bo_set_tiling failed "
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800294 "errno=%x, stride=%x\n",
295 errno, bo->strides[0]);
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800296 /* Calls i915 bo destroy. */
297 bo->drv->backend->bo_destroy(bo);
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700298 return -errno;
299 }
300
301 return 0;
302}
303
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800304static int i915_bo_destroy(struct bo *bo)
305{
306 size_t plane;
307 struct i915_bo *i915_bo = bo->priv;
308
309 for (plane = 0; plane < bo->num_planes; plane++)
310 drm_intel_bo_unreference(i915_bo->ibos[plane]);
311
312 free(i915_bo);
313 bo->priv = NULL;
314
315 return 0;
316}
317
318static int i915_bo_import(struct bo *bo, struct drv_import_fd_data *data)
319{
320 size_t plane;
321 uint32_t swizzling;
322 struct i915_bo *i915_bo;
323 struct i915_device *i915_dev = bo->drv->priv;
324
325 i915_bo = calloc(1, sizeof(*i915_bo));
326 if (!i915_bo)
327 return -ENOMEM;
328
329 bo->priv = i915_bo;
330
331 /*
332 * When self-importing, libdrm_intel increments the reference count
333 * on the drm_intel_bo. It also returns the same drm_intel_bo per GEM
334 * handle. Thus, we don't need to increase the reference count
335 * (i.e, drv_increment_reference_count) when importing with this
336 * backend.
337 */
338 for (plane = 0; plane < bo->num_planes; plane++) {
339
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800340 i915_bo->ibos[plane] = drm_intel_bo_gem_create_from_prime(
341 i915_dev->mgr, data->fds[plane], data->sizes[plane]);
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800342
343 if (!i915_bo->ibos[plane]) {
344 /*
345 * Need to call GEM close on planes that were opened,
346 * if any. Adjust the num_planes variable to be the
347 * plane that failed, so GEM close will be called on
348 * planes before that plane.
349 */
350 bo->num_planes = plane;
351 i915_bo_destroy(bo);
352 fprintf(stderr, "drv: i915: failed to import failed");
353 return -EINVAL;
354 }
355
356 bo->handles[plane].u32 = i915_bo->ibos[plane]->handle;
357 }
358
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800359 if (drm_intel_bo_get_tiling(i915_bo->ibos[0], &bo->tiling, &swizzling)) {
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800360 fprintf(stderr, "drv: drm_intel_bo_get_tiling failed");
361 i915_bo_destroy(bo);
362 return -EINVAL;
363 }
364
365 return 0;
366}
367
Gurchetan Singh1a31e602016-10-06 10:58:00 -0700368static void *i915_bo_map(struct bo *bo, struct map_info *data, size_t plane)
Gurchetan Singhef920532016-08-12 16:38:25 -0700369{
370 int ret;
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800371 struct i915_bo *i915_bo = bo->priv;
Gurchetan Singhef920532016-08-12 16:38:25 -0700372
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800373 if (bo->tiling == I915_TILING_NONE)
374 /* TODO(gsingh): use bo_map flags to determine if we should
375 * enable writing.
376 */
377 ret = drm_intel_bo_map(i915_bo->ibos[0], 1);
378 else
379 ret = drm_intel_gem_bo_map_gtt(i915_bo->ibos[0]);
Gurchetan Singhef920532016-08-12 16:38:25 -0700380
Gurchetan Singhef920532016-08-12 16:38:25 -0700381 if (ret) {
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800382 fprintf(stderr, "drv: i915_bo_map failed.");
Gurchetan Singhef920532016-08-12 16:38:25 -0700383 return MAP_FAILED;
384 }
385
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800386 return i915_bo->ibos[0]->virtual;
387}
Gurchetan Singh1a31e602016-10-06 10:58:00 -0700388
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800389static int i915_bo_unmap(struct bo *bo, struct map_info *data)
390{
391 int ret;
392 struct i915_bo *i915_bo = bo->priv;
393
394 if (bo->tiling == I915_TILING_NONE)
395 ret = drm_intel_bo_unmap(i915_bo->ibos[0]);
396 else
397 ret = drm_intel_gem_bo_unmap_gtt(i915_bo->ibos[0]);
398
399 return ret;
Gurchetan Singhef920532016-08-12 16:38:25 -0700400}
401
Gurchetan Singhf3b22da2016-11-21 10:46:38 -0800402static uint32_t i915_resolve_format(uint32_t format)
Gurchetan Singhbfba8c22016-08-16 17:57:10 -0700403{
404 switch (format) {
Gurchetan Singhf3b22da2016-11-21 10:46:38 -0800405 case DRM_FORMAT_FLEX_IMPLEMENTATION_DEFINED:
Gurchetan Singhd6fb5772016-08-29 19:13:51 -0700406 /*HACK: See b/28671744 */
Gurchetan Singhf3b22da2016-11-21 10:46:38 -0800407 return DRM_FORMAT_XBGR8888;
408 case DRM_FORMAT_FLEX_YCbCr_420_888:
Gurchetan Singh03f13562017-02-08 15:21:14 -0800409 return DRM_FORMAT_YVU420_ANDROID;
Gurchetan Singhd6fb5772016-08-29 19:13:51 -0700410 default:
411 return format;
Gurchetan Singhbfba8c22016-08-16 17:57:10 -0700412 }
413}
414
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800415struct backend backend_i915 = {
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700416 .name = "i915",
Gurchetan Singhd7c84fd2016-08-16 18:18:24 -0700417 .init = i915_init,
418 .close = i915_close,
419 .bo_create = i915_bo_create,
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800420 .bo_destroy = i915_bo_destroy,
421 .bo_import = i915_bo_import,
Gurchetan Singhd7c84fd2016-08-16 18:18:24 -0700422 .bo_map = i915_bo_map,
Gurchetan Singh82a8eed2017-01-03 13:01:37 -0800423 .bo_unmap = i915_bo_unmap,
Gurchetan Singhbfba8c22016-08-16 17:57:10 -0700424 .resolve_format = i915_resolve_format,
Stéphane Marchesin25a26062014-09-12 16:18:59 -0700425};
426
427#endif