blob: 7ff61a420327a0fa3686a5ab077ff594dce0b82f [file] [log] [blame]
Akshu Agrawal0337d9b2016-07-28 15:35:45 +05301/*
Daniele Castagna7a755de2016-12-16 17:32:30 -05002 * Copyright 2016 The Chromium OS Authors. All rights reserved.
Akshu Agrawal0337d9b2016-07-28 15:35:45 +05303 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6#ifdef DRV_AMDGPU
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -08007#include <amdgpu.h>
8#include <amdgpu_drm.h>
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +02009#include <assert.h>
10#include <drm_fourcc.h>
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053011#include <errno.h>
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +020012#include <fcntl.h>
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053013#include <stdio.h>
14#include <stdlib.h>
15#include <string.h>
Pratik Vishwakarmabc1b5352016-12-12 14:22:10 +053016#include <sys/mman.h>
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +020017#include <unistd.h>
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053018#include <xf86drm.h>
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +020019#include <xf86drmMode.h>
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053020
Satyajitcdcebd82018-01-12 14:49:05 +053021#include "dri.h"
Yiwei Zhangb7a64442021-09-30 05:13:10 +000022#include "drv_helpers.h"
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053023#include "drv_priv.h"
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053024#include "util.h"
25
Gurchetan Singhcf9ed9d2019-12-13 09:37:01 -080026// clang-format off
27#define DRI_PATH STRINGIZE(DRI_DRIVER_DIR/radeonsi_dri.so)
28// clang-format on
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053029
Satyajitcdcebd82018-01-12 14:49:05 +053030#define TILE_TYPE_LINEAR 0
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +020031/* We decide a modifier and then use DRI to manage allocation */
32#define TILE_TYPE_DRI_MODIFIER 1
Satyajitcdcebd82018-01-12 14:49:05 +053033/* DRI backend decides tiling in this case. */
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +020034#define TILE_TYPE_DRI 2
Akshu Agrawal0337d9b2016-07-28 15:35:45 +053035
Ikshwaku Chauhan047df2b2020-06-29 16:44:57 +053036/* Height alignement for Encoder/Decoder buffers */
37#define CHROME_HEIGHT_ALIGN 16
38
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +010039struct amdgpu_priv {
Satyajitcdcebd82018-01-12 14:49:05 +053040 struct dri_driver dri;
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +010041 int drm_version;
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +020042
43 /* sdma */
44 struct drm_amdgpu_info_device dev_info;
45 uint32_t sdma_ctx;
46 uint32_t sdma_cmdbuf_bo;
47 uint64_t sdma_cmdbuf_addr;
48 uint64_t sdma_cmdbuf_size;
49 uint32_t *sdma_cmdbuf_map;
50};
51
52struct amdgpu_linear_vma_priv {
53 uint32_t handle;
54 uint32_t map_flags;
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +010055};
56
Bas Nieuwenhuizenb16076b2020-06-29 12:41:18 +020057const static uint32_t render_target_formats[] = {
Gurchetan Singh45ca4492021-04-28 17:12:52 -070058 DRM_FORMAT_ABGR8888, DRM_FORMAT_ARGB8888, DRM_FORMAT_RGB565,
59 DRM_FORMAT_XBGR8888, DRM_FORMAT_XRGB8888, DRM_FORMAT_ABGR2101010,
60 DRM_FORMAT_ARGB2101010, DRM_FORMAT_XBGR2101010, DRM_FORMAT_XRGB2101010,
Lepton Wuc83116f2021-04-26 12:26:56 -070061 DRM_FORMAT_ABGR16161616F,
Bas Nieuwenhuizenb16076b2020-06-29 12:41:18 +020062};
Gurchetan Singh179687e2016-10-28 10:07:35 -070063
Bas Nieuwenhuizenb5e0f2d2020-09-29 16:02:18 +020064const static uint32_t texture_source_formats[] = {
65 DRM_FORMAT_GR88, DRM_FORMAT_R8, DRM_FORMAT_NV21, DRM_FORMAT_NV12,
66 DRM_FORMAT_YVU420_ANDROID, DRM_FORMAT_YVU420, DRM_FORMAT_P010
67};
Shirish Sdf423df2017-04-18 16:21:59 +053068
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +020069static int query_dev_info(int fd, struct drm_amdgpu_info_device *dev_info)
70{
71 struct drm_amdgpu_info info_args = { 0 };
72
73 info_args.return_pointer = (uintptr_t)dev_info;
74 info_args.return_size = sizeof(*dev_info);
75 info_args.query = AMDGPU_INFO_DEV_INFO;
76
77 return drmCommandWrite(fd, DRM_AMDGPU_INFO, &info_args, sizeof(info_args));
78}
79
80static int sdma_init(struct amdgpu_priv *priv, int fd)
81{
82 union drm_amdgpu_ctx ctx_args = { { 0 } };
83 union drm_amdgpu_gem_create gem_create = { { 0 } };
84 struct drm_amdgpu_gem_va va_args = { 0 };
85 union drm_amdgpu_gem_mmap gem_map = { { 0 } };
86 struct drm_gem_close gem_close = { 0 };
87 int ret;
88
89 /* Ensure we can make a submission without BO lists. */
90 if (priv->drm_version < 27)
91 return 0;
92
93 /* Anything outside this range needs adjustments to the SDMA copy commands */
94 if (priv->dev_info.family < AMDGPU_FAMILY_CI || priv->dev_info.family > AMDGPU_FAMILY_NV)
95 return 0;
96
97 ctx_args.in.op = AMDGPU_CTX_OP_ALLOC_CTX;
98
99 ret = drmCommandWriteRead(fd, DRM_AMDGPU_CTX, &ctx_args, sizeof(ctx_args));
100 if (ret < 0)
101 return ret;
102
103 priv->sdma_ctx = ctx_args.out.alloc.ctx_id;
104
105 priv->sdma_cmdbuf_size = ALIGN(4096, priv->dev_info.virtual_address_alignment);
106 gem_create.in.bo_size = priv->sdma_cmdbuf_size;
107 gem_create.in.alignment = 4096;
108 gem_create.in.domains = AMDGPU_GEM_DOMAIN_GTT;
109
110 ret = drmCommandWriteRead(fd, DRM_AMDGPU_GEM_CREATE, &gem_create, sizeof(gem_create));
111 if (ret < 0)
112 goto fail_ctx;
113
114 priv->sdma_cmdbuf_bo = gem_create.out.handle;
115
116 priv->sdma_cmdbuf_addr =
117 ALIGN(priv->dev_info.virtual_address_offset, priv->dev_info.virtual_address_alignment);
118
119 /* Map the buffer into the GPU address space so we can use it from the GPU */
120 va_args.handle = priv->sdma_cmdbuf_bo;
121 va_args.operation = AMDGPU_VA_OP_MAP;
122 va_args.flags = AMDGPU_VM_PAGE_READABLE | AMDGPU_VM_PAGE_EXECUTABLE;
123 va_args.va_address = priv->sdma_cmdbuf_addr;
124 va_args.offset_in_bo = 0;
125 va_args.map_size = priv->sdma_cmdbuf_size;
126
127 ret = drmCommandWrite(fd, DRM_AMDGPU_GEM_VA, &va_args, sizeof(va_args));
128 if (ret)
129 goto fail_bo;
130
131 gem_map.in.handle = priv->sdma_cmdbuf_bo;
132 ret = drmIoctl(fd, DRM_IOCTL_AMDGPU_GEM_MMAP, &gem_map);
133 if (ret)
134 goto fail_va;
135
136 priv->sdma_cmdbuf_map = mmap(0, priv->sdma_cmdbuf_size, PROT_READ | PROT_WRITE, MAP_SHARED,
137 fd, gem_map.out.addr_ptr);
138 if (priv->sdma_cmdbuf_map == MAP_FAILED) {
139 priv->sdma_cmdbuf_map = NULL;
140 ret = -ENOMEM;
141 goto fail_va;
142 }
143
144 return 0;
145fail_va:
146 va_args.operation = AMDGPU_VA_OP_UNMAP;
147 va_args.flags = 0;
148 drmCommandWrite(fd, DRM_AMDGPU_GEM_VA, &va_args, sizeof(va_args));
149fail_bo:
150 gem_close.handle = priv->sdma_cmdbuf_bo;
151 drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
152fail_ctx:
153 memset(&ctx_args, 0, sizeof(ctx_args));
154 ctx_args.in.op = AMDGPU_CTX_OP_FREE_CTX;
155 ctx_args.in.ctx_id = priv->sdma_ctx;
156 drmCommandWriteRead(fd, DRM_AMDGPU_CTX, &ctx_args, sizeof(ctx_args));
157 return ret;
158}
159
160static void sdma_finish(struct amdgpu_priv *priv, int fd)
161{
162 union drm_amdgpu_ctx ctx_args = { { 0 } };
163 struct drm_amdgpu_gem_va va_args = { 0 };
164 struct drm_gem_close gem_close = { 0 };
165
166 if (!priv->sdma_cmdbuf_map)
167 return;
168
169 va_args.handle = priv->sdma_cmdbuf_bo;
170 va_args.operation = AMDGPU_VA_OP_UNMAP;
171 va_args.flags = 0;
172 va_args.va_address = priv->sdma_cmdbuf_addr;
173 va_args.offset_in_bo = 0;
174 va_args.map_size = priv->sdma_cmdbuf_size;
175 drmCommandWrite(fd, DRM_AMDGPU_GEM_VA, &va_args, sizeof(va_args));
176
177 gem_close.handle = priv->sdma_cmdbuf_bo;
178 drmIoctl(fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
179
180 ctx_args.in.op = AMDGPU_CTX_OP_FREE_CTX;
181 ctx_args.in.ctx_id = priv->sdma_ctx;
182 drmCommandWriteRead(fd, DRM_AMDGPU_CTX, &ctx_args, sizeof(ctx_args));
183}
184
185static int sdma_copy(struct amdgpu_priv *priv, int fd, uint32_t src_handle, uint32_t dst_handle,
186 uint64_t size)
187{
188 const uint64_t max_size_per_cmd = 0x3fff00;
189 const uint32_t cmd_size = 7 * sizeof(uint32_t); /* 7 dwords, see loop below. */
190 const uint64_t max_commands = priv->sdma_cmdbuf_size / cmd_size;
191 uint64_t src_addr = priv->sdma_cmdbuf_addr + priv->sdma_cmdbuf_size;
192 uint64_t dst_addr = src_addr + size;
193 struct drm_amdgpu_gem_va va_args = { 0 };
194 unsigned cmd = 0;
195 uint64_t remaining_size = size;
196 uint64_t cur_src_addr = src_addr;
197 uint64_t cur_dst_addr = dst_addr;
198 struct drm_amdgpu_cs_chunk_ib ib = { 0 };
199 struct drm_amdgpu_cs_chunk chunks[2] = { { 0 } };
200 uint64_t chunk_ptrs[2];
201 union drm_amdgpu_cs cs = { { 0 } };
202 struct drm_amdgpu_bo_list_in bo_list = { 0 };
203 struct drm_amdgpu_bo_list_entry bo_list_entries[3] = { { 0 } };
204 union drm_amdgpu_wait_cs wait_cs = { { 0 } };
205 int ret = 0;
206
207 if (size > UINT64_MAX - max_size_per_cmd ||
208 DIV_ROUND_UP(size, max_size_per_cmd) > max_commands)
209 return -ENOMEM;
210
211 /* Map both buffers into the GPU address space so we can access them from the GPU. */
212 va_args.handle = src_handle;
213 va_args.operation = AMDGPU_VA_OP_MAP;
214 va_args.flags = AMDGPU_VM_PAGE_READABLE | AMDGPU_VM_DELAY_UPDATE;
215 va_args.va_address = src_addr;
216 va_args.map_size = size;
217
218 ret = drmCommandWrite(fd, DRM_AMDGPU_GEM_VA, &va_args, sizeof(va_args));
219 if (ret)
220 return ret;
221
222 va_args.handle = dst_handle;
223 va_args.flags = AMDGPU_VM_PAGE_READABLE | AMDGPU_VM_PAGE_WRITEABLE | AMDGPU_VM_DELAY_UPDATE;
224 va_args.va_address = dst_addr;
225
226 ret = drmCommandWrite(fd, DRM_AMDGPU_GEM_VA, &va_args, sizeof(va_args));
227 if (ret)
228 goto unmap_src;
229
230 while (remaining_size) {
231 uint64_t cur_size = remaining_size;
232 if (cur_size > max_size_per_cmd)
233 cur_size = max_size_per_cmd;
234
235 priv->sdma_cmdbuf_map[cmd++] = 0x01; /* linear copy */
236 priv->sdma_cmdbuf_map[cmd++] =
237 priv->dev_info.family >= AMDGPU_FAMILY_AI ? (cur_size - 1) : cur_size;
238 priv->sdma_cmdbuf_map[cmd++] = 0;
239 priv->sdma_cmdbuf_map[cmd++] = cur_src_addr;
240 priv->sdma_cmdbuf_map[cmd++] = cur_src_addr >> 32;
241 priv->sdma_cmdbuf_map[cmd++] = cur_dst_addr;
242 priv->sdma_cmdbuf_map[cmd++] = cur_dst_addr >> 32;
243
244 remaining_size -= cur_size;
245 cur_src_addr += cur_size;
246 cur_dst_addr += cur_size;
247 }
248
249 ib.va_start = priv->sdma_cmdbuf_addr;
250 ib.ib_bytes = cmd * 4;
251 ib.ip_type = AMDGPU_HW_IP_DMA;
252
253 chunks[1].chunk_id = AMDGPU_CHUNK_ID_IB;
254 chunks[1].length_dw = sizeof(ib) / 4;
255 chunks[1].chunk_data = (uintptr_t)&ib;
256
257 bo_list_entries[0].bo_handle = priv->sdma_cmdbuf_bo;
258 bo_list_entries[0].bo_priority = 8; /* Middle of range, like RADV. */
259 bo_list_entries[1].bo_handle = src_handle;
260 bo_list_entries[1].bo_priority = 8;
261 bo_list_entries[2].bo_handle = dst_handle;
262 bo_list_entries[2].bo_priority = 8;
263
264 bo_list.bo_number = 3;
265 bo_list.bo_info_size = sizeof(bo_list_entries[0]);
266 bo_list.bo_info_ptr = (uintptr_t)bo_list_entries;
267
268 chunks[0].chunk_id = AMDGPU_CHUNK_ID_BO_HANDLES;
269 chunks[0].length_dw = sizeof(bo_list) / 4;
270 chunks[0].chunk_data = (uintptr_t)&bo_list;
271
272 chunk_ptrs[0] = (uintptr_t)&chunks[0];
273 chunk_ptrs[1] = (uintptr_t)&chunks[1];
274
275 cs.in.ctx_id = priv->sdma_ctx;
276 cs.in.num_chunks = 2;
277 cs.in.chunks = (uintptr_t)chunk_ptrs;
278
279 ret = drmCommandWriteRead(fd, DRM_AMDGPU_CS, &cs, sizeof(cs));
280 if (ret) {
281 drv_log("SDMA copy command buffer submission failed %d\n", ret);
282 goto unmap_dst;
283 }
284
285 wait_cs.in.handle = cs.out.handle;
286 wait_cs.in.ip_type = AMDGPU_HW_IP_DMA;
287 wait_cs.in.ctx_id = priv->sdma_ctx;
288 wait_cs.in.timeout = INT64_MAX;
289
290 ret = drmCommandWriteRead(fd, DRM_AMDGPU_WAIT_CS, &wait_cs, sizeof(wait_cs));
291 if (ret) {
292 drv_log("Could not wait for CS to finish\n");
293 } else if (wait_cs.out.status) {
294 drv_log("Infinite wait timed out, likely GPU hang.\n");
295 ret = -ENODEV;
296 }
297
298unmap_dst:
299 va_args.handle = dst_handle;
300 va_args.operation = AMDGPU_VA_OP_UNMAP;
301 va_args.flags = AMDGPU_VM_DELAY_UPDATE;
302 va_args.va_address = dst_addr;
303 drmCommandWrite(fd, DRM_AMDGPU_GEM_VA, &va_args, sizeof(va_args));
304
305unmap_src:
306 va_args.handle = src_handle;
307 va_args.operation = AMDGPU_VA_OP_UNMAP;
308 va_args.flags = AMDGPU_VM_DELAY_UPDATE;
309 va_args.va_address = src_addr;
310 drmCommandWrite(fd, DRM_AMDGPU_GEM_VA, &va_args, sizeof(va_args));
311
312 return ret;
313}
314
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +0200315static bool is_modifier_scanout_capable(struct amdgpu_priv *priv, uint32_t format,
316 uint64_t modifier)
317{
318 unsigned bytes_per_pixel = drv_stride_from_format(format, 1, 0);
319
320 if (modifier == DRM_FORMAT_MOD_LINEAR)
321 return true;
322
323 if ((modifier >> 56) != DRM_FORMAT_MOD_VENDOR_AMD)
324 return false;
325
326 unsigned swizzle = AMD_FMT_MOD_GET(TILE, modifier);
327 if (priv->dev_info.family >= AMDGPU_FAMILY_RV) { /* DCN based GPUs */
328 /* D swizzle only supported for 64 bpp */
329 if ((swizzle & 3) == 2 && bytes_per_pixel != 8)
330 return false;
331
332 /* S swizzle not supported for 64 bpp */
333 if ((swizzle & 3) == 1 && bytes_per_pixel == 8)
334 return false;
335 } else { /* DCE based GPUs with GFX9 based modifier swizzling. */
336 assert(priv->dev_info.family == AMDGPU_FAMILY_AI);
337 /* Only D swizzles are allowed for display */
338 if ((swizzle & 3) != 2)
339 return false;
340 }
341
342 if (AMD_FMT_MOD_GET(DCC, modifier) &&
343 (AMD_FMT_MOD_GET(DCC_PIPE_ALIGN, modifier) || !AMD_FMT_MOD_GET(DCC_RETILE, modifier)))
344 return false;
345 return true;
346}
347
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530348static int amdgpu_init(struct driver *drv)
349{
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +0100350 struct amdgpu_priv *priv;
351 drmVersionPtr drm_version;
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800352 struct format_metadata metadata;
Gurchetan Singha1892b22017-09-28 16:40:52 -0700353 uint64_t use_flags = BO_USE_RENDER_MASK;
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530354
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +0100355 priv = calloc(1, sizeof(struct amdgpu_priv));
356 if (!priv)
Satyajitcdcebd82018-01-12 14:49:05 +0530357 return -ENOMEM;
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530358
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +0100359 drm_version = drmGetVersion(drv_get_fd(drv));
360 if (!drm_version) {
361 free(priv);
Satyajitcdcebd82018-01-12 14:49:05 +0530362 return -ENODEV;
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +0100363 }
364
365 priv->drm_version = drm_version->version_minor;
366 drmFreeVersion(drm_version);
367
Bas Nieuwenhuizen3cf8c922018-03-23 17:21:37 +0100368 drv->priv = priv;
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530369
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200370 if (query_dev_info(drv_get_fd(drv), &priv->dev_info)) {
371 free(priv);
372 drv->priv = NULL;
373 return -ENODEV;
374 }
Satyajitcdcebd82018-01-12 14:49:05 +0530375 if (dri_init(drv, DRI_PATH, "radeonsi")) {
376 free(priv);
377 drv->priv = NULL;
378 return -ENODEV;
379 }
Shirish Sdf423df2017-04-18 16:21:59 +0530380
Gurchetan Singhcadc54f2021-02-01 12:03:11 -0800381 /* Continue on failure, as we can still succesfully map things without SDMA. */
382 if (sdma_init(priv, drv_get_fd(drv)))
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200383 drv_log("SDMA init failed\n");
384
Satyajitcdcebd82018-01-12 14:49:05 +0530385 metadata.tiling = TILE_TYPE_LINEAR;
386 metadata.priority = 1;
Kristian H. Kristensenbc8c5932017-10-24 18:36:32 -0700387 metadata.modifier = DRM_FORMAT_MOD_LINEAR;
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800388
Gurchetan Singhd3001452017-11-03 17:18:36 -0700389 drv_add_combinations(drv, render_target_formats, ARRAY_SIZE(render_target_formats),
390 &metadata, use_flags);
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800391
Satyajitcdcebd82018-01-12 14:49:05 +0530392 drv_add_combinations(drv, texture_source_formats, ARRAY_SIZE(texture_source_formats),
393 &metadata, BO_USE_TEXTURE_MASK);
394
Hirokazu Honda3bd681c2020-06-23 17:52:20 +0900395 /* NV12 format for camera, display, decoding and encoding. */
396 drv_modify_combination(drv, DRM_FORMAT_NV12, &metadata,
397 BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_SCANOUT |
Gurchetan Singh45ca4492021-04-28 17:12:52 -0700398 BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER |
399 BO_USE_PROTECTED);
Hirokazu Honda3b8d4d02019-07-31 16:35:52 +0900400
Bas Nieuwenhuizenb5e0f2d2020-09-29 16:02:18 +0200401 drv_modify_combination(drv, DRM_FORMAT_P010, &metadata,
Ikshwaku Chauhan4b69e282021-01-28 23:56:12 +0530402 BO_USE_SCANOUT | BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER |
Gurchetan Singh45ca4492021-04-28 17:12:52 -0700403 BO_USE_PROTECTED);
Bas Nieuwenhuizenb5e0f2d2020-09-29 16:02:18 +0200404
Gurchetan Singh71bc6652018-09-17 17:42:05 -0700405 /* Android CTS tests require this. */
406 drv_add_combination(drv, DRM_FORMAT_BGR888, &metadata, BO_USE_SW_MASK);
407
Satyajitcdcebd82018-01-12 14:49:05 +0530408 /* Linear formats supported by display. */
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800409 drv_modify_combination(drv, DRM_FORMAT_ARGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
410 drv_modify_combination(drv, DRM_FORMAT_XRGB8888, &metadata, BO_USE_CURSOR | BO_USE_SCANOUT);
Drew Davenport5d215242019-03-25 09:18:42 -0600411 drv_modify_combination(drv, DRM_FORMAT_ABGR8888, &metadata, BO_USE_SCANOUT);
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800412 drv_modify_combination(drv, DRM_FORMAT_XBGR8888, &metadata, BO_USE_SCANOUT);
Yiwei Zhang1c2a0ef2021-09-02 22:59:29 +0000413 drv_modify_combination(drv, DRM_FORMAT_RGB565, &metadata, BO_USE_SCANOUT);
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800414
Bas Nieuwenhuizenb16076b2020-06-29 12:41:18 +0200415 drv_modify_combination(drv, DRM_FORMAT_ABGR2101010, &metadata, BO_USE_SCANOUT);
416 drv_modify_combination(drv, DRM_FORMAT_ARGB2101010, &metadata, BO_USE_SCANOUT);
417 drv_modify_combination(drv, DRM_FORMAT_XBGR2101010, &metadata, BO_USE_SCANOUT);
418 drv_modify_combination(drv, DRM_FORMAT_XRGB2101010, &metadata, BO_USE_SCANOUT);
419
Satyajitcdcebd82018-01-12 14:49:05 +0530420 drv_modify_combination(drv, DRM_FORMAT_NV21, &metadata, BO_USE_SCANOUT);
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800421
Satyajitcdcebd82018-01-12 14:49:05 +0530422 /*
423 * R8 format is used for Android's HAL_PIXEL_FORMAT_BLOB and is used for JPEG snapshots
David Stevens49518142020-06-15 13:48:48 +0900424 * from camera and input/output from hardware decoder/encoder.
Satyajitcdcebd82018-01-12 14:49:05 +0530425 */
426 drv_modify_combination(drv, DRM_FORMAT_R8, &metadata,
David Stevens49518142020-06-15 13:48:48 +0900427 BO_USE_CAMERA_READ | BO_USE_CAMERA_WRITE | BO_USE_HW_VIDEO_DECODER |
428 BO_USE_HW_VIDEO_ENCODER);
Satyajitcdcebd82018-01-12 14:49:05 +0530429
430 /*
431 * The following formats will be allocated by the DRI backend and may be potentially tiled.
432 * Since format modifier support hasn't been implemented fully yet, it's not
433 * possible to enumerate the different types of buffers (like i915 can).
434 */
435 use_flags &= ~BO_USE_RENDERSCRIPT;
Gurchetan Singha1892b22017-09-28 16:40:52 -0700436 use_flags &= ~BO_USE_SW_WRITE_OFTEN;
437 use_flags &= ~BO_USE_SW_READ_OFTEN;
Drew Davenportf1a7dfc2021-06-15 00:56:30 -0600438#if __ANDROID__
439 use_flags &= ~BO_USE_SW_WRITE_RARELY;
440 use_flags &= ~BO_USE_SW_READ_RARELY;
441#endif
Gurchetan Singha1892b22017-09-28 16:40:52 -0700442 use_flags &= ~BO_USE_LINEAR;
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800443
Satyajitcdcebd82018-01-12 14:49:05 +0530444 metadata.priority = 2;
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800445
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +0200446 for (unsigned f = 0; f < ARRAY_SIZE(render_target_formats); ++f) {
447 uint32_t format = render_target_formats[f];
448 int mod_cnt;
449 if (dri_query_modifiers(drv, format, 0, NULL, &mod_cnt) && mod_cnt) {
450 uint64_t *modifiers = calloc(mod_cnt, sizeof(uint64_t));
451 dri_query_modifiers(drv, format, mod_cnt, modifiers, &mod_cnt);
452 metadata.tiling = TILE_TYPE_DRI_MODIFIER;
453 for (int i = 0; i < mod_cnt; ++i) {
454 bool scanout =
455 is_modifier_scanout_capable(drv->priv, format, modifiers[i]);
Gurchetan Singh6b41fb52017-03-01 20:14:39 -0800456
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +0200457 /* LINEAR will be handled using the LINEAR metadata. */
458 if (modifiers[i] == DRM_FORMAT_MOD_LINEAR)
459 continue;
Bas Nieuwenhuizenb16076b2020-06-29 12:41:18 +0200460
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +0200461 /* The virtgpu minigbm can't handle auxiliary planes in the host. */
462 if (dri_num_planes_from_modifier(drv, format, modifiers[i]) !=
463 drv_num_planes_from_format(format))
464 continue;
465
466 metadata.modifier = modifiers[i];
467 drv_add_combination(drv, format, &metadata,
468 use_flags | (scanout ? BO_USE_SCANOUT : 0));
469 }
470 free(modifiers);
471 } else {
472 bool scanout = false;
473 switch (format) {
474 case DRM_FORMAT_ARGB8888:
475 case DRM_FORMAT_XRGB8888:
476 case DRM_FORMAT_ABGR8888:
477 case DRM_FORMAT_XBGR8888:
478 case DRM_FORMAT_ABGR2101010:
479 case DRM_FORMAT_ARGB2101010:
480 case DRM_FORMAT_XBGR2101010:
481 case DRM_FORMAT_XRGB2101010:
482 scanout = true;
483 break;
484 default:
485 break;
486 }
487 metadata.tiling = TILE_TYPE_DRI;
488 drv_add_combination(drv, format, &metadata,
489 use_flags | (scanout ? BO_USE_SCANOUT : 0));
490 }
491 }
Gurchetan Singhd3001452017-11-03 17:18:36 -0700492 return 0;
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530493}
494
495static void amdgpu_close(struct driver *drv)
496{
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200497 sdma_finish(drv->priv, drv_get_fd(drv));
Satyajitcdcebd82018-01-12 14:49:05 +0530498 dri_close(drv);
499 free(drv->priv);
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530500 drv->priv = NULL;
501}
502
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100503static int amdgpu_create_bo_linear(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
504 uint64_t use_flags)
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530505{
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530506 int ret;
Drew Davenport8db36fe2020-10-15 22:18:00 -0600507 size_t num_planes;
Satyajitcdcebd82018-01-12 14:49:05 +0530508 uint32_t plane, stride;
Gurchetan Singh99644382020-10-07 15:28:11 -0700509 union drm_amdgpu_gem_create gem_create = { { 0 } };
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200510 struct amdgpu_priv *priv = bo->drv->priv;
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530511
Satyajitcdcebd82018-01-12 14:49:05 +0530512 stride = drv_stride_from_format(format, width, 0);
Drew Davenport8db36fe2020-10-15 22:18:00 -0600513 num_planes = drv_num_planes_from_format(format);
514
515 /*
516 * For multiplane formats, align the stride to 512 to ensure that subsample strides are 256
517 * aligned. This uses more memory than necessary since the first plane only needs to be
518 * 256 aligned, but it's acceptable for a short-term fix. It's probably safe for other gpu
Drew Davenport49b804b2021-07-29 19:52:02 -0600519 * families, but let's restrict it to Raven and Stoney for now (b/171013552, b/190484589).
Jason Macnakdbc63f72022-06-23 18:34:55 -0700520 * This only applies to the Android YUV (multiplane) format.
Drew Davenport8db36fe2020-10-15 22:18:00 -0600521 * */
Jason Macnakdbc63f72022-06-23 18:34:55 -0700522 if (format == DRM_FORMAT_YVU420_ANDROID &&
523 (priv->dev_info.family == AMDGPU_FAMILY_RV || priv->dev_info.family == AMDGPU_FAMILY_CZ))
Drew Davenport8db36fe2020-10-15 22:18:00 -0600524 stride = ALIGN(stride, 512);
525 else
526 stride = ALIGN(stride, 256);
Satyajitcdcebd82018-01-12 14:49:05 +0530527
Ikshwaku Chauhan047df2b2020-06-29 16:44:57 +0530528 /*
Gurchetan Singh9b4c8b72020-08-20 14:25:43 -0700529 * Currently, allocator used by chrome aligns the height for Encoder/
530 * Decoder buffers while allocator used by android(gralloc/minigbm)
531 * doesn't provide any aligment.
532 *
533 * See b/153130069
534 */
Ikshwaku Chauhan047df2b2020-06-29 16:44:57 +0530535 if (use_flags & (BO_USE_HW_VIDEO_DECODER | BO_USE_HW_VIDEO_ENCODER))
536 height = ALIGN(height, CHROME_HEIGHT_ALIGN);
537
Satyajitcdcebd82018-01-12 14:49:05 +0530538 drv_bo_from_format(bo, stride, height, format);
Shirish Sdf423df2017-04-18 16:21:59 +0530539
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200540 gem_create.in.bo_size =
541 ALIGN(bo->meta.total_size, priv->dev_info.virtual_address_alignment);
Satyajitcdcebd82018-01-12 14:49:05 +0530542 gem_create.in.alignment = 256;
Dominik Behrfa17cdd2017-11-30 12:23:06 -0800543 gem_create.in.domain_flags = 0;
Satyajitcdcebd82018-01-12 14:49:05 +0530544
Gurchetan Singh71bc6652018-09-17 17:42:05 -0700545 if (use_flags & (BO_USE_LINEAR | BO_USE_SW_MASK))
Dominik Behrfa17cdd2017-11-30 12:23:06 -0800546 gem_create.in.domain_flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
547
Deepak Sharma62a9c4e2018-05-01 12:11:27 -0700548 gem_create.in.domains = AMDGPU_GEM_DOMAIN_GTT;
Bas Nieuwenhuizen4daf12c2020-06-04 23:11:27 +0200549
550 /* Scanout in GTT requires USWC, otherwise try to use cachable memory
551 * for buffers that are read often, because uncacheable reads can be
552 * very slow. USWC should be faster on the GPU though. */
553 if ((use_flags & BO_USE_SCANOUT) || !(use_flags & BO_USE_SW_READ_OFTEN))
Jao-ke Chin-Lee5481e3c2020-04-10 00:12:12 +0000554 gem_create.in.domain_flags |= AMDGPU_GEM_CREATE_CPU_GTT_USWC;
Dominik Behrfa17cdd2017-11-30 12:23:06 -0800555
Ikshwaku Chauhan4b69e282021-01-28 23:56:12 +0530556 /* For protected data Buffer needs to be allocated from TMZ */
557 if (use_flags & BO_USE_PROTECTED)
558 gem_create.in.domain_flags |= AMDGPU_GEM_CREATE_ENCRYPTED;
559
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530560 /* Allocate the buffer with the preferred heap. */
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -0800561 ret = drmCommandWriteRead(drv_get_fd(bo->drv), DRM_AMDGPU_GEM_CREATE, &gem_create,
562 sizeof(gem_create));
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530563 if (ret < 0)
564 return ret;
565
Gurchetan Singh298b7572019-09-19 09:55:18 -0700566 for (plane = 0; plane < bo->meta.num_planes; plane++)
Shirish Sdf423df2017-04-18 16:21:59 +0530567 bo->handles[plane].u32 = gem_create.out.handle;
568
Gurchetan Singh52155b42021-01-27 17:55:17 -0800569 bo->meta.format_modifier = DRM_FORMAT_MOD_LINEAR;
Bas Nieuwenhuizen7119d332020-02-07 20:20:30 +0100570
Satyajitcdcebd82018-01-12 14:49:05 +0530571 return 0;
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530572}
573
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100574static int amdgpu_create_bo(struct bo *bo, uint32_t width, uint32_t height, uint32_t format,
575 uint64_t use_flags)
Satyajitcdcebd82018-01-12 14:49:05 +0530576{
577 struct combination *combo;
Drew Davenport8ed9b312021-05-06 17:08:27 -0600578 struct amdgpu_priv *priv = bo->drv->priv;
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100579
580 combo = drv_get_combination(bo->drv, format, use_flags);
Satyajitcdcebd82018-01-12 14:49:05 +0530581 if (!combo)
582 return -EINVAL;
583
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100584 if (combo->metadata.tiling == TILE_TYPE_DRI) {
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100585 // See b/122049612
Drew Davenport5ebd19f2021-06-09 00:17:05 -0600586 if (use_flags & (BO_USE_SCANOUT) && priv->dev_info.family == AMDGPU_FAMILY_CZ) {
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100587 uint32_t bytes_per_pixel = drv_bytes_per_pixel_from_format(format, 0);
588 width = ALIGN(width, 256 / bytes_per_pixel);
589 }
590
591 return dri_bo_create(bo, width, height, format, use_flags);
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +0200592 } else if (combo->metadata.tiling == TILE_TYPE_DRI_MODIFIER) {
593 return dri_bo_create_with_modifiers(bo, width, height, format,
594 &combo->metadata.modifier, 1);
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100595 }
596
597 return amdgpu_create_bo_linear(bo, width, height, format, use_flags);
598}
599
600static int amdgpu_create_bo_with_modifiers(struct bo *bo, uint32_t width, uint32_t height,
601 uint32_t format, const uint64_t *modifiers,
602 uint32_t count)
603{
604 bool only_use_linear = true;
605
606 for (uint32_t i = 0; i < count; ++i)
607 if (modifiers[i] != DRM_FORMAT_MOD_LINEAR)
608 only_use_linear = false;
609
610 if (only_use_linear)
611 return amdgpu_create_bo_linear(bo, width, height, format, BO_USE_SCANOUT);
612
613 return dri_bo_create_with_modifiers(bo, width, height, format, modifiers, count);
614}
615
616static int amdgpu_import_bo(struct bo *bo, struct drv_import_fd_data *data)
617{
Gurchetan Singh52155b42021-01-27 17:55:17 -0800618 bool dri_tiling = data->format_modifier != DRM_FORMAT_MOD_LINEAR;
619 if (data->format_modifier == DRM_FORMAT_MOD_INVALID) {
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100620 struct combination *combo;
621 combo = drv_get_combination(bo->drv, data->format, data->use_flags);
622 if (!combo)
623 return -EINVAL;
624
Bas Nieuwenhuizen4c0371b2021-08-10 03:37:00 +0200625 dri_tiling = combo->metadata.tiling != TILE_TYPE_LINEAR;
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100626 }
627
Robert Mader1a733372022-03-29 12:05:01 +0200628 bo->meta.num_planes = dri_num_planes_from_modifier(bo->drv, data->format,
629 data->format_modifier);
630
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100631 if (dri_tiling)
Satyajitcdcebd82018-01-12 14:49:05 +0530632 return dri_bo_import(bo, data);
633 else
634 return drv_prime_bo_import(bo, data);
635}
636
Bas Nieuwenhuizen136d9222021-11-10 14:04:21 +0100637static int amdgpu_release_bo(struct bo *bo)
638{
639 if (bo->priv)
640 return dri_bo_release(bo);
641
642 return 0;
643}
644
Satyajitcdcebd82018-01-12 14:49:05 +0530645static int amdgpu_destroy_bo(struct bo *bo)
646{
647 if (bo->priv)
648 return dri_bo_destroy(bo);
649 else
650 return drv_gem_bo_destroy(bo);
651}
652
653static void *amdgpu_map_bo(struct bo *bo, struct vma *vma, size_t plane, uint32_t map_flags)
Pratik Vishwakarmabc1b5352016-12-12 14:22:10 +0530654{
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200655 void *addr = MAP_FAILED;
Pratik Vishwakarmabc1b5352016-12-12 14:22:10 +0530656 int ret;
Gurchetan Singh99644382020-10-07 15:28:11 -0700657 union drm_amdgpu_gem_mmap gem_map = { { 0 } };
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200658 struct drm_amdgpu_gem_create_in bo_info = { 0 };
659 struct drm_amdgpu_gem_op gem_op = { 0 };
660 uint32_t handle = bo->handles[plane].u32;
661 struct amdgpu_linear_vma_priv *priv = NULL;
662 struct amdgpu_priv *drv_priv;
Pratik Vishwakarmabc1b5352016-12-12 14:22:10 +0530663
Satyajitcdcebd82018-01-12 14:49:05 +0530664 if (bo->priv)
665 return dri_bo_map(bo, vma, plane, map_flags);
666
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200667 drv_priv = bo->drv->priv;
668 gem_op.handle = handle;
669 gem_op.op = AMDGPU_GEM_OP_GET_GEM_CREATE_INFO;
670 gem_op.value = (uintptr_t)&bo_info;
671
672 ret = drmCommandWriteRead(bo->drv->fd, DRM_AMDGPU_GEM_OP, &gem_op, sizeof(gem_op));
673 if (ret)
674 return MAP_FAILED;
675
676 vma->length = bo_info.bo_size;
677
678 if (((bo_info.domains & AMDGPU_GEM_DOMAIN_VRAM) ||
679 (bo_info.domain_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC)) &&
680 drv_priv->sdma_cmdbuf_map) {
681 union drm_amdgpu_gem_create gem_create = { { 0 } };
682
683 priv = calloc(1, sizeof(struct amdgpu_linear_vma_priv));
684 if (!priv)
685 return MAP_FAILED;
686
687 gem_create.in.bo_size = bo_info.bo_size;
688 gem_create.in.alignment = 4096;
689 gem_create.in.domains = AMDGPU_GEM_DOMAIN_GTT;
690
691 ret = drmCommandWriteRead(bo->drv->fd, DRM_AMDGPU_GEM_CREATE, &gem_create,
692 sizeof(gem_create));
693 if (ret < 0) {
694 drv_log("GEM create failed\n");
695 free(priv);
696 return MAP_FAILED;
697 }
698
699 priv->map_flags = map_flags;
700 handle = priv->handle = gem_create.out.handle;
701
702 ret = sdma_copy(bo->drv->priv, bo->drv->fd, bo->handles[0].u32, priv->handle,
703 bo_info.bo_size);
704 if (ret) {
705 drv_log("SDMA copy for read failed\n");
706 goto fail;
707 }
708 }
709
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200710 gem_map.in.handle = handle;
Pratik Vishwakarmabc1b5352016-12-12 14:22:10 +0530711 ret = drmIoctl(bo->drv->fd, DRM_IOCTL_AMDGPU_GEM_MMAP, &gem_map);
712 if (ret) {
Alistair Strachan0cfaaa52018-03-19 14:03:23 -0700713 drv_log("DRM_IOCTL_AMDGPU_GEM_MMAP failed\n");
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200714 goto fail;
Pratik Vishwakarmabc1b5352016-12-12 14:22:10 +0530715 }
Gurchetan Singhcfb88762017-09-28 17:14:50 -0700716
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200717 addr = mmap(0, bo->meta.total_size, drv_get_prot(map_flags), MAP_SHARED, bo->drv->fd,
Gurchetan Singhcfb88762017-09-28 17:14:50 -0700718 gem_map.out.addr_ptr);
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200719 if (addr == MAP_FAILED)
720 goto fail;
721
722 vma->priv = priv;
723 return addr;
724
725fail:
726 if (priv) {
727 struct drm_gem_close gem_close = { 0 };
728 gem_close.handle = priv->handle;
729 drmIoctl(bo->drv->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
730 free(priv);
731 }
732 return MAP_FAILED;
Pratik Vishwakarmabc1b5352016-12-12 14:22:10 +0530733}
734
Satyajitcdcebd82018-01-12 14:49:05 +0530735static int amdgpu_unmap_bo(struct bo *bo, struct vma *vma)
736{
Gurchetan Singhcadc54f2021-02-01 12:03:11 -0800737 if (bo->priv) {
Satyajitcdcebd82018-01-12 14:49:05 +0530738 return dri_bo_unmap(bo, vma);
Gurchetan Singhcadc54f2021-02-01 12:03:11 -0800739 } else {
Bas Nieuwenhuizen4a3f98c2020-06-20 03:50:34 +0200740 int r = munmap(vma->addr, vma->length);
741 if (r)
742 return r;
743
744 if (vma->priv) {
745 struct amdgpu_linear_vma_priv *priv = vma->priv;
746 struct drm_gem_close gem_close = { 0 };
747
748 if (BO_MAP_WRITE & priv->map_flags) {
749 r = sdma_copy(bo->drv->priv, bo->drv->fd, priv->handle,
750 bo->handles[0].u32, vma->length);
751 if (r)
752 return r;
753 }
754
755 gem_close.handle = priv->handle;
756 r = drmIoctl(bo->drv->fd, DRM_IOCTL_GEM_CLOSE, &gem_close);
757 }
758
759 return 0;
760 }
Satyajitcdcebd82018-01-12 14:49:05 +0530761}
762
Deepak Sharmaff66c802018-11-16 12:10:54 -0800763static int amdgpu_bo_invalidate(struct bo *bo, struct mapping *mapping)
764{
765 int ret;
Gurchetan Singh99644382020-10-07 15:28:11 -0700766 union drm_amdgpu_gem_wait_idle wait_idle = { { 0 } };
Deepak Sharmaff66c802018-11-16 12:10:54 -0800767
768 if (bo->priv)
769 return 0;
770
Deepak Sharmaff66c802018-11-16 12:10:54 -0800771 wait_idle.in.handle = bo->handles[0].u32;
772 wait_idle.in.timeout = AMDGPU_TIMEOUT_INFINITE;
773
774 ret = drmCommandWriteRead(bo->drv->fd, DRM_AMDGPU_GEM_WAIT_IDLE, &wait_idle,
775 sizeof(wait_idle));
776
777 if (ret < 0) {
778 drv_log("DRM_AMDGPU_GEM_WAIT_IDLE failed with %d\n", ret);
779 return ret;
780 }
781
782 if (ret == 0 && wait_idle.out.status)
783 drv_log("DRM_AMDGPU_GEM_WAIT_IDLE BO is busy\n");
784
785 return 0;
786}
787
Gurchetan Singh3e9d3832017-10-31 10:36:25 -0700788const struct backend backend_amdgpu = {
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530789 .name = "amdgpu",
790 .init = amdgpu_init,
791 .close = amdgpu_close,
Satyajitcdcebd82018-01-12 14:49:05 +0530792 .bo_create = amdgpu_create_bo,
ChromeOS Developer9b367b32020-03-02 13:08:53 +0100793 .bo_create_with_modifiers = amdgpu_create_bo_with_modifiers,
Bas Nieuwenhuizen136d9222021-11-10 14:04:21 +0100794 .bo_release = amdgpu_release_bo,
Satyajitcdcebd82018-01-12 14:49:05 +0530795 .bo_destroy = amdgpu_destroy_bo,
796 .bo_import = amdgpu_import_bo,
797 .bo_map = amdgpu_map_bo,
798 .bo_unmap = amdgpu_unmap_bo,
Deepak Sharmaff66c802018-11-16 12:10:54 -0800799 .bo_invalidate = amdgpu_bo_invalidate,
Yiwei Zhangb8ad7b82021-10-01 17:55:14 +0000800 .resolve_format_and_use_flags = drv_resolve_format_and_use_flags_helper,
ChromeOS Developer44588bb2020-03-02 16:32:09 +0100801 .num_planes_from_modifier = dri_num_planes_from_modifier,
Akshu Agrawal0337d9b2016-07-28 15:35:45 +0530802};
803
804#endif