summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/xa/xa_tracker.c
diff options
context:
space:
mode:
authorRob Clark <robclark@freedesktop.org>2015-09-02 23:13:33 -0700
committerThomas Hellstrom <thellstrom@vmware.com>2015-09-07 01:25:08 -0700
commit1432a182414352e853bfdad997591598e621fd73 (patch)
treea619a9cd193f98f23385bc15b4caedb56338ccf3 /src/gallium/state_trackers/xa/xa_tracker.c
parent00c568f679413ee627421d5724beb85be3da55c1 (diff)
downloadexternal_mesa3d-1432a182414352e853bfdad997591598e621fd73.zip
external_mesa3d-1432a182414352e853bfdad997591598e621fd73.tar.gz
external_mesa3d-1432a182414352e853bfdad997591598e621fd73.tar.bz2
xa: add xa_surface_from_handle2 v2
Like xa_surface_from_handle(), but takes a handle type, rather than hard-coding 'shared' handle. This is needed to fix bugs seen with xf86-video-freedreno with xrandr rotation, for example. The root issue is that doing a GEM_OPEN ioctl on a bo that already has a GEM handle associated with the drm_file will result in two unique handles for the same bo. Which causes all sorts of follow-on fail. v2: - Add support for for fd handles. - Avoid duplicating code. - Bump xa version minor. Signed-off-by: Rob Clark <robclark@freedesktop.org> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Diffstat (limited to 'src/gallium/state_trackers/xa/xa_tracker.c')
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index 21ca57c..2944b16 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -298,6 +298,20 @@ xa_format_check_supported(struct xa_tracker *xa,
return XA_ERR_NONE;
}
+static unsigned
+handle_type(enum xa_handle_type type)
+{
+ switch (type) {
+ case xa_handle_type_kms:
+ return DRM_API_HANDLE_TYPE_KMS;
+ case xa_handle_type_fd:
+ return DRM_API_HANDLE_TYPE_FD;
+ case xa_handle_type_shared:
+ default:
+ return DRM_API_HANDLE_TYPE_SHARED;
+ }
+}
+
static struct xa_surface *
surface_create(struct xa_tracker *xa,
int width,
@@ -380,9 +394,24 @@ xa_surface_from_handle(struct xa_tracker *xa,
enum xa_formats xa_format, unsigned int flags,
uint32_t handle, uint32_t stride)
{
+ return xa_surface_from_handle2(xa, width, height, depth, stype, xa_format,
+ DRM_API_HANDLE_TYPE_SHARED, flags, handle,
+ stride);
+}
+
+XA_EXPORT struct xa_surface *
+xa_surface_from_handle2(struct xa_tracker *xa,
+ int width,
+ int height,
+ int depth,
+ enum xa_surface_type stype,
+ enum xa_formats xa_format, unsigned int flags,
+ enum xa_handle_type type,
+ uint32_t handle, uint32_t stride)
+{
struct winsys_handle whandle;
memset(&whandle, 0, sizeof(whandle));
- whandle.type = DRM_API_HANDLE_TYPE_SHARED;
+ whandle.type = handle_type(type);
whandle.handle = handle;
whandle.stride = stride;
return surface_create(xa, width, height, depth, stype, xa_format, flags, &whandle);
@@ -511,15 +540,7 @@ xa_surface_handle(struct xa_surface *srf,
boolean res;
memset(&whandle, 0, sizeof(whandle));
- switch (type) {
- case xa_handle_type_kms:
- whandle.type = DRM_API_HANDLE_TYPE_KMS;
- break;
- case xa_handle_type_shared:
- default:
- whandle.type = DRM_API_HANDLE_TYPE_SHARED;
- break;
- }
+ whandle.type = handle_type(type);
res = screen->resource_get_handle(screen, srf->tex, &whandle);
if (!res)
return -XA_ERR_INVAL;