aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Figa2015-04-27 19:53:35 -0500
committerTomasz Figa2015-06-04 23:19:57 -0500
commita5c8b07b1dad94ca227c17ebecff50aa0e89d776 (patch)
tree1ab419bc5f926cf4543a4428126ffa2ac8325843 /rockchip
parentbd00c5c41dab43ab3bd2d7f505df0e8ea3b834e8 (diff)
downloadexternal-libdrm-a5c8b07b1dad94ca227c17ebecff50aa0e89d776.tar.gz
external-libdrm-a5c8b07b1dad94ca227c17ebecff50aa0e89d776.tar.xz
external-libdrm-a5c8b07b1dad94ca227c17ebecff50aa0e89d776.zip
rockchip: Add API to create BO object from existing handle
Certain use cases involve importing BO from Prime FD and obtaining a handle, which then needs to be imported into libdrm. Change-Id: Ibe28f719d1287e2cc5fb62523239635f8baac901 Signed-off-by: Tomasz Figa <tfiga@google.com>
Diffstat (limited to 'rockchip')
-rw-r--r--rockchip/rockchip_drm.c25
-rw-r--r--rockchip/rockchip_drmif.h2
2 files changed, 27 insertions, 0 deletions
diff --git a/rockchip/rockchip_drm.c b/rockchip/rockchip_drm.c
index d56a68b4..44a78be8 100644
--- a/rockchip/rockchip_drm.c
+++ b/rockchip/rockchip_drm.c
@@ -129,6 +129,31 @@ fail:
129 return NULL; 129 return NULL;
130} 130}
131 131
132struct rockchip_bo *rockchip_bo_from_handle(struct rockchip_device *dev,
133 uint32_t handle, uint32_t flags, uint32_t size)
134{
135 struct rockchip_bo *bo;
136
137 if (size == 0) {
138 fprintf(stderr, "invalid size.\n");
139 return NULL;
140 }
141
142 bo = calloc(1, sizeof(*bo));
143 if (!bo) {
144 fprintf(stderr, "failed to create bo[%s].\n",
145 strerror(errno));
146 return NULL;
147 }
148
149 bo->dev = dev;
150 bo->handle = handle;
151 bo->size = size;
152 bo->flags = flags;
153
154 return bo;
155}
156
132/* 157/*
133 * Destroy a rockchip buffer object. 158 * Destroy a rockchip buffer object.
134 * 159 *
diff --git a/rockchip/rockchip_drmif.h b/rockchip/rockchip_drmif.h
index bcc55539..5c549a05 100644
--- a/rockchip/rockchip_drmif.h
+++ b/rockchip/rockchip_drmif.h
@@ -73,5 +73,7 @@ struct rockchip_bo *rockchip_bo_from_name(struct rockchip_device *dev,
73 uint32_t name); 73 uint32_t name);
74int rockchip_bo_get_name(struct rockchip_bo *bo, uint32_t *name); 74int rockchip_bo_get_name(struct rockchip_bo *bo, uint32_t *name);
75uint32_t rockchip_bo_handle(struct rockchip_bo *bo); 75uint32_t rockchip_bo_handle(struct rockchip_bo *bo);
76struct rockchip_bo *rockchip_bo_from_handle(struct rockchip_device *dev,
77 uint32_t handle, uint32_t flags, uint32_t size);
76void *rockchip_bo_map(struct rockchip_bo *bo); 78void *rockchip_bo_map(struct rockchip_bo *bo);
77#endif /* ROCKCHIP_DRMIF_H_ */ 79#endif /* ROCKCHIP_DRMIF_H_ */