<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Jan 2, 2017 at 6:36 PM, Ben Widawsky <span dir="ltr"><<a href="mailto:ben@bwidawsk.net" target="_blank">ben@bwidawsk.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
Reviewed-by: Eric Engestrom <<a href="mailto:eric.engestrom@imgtec.com">eric.engestrom@imgtec.com</a>><br>
Acked-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
---<br>
 src/gbm/backends/dri/gbm_dri.c | 26 +++++++++++++++++++++++++-<br>
 src/gbm/gbm-symbols-check      |  1 +<br>
 src/gbm/main/gbm.c             | 15 ++++++++++++++-<br>
 src/gbm/main/gbm.h             |  3 +++<br>
 4 files changed, 43 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/gbm/backends/dri/gbm_<wbr>dri.c b/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
index 9b23299889..1b79682282 100644<br>
--- a/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
+++ b/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
@@ -652,7 +652,31 @@ gbm_dri_bo_get_handle_for_<wbr>plane(struct gbm_bo *_bo, int plane)<br>
 static uint32_t<br>
 gbm_dri_bo_get_stride(struct gbm_bo *_bo, int plane)<br>
 {<br>
-   return _bo->stride;<br>
+   struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);<br>
+   struct gbm_dri_bo *bo = gbm_dri_bo(_bo);<br>
+   __DRIimage *image;<br>
+   int stride = 0;<br>
+<br>
+   if (!dri->image || dri->image->base.version < 11 || !dri->image->fromPlanar) {<br>
+      errno = ENOSYS;<br>
+      return 0;<br>
+   }<br>
+<br>
+   if (bo->image == NULL)<br>
+      return _bo->stride;<br>
+<br>
+   if (plane >= get_number_planes(dri, bo->image))<br>
+      return 0;<br></blockquote><div><br></div><div>again, EINVAL?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+   image = dri->image->fromPlanar(bo-><wbr>image, plane, NULL);<br>
+   if (!image) {<br>
+      /* Use the parent stride */<br>
+      image = bo->image;<br>
+   }<br>
+<br>
+   dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_STRIDE, &stride);<br>
+<br>
+   return (uint32_t)stride;<br>
 }<br>
<br>
 static void<br>
diff --git a/src/gbm/gbm-symbols-check b/src/gbm/gbm-symbols-check<br>
index 1e6dd4d3ec..459006a63f 100755<br>
--- a/src/gbm/gbm-symbols-check<br>
+++ b/src/gbm/gbm-symbols-check<br>
@@ -14,6 +14,7 @@ gbm_bo_unmap<br>
 gbm_bo_get_width<br>
 gbm_bo_get_height<br>
 gbm_bo_get_stride<br>
+gbm_bo_get_stride_for_plane<br>
 gbm_bo_get_format<br>
 gbm_bo_get_device<br>
 gbm_bo_get_handle<br>
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c<br>
index 7462e90c4c..0a9f0bef7e 100644<br>
--- a/src/gbm/main/gbm.c<br>
+++ b/src/gbm/main/gbm.c<br>
@@ -165,7 +165,20 @@ gbm_bo_get_height(struct gbm_bo *bo)<br>
 GBM_EXPORT uint32_t<br>
 gbm_bo_get_stride(struct gbm_bo *bo)<br>
 {<br>
-   return bo->gbm->bo_get_stride(bo, 0);<br>
+   return gbm_bo_get_stride_for_plane(<wbr>bo, 0);<br>
+}<br>
+<br>
+/** Get the stride for the given plane<br>
+ *<br>
+ * \param bo The buffer object<br>
+ * \param plane for which you want the stride<br>
+ *<br>
+ * \sa gbm_bo_get_stride()<br>
+ */<br>
+GBM_EXPORT uint32_t<br>
+gbm_bo_get_stride_for_plane(<wbr>struct gbm_bo *bo, int plane)<br>
+{<br>
+   return bo->gbm->bo_get_stride(bo, plane);<br>
 }<br>
<br>
 /** Get the format of the buffer object<br>
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h<br>
index 67548206c4..1719c5312a 100644<br>
--- a/src/gbm/main/gbm.h<br>
+++ b/src/gbm/main/gbm.h<br>
@@ -304,6 +304,9 @@ uint32_t<br>
 gbm_bo_get_stride(struct gbm_bo *bo);<br>
<br>
 uint32_t<br>
+gbm_bo_get_stride_for_plane(<wbr>struct gbm_bo *bo, int plane);<br>
+<br>
+uint32_t<br>
 gbm_bo_get_format(struct gbm_bo *bo);<br>
<br>
 struct gbm_device *<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>