<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 4, 2017 at 8:43 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">v2: Make the error return be -1 instead of 0 because I think 0 is<br>
actually valid.<br>
<span class=""><br>
Cc: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>><br>
Signed-off-by: Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>><br>
</span><span class="">---<br>
src/gbm/backends/dri/gbm_dri.c | 28 ++++++++++++++++++++++++++++<br>
src/gbm/gbm-symbols-check | 1 +<br>
src/gbm/main/gbm.c | 18 ++++++++++++++++++<br>
src/gbm/main/gbm.h | 3 +++<br>
src/gbm/main/gbmint.h | 1 +<br>
5 files changed, 51 insertions(+)<br>
<br>
diff --git a/src/gbm/backends/dri/gbm_<wbr>dri.c b/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
</span>index c61d56b44a..f9c1afd8cb 100644<br>
<span class="">--- a/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
+++ b/src/gbm/backends/dri/gbm_<wbr>dri.c<br>
@@ -622,6 +622,33 @@ gbm_dri_bo_get_planes(struct gbm_bo *_bo)<br>
return get_number_planes(dri, bo->image);<br>
}<br>
<br>
+static union gbm_bo_handle<br>
+gbm_dri_bo_get_handle_for_<wbr>plane(struct gbm_bo *_bo, int plane)<br>
+{<br>
+ struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);<br>
+ struct gbm_dri_bo *bo = gbm_dri_bo(_bo);<br>
+ union gbm_bo_handle ret;<br>
</span>+ ret.s32 = -1;<br>
<div class="HOEnZb"><div class="h5">+<br>
+ if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar) {<br>
+ errno = ENOSYS;<br>
+ return ret;<br>
+ }<br>
+<br>
+ if (plane >= get_number_planes(dri, bo->image))<br></div></div></blockquote><div><br></div><div>Maybe set errno = EINVAL? Maybe silent failure is ok. Thoughts?<br><br></div><div>Otherwise, this seems sane.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
+ return ret;<br>
+<br>
+ __DRIimage *image = dri->image->fromPlanar(bo-><wbr>image, plane, NULL);<br>
+ if (!image) {<br>
+ /* Use the parent's handle */<br>
+ image = bo->image;<br>
+ }<br>
+<br>
+ dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_HANDLE, &ret.s32);<br>
+<br>
+ return ret;<br>
+}<br>
+<br>
static void<br>
gbm_dri_bo_destroy(struct gbm_bo *_bo)<br>
{<br>
@@ -1080,6 +1107,7 @@ dri_device_create(int fd)<br>
dri->base.base.bo_write = gbm_dri_bo_write;<br>
dri->base.base.bo_get_fd = gbm_dri_bo_get_fd;<br>
dri->base.base.bo_get_planes = gbm_dri_bo_get_planes;<br>
+ dri->base.base.bo_get_handle = gbm_dri_bo_get_handle_for_<wbr>plane;<br>
dri->base.base.bo_destroy = gbm_dri_bo_destroy;<br>
dri->base.base.destroy = dri_destroy;<br>
dri->base.base.surface_create = gbm_dri_surface_create;<br>
diff --git a/src/gbm/gbm-symbols-check b/src/gbm/gbm-symbols-check<br>
index 8c4da1b7ea..1e6dd4d3ec 100755<br>
--- a/src/gbm/gbm-symbols-check<br>
+++ b/src/gbm/gbm-symbols-check<br>
@@ -19,6 +19,7 @@ gbm_bo_get_device<br>
gbm_bo_get_handle<br>
gbm_bo_get_fd<br>
gbm_bo_get_plane_count<br>
+gbm_bo_get_handle_for_plane<br>
gbm_bo_write<br>
gbm_bo_set_user_data<br>
gbm_bo_get_user_data<br>
diff --git a/src/gbm/main/gbm.c b/src/gbm/main/gbm.c<br>
index 3779517564..066ceffc0a 100644<br>
--- a/src/gbm/main/gbm.c<br>
+++ b/src/gbm/main/gbm.c<br>
@@ -234,6 +234,24 @@ gbm_bo_get_plane_count(struct gbm_bo *bo)<br>
return bo->gbm->bo_get_planes(bo);<br>
}<br>
<br>
+/** Get the handle for the specified plane of the buffer object<br>
+ *<br>
+ * This function gets the handle for any plane associated with the BO. When<br>
+ * dealing with multi-planar formats, or formats which might have implicit<br>
+ * planes based on different underlying hardware it is necessary for the client<br>
+ * to be able to get this information to pass to the DRM.<br>
+ *<br>
+ * \param bo The buffer object<br>
+ * \param plane the plane to get a handle for<br>
+ *<br>
+ * \sa gbm_bo_get_handle()<br>
+ */<br>
+GBM_EXPORT union gbm_bo_handle<br>
+gbm_bo_get_handle_for_plane(<wbr>struct gbm_bo *bo, int plane)<br>
+{<br>
+ return bo->gbm->bo_get_handle(bo, plane);<br>
+}<br>
+<br>
/** Write data into the buffer object<br>
*<br>
* If the buffer object was created with the GBM_BO_USE_WRITE flag,<br>
diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h<br>
index 203a236357..67548206c4 100644<br>
--- a/src/gbm/main/gbm.h<br>
+++ b/src/gbm/main/gbm.h<br>
@@ -318,6 +318,9 @@ gbm_bo_get_fd(struct gbm_bo *bo);<br>
int<br>
gbm_bo_get_plane_count(struct gbm_bo *bo);<br>
<br>
+union gbm_bo_handle<br>
+gbm_bo_get_handle_for_plane(<wbr>struct gbm_bo *bo, int plane);<br>
+<br>
int<br>
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);<br>
<br>
diff --git a/src/gbm/main/gbmint.h b/src/gbm/main/gbmint.h<br>
index c6a6701464..0ec531d099 100644<br>
--- a/src/gbm/main/gbmint.h<br>
+++ b/src/gbm/main/gbmint.h<br>
@@ -77,6 +77,7 @@ struct gbm_device {<br>
int (*bo_write)(struct gbm_bo *bo, const void *buf, size_t data);<br>
int (*bo_get_fd)(struct gbm_bo *bo);<br>
int (*bo_get_planes)(struct gbm_bo *bo);<br>
+ union gbm_bo_handle (*bo_get_handle)(struct gbm_bo *bo, int plane);<br>
void (*bo_destroy)(struct gbm_bo *bo);<br>
<br>
struct gbm_surface *(*surface_create)(struct gbm_device *gbm,<br>
--<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>
</div></div></blockquote></div><br></div></div>