[PATCH 09/11] etnaviv: fill in modifier in etna_resource_get_handle

Lucas Stach l.stach at pengutronix.de
Fri Jun 23 15:50:26 UTC 2017


This allows the state trackers to know the tiling layout of the
resource and pass this through the various userspace protocols.

Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
---
 src/gallium/drivers/etnaviv/etnaviv_resource.c | 30 +++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index 66d96aacbbe7..df5a5700bc19 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -464,6 +464,24 @@ fail:
    return NULL;
 }
 
+static uint64_t layout_to_modifier(unsigned int layout)
+{
+   switch (layout) {
+   case ETNA_LAYOUT_TILED:
+      return DRM_FORMAT_MOD_VIVANTE_TILED;
+   case ETNA_LAYOUT_SUPER_TILED:
+      return DRM_FORMAT_MOD_VIVANTE_SUPER_TILED;
+   case ETNA_LAYOUT_MULTI_TILED:
+      return DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED;
+   case ETNA_LAYOUT_MULTI_SUPERTILED:
+      return DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED;
+   case ETNA_LAYOUT_LINEAR:
+      return DRM_FORMAT_MOD_LINEAR;
+   default:
+      return DRM_FORMAT_MOD_INVALID;
+   }
+}
+
 static boolean
 etna_resource_get_handle(struct pipe_screen *pscreen,
                          struct pipe_context *pctx,
@@ -472,10 +490,20 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
 {
    struct etna_resource *rsc = etna_resource(prsc);
    handle->stride = rsc->levels[0].stride;
+   handle->modifier = layout_to_modifier(rsc->layout);
 
    if (handle->type == DRM_API_HANDLE_TYPE_KMS &&
-       renderonly_get_handle(rsc->scanout, handle))
+       renderonly_get_handle(rsc->scanout, handle)) {
+      /*
+       * If we export the renderonly handle and the scanout BO is attached as
+       * an external resource we need to fill in the modifier from the external
+       * resource.
+       */
+      if (rsc->external)
+         handle->modifier = layout_to_modifier(etna_resource(rsc->external)->layout);
+
       return TRUE;
+   }
 
    if (handle->type == DRM_API_HANDLE_TYPE_SHARED) {
       return etna_bo_get_name(rsc->bo, &handle->handle) == 0;
-- 
2.11.0



More information about the etnaviv mailing list