aboutsummaryrefslogtreecommitdiffstats
path: root/amdgpu/amdgpu_bo.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-04-22 14:52:34 +0200
committerAlex Deucher <alexander.deucher@amd.com>2015-08-05 13:47:49 -0400
commit6dc2eaf2cc8428d11498a57bbe72cdf0df4a3306 (patch)
tree2e46dc9744ab1890a1bca5019dcb5c4df120e95a /amdgpu/amdgpu_bo.c
parent9c2afffedb773da27fd7506b31fc2164f329d3a8 (diff)
downloadexternal_libdrm-6dc2eaf2cc8428d11498a57bbe72cdf0df4a3306.tar.gz
external_libdrm-6dc2eaf2cc8428d11498a57bbe72cdf0df4a3306.tar.bz2
external_libdrm-6dc2eaf2cc8428d11498a57bbe72cdf0df4a3306.zip
amdgpu: add public bo list interface v3
v2: cleanup comments and function parameter v3: rebased on internal branch Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'amdgpu/amdgpu_bo.c')
-rw-r--r--amdgpu/amdgpu_bo.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index b4ca7f72..9321f8b3 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -636,3 +636,59 @@ int amdgpu_create_bo_from_user_mem(amdgpu_device_handle dev,
return r;
}
+
+int amdgpu_bo_list_create(amdgpu_device_handle dev,
+ uint32_t number_of_resources,
+ amdgpu_bo_handle *resources,
+ uint8_t *resource_prios,
+ amdgpu_bo_list_handle *result)
+{
+ struct drm_amdgpu_bo_list_entry *list;
+ union drm_amdgpu_bo_list args;
+ unsigned i;
+ int r;
+
+ list = alloca(sizeof(struct drm_amdgpu_bo_list_entry) * number_of_resources);
+
+ memset(&args, 0, sizeof(args));
+ args.in.operation = AMDGPU_BO_LIST_OP_CREATE;
+ args.in.bo_number = number_of_resources;
+ args.in.bo_info_size = sizeof(struct drm_amdgpu_bo_list_entry);
+ args.in.bo_info_ptr = (uint64_t)(uintptr_t)list;
+
+ for (i = 0; i < number_of_resources; i++) {
+ list[i].bo_handle = resources[i]->handle;
+ if (resource_prios)
+ list[i].bo_priority = resource_prios[i];
+ else
+ list[i].bo_priority = 0;
+ }
+
+ r = drmCommandWriteRead(dev->fd, DRM_AMDGPU_BO_LIST,
+ &args, sizeof(args));
+ if (r)
+ return r;
+
+ *result = calloc(1, sizeof(struct amdgpu_bo_list));
+ (*result)->dev = dev;
+ (*result)->handle = args.out.list_handle;
+ return 0;
+}
+
+int amdgpu_bo_list_destroy(amdgpu_bo_list_handle list)
+{
+ union drm_amdgpu_bo_list args;
+ int r;
+
+ memset(&args, 0, sizeof(args));
+ args.in.operation = AMDGPU_BO_LIST_OP_DESTROY;
+ args.in.list_handle = list->handle;
+
+ r = drmCommandWriteRead(list->dev->fd, DRM_AMDGPU_BO_LIST,
+ &args, sizeof(args));
+
+ if (!r)
+ free(list);
+
+ return r;
+}