return ret;
}
+static int
+gbm_dri_bo_get_plane_fd(struct gbm_bo *_bo, int plane)
+{
+ struct gbm_dri_device *dri = gbm_dri_device(_bo->gbm);
+ struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
+ int fd = -1;
+
+ if (!dri->image || dri->image->base.version < 13 || !dri->image->fromPlanar) {
+ /* Preserve legacy behavior if plane is 0 */
+ if (plane == 0)
+ return gbm_dri_bo_get_fd(_bo);
+
+ errno = ENOSYS;
+ return -1;
+ }
+
+ /* dumb BOs can only utilize non-planar formats */
+ if (!bo->image) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (plane >= get_number_planes(dri, bo->image)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ __DRIimage *image = dri->image->fromPlanar(bo->image, plane, NULL);
+ if (image) {
+ dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_FD, &fd);
+ dri->image->destroyImage(image);
+ } else {
+ assert(plane == 0);
+ dri->image->queryImage(bo->image, __DRI_IMAGE_ATTRIB_FD, &fd);
+ }
+
+ return fd;
+}
+
static uint32_t
gbm_dri_bo_get_stride(struct gbm_bo *_bo, int plane)
{
dri->base.bo_get_fd = gbm_dri_bo_get_fd;
dri->base.bo_get_planes = gbm_dri_bo_get_planes;
dri->base.bo_get_handle = gbm_dri_bo_get_handle_for_plane;
+ dri->base.bo_get_plane_fd = gbm_dri_bo_get_plane_fd;
dri->base.bo_get_stride = gbm_dri_bo_get_stride;
dri->base.bo_get_offset = gbm_dri_bo_get_offset;
dri->base.bo_get_modifier = gbm_dri_bo_get_modifier;
gbm_bo_get_bpp
gbm_bo_get_device
gbm_bo_get_fd
+gbm_bo_get_fd_for_plane
gbm_bo_get_format
gbm_bo_get_handle
gbm_bo_get_handle_for_plane
return bo->gbm->bo_get_handle(bo, plane);
}
+/** Get a DMA-BUF file descriptor for the specified plane of the buffer object
+ *
+ * This function creates a DMA-BUF (also known as PRIME) file descriptor
+ * handle for the specified plane of the buffer object. Each call to
+ * gbm_bo_get_fd_for_plane() returns a new file descriptor and the caller is
+ * responsible for closing the file descriptor.
+
+ * \param bo The buffer object
+ * \param plane The plane to get a DMA-BUF for
+ * \return Returns a file descriptor referring to the underlying buffer or -1
+ * if an error occurs.
+ *
+ * \sa gbm_bo_get_fd()
+ */
+GBM_EXPORT int
+gbm_bo_get_fd_for_plane(struct gbm_bo *bo, int plane)
+{
+ return bo->gbm->bo_get_plane_fd(bo, plane);
+}
+
/**
* Get the chosen modifier for the buffer object
*
gbm_bo_get_handle_for_plane(struct gbm_bo *bo, int plane);
int
+gbm_bo_get_fd_for_plane(struct gbm_bo *bo, int plane);
+
+int
gbm_bo_write(struct gbm_bo *bo, const void *buf, size_t count);
void
int (*bo_get_fd)(struct gbm_bo *bo);
int (*bo_get_planes)(struct gbm_bo *bo);
union gbm_bo_handle (*bo_get_handle)(struct gbm_bo *bo, int plane);
+ int (*bo_get_plane_fd)(struct gbm_bo *bo, int plane);
uint32_t (*bo_get_stride)(struct gbm_bo *bo, int plane);
uint32_t (*bo_get_offset)(struct gbm_bo *bo, int plane);
uint64_t (*bo_get_modifier)(struct gbm_bo *bo);