intel: make bufmgr_gem shareable from different API
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Fri, 12 Sep 2014 12:48:36 +0000 (13:48 +0100)
committerDamien Lespiau <damien.lespiau@intel.com>
Mon, 15 Sep 2014 13:51:07 +0000 (14:51 +0100)
commit743af59669386cb6e063fa4bd85f0a0b2da86295
tree96ed2aa1b31ff80bb277b9d739728dbce721353d
parent63fc571863aa646834004fae2a8aee1326b775dc
intel: make bufmgr_gem shareable from different API

When using Mesa and LibVA in the same process, one would like to be
able bind buffers from the output of the decoder to a GL texture
through an EGLImage.

LibVA can reuse buffers allocated by Gbm through a file descriptor. It
will then wrap it into a drm_intel_bo with
drm_intel_bo_gem_create_from_prime().

The problem at the moment is that both library get a different
drm_intel_bufmgr object when they call drm_intel_bufmgr_gem_init()
even though they're using the same drm file descriptor. As a result,
instead of manipulating the same buffer object for a given file
descriptor, they get 2 different drm_intel_bo objects and 2 different
refcounts, leading one of the library to get errors from the kernel on
invalid BO when one of the 2 library is done with a shared buffer.

This patch modifies drm_intel_bufmgr_gem_init() so, given a file
descriptor, it will look for an already existing drm_intel_bufmgr
using the same file descriptor and return that object.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
intel/intel_bufmgr_gem.c