glamor: check driver support GEM or not
glamor calls DRM_IOCTL_GEM_FLINK to get a name for a buffer object. It only works for driver that support GEM, such as intel i915 driver. But for pvr driver who doesn't has GEM, we can't do it this way. According to Chris's comments, we check the has_gem as the following method: Here we just try to flink handle 0. If that fails with ENODEV or ENOTTY instead of ENOENT (or EINVAL on older kernels), set has_gem=0. Signed-off-by: Li Peng <peng.li@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
68789b23e7
commit
6fb92e67b3
|
@ -89,6 +89,7 @@ struct glamor_egl_screen_private {
|
|||
#ifdef GLAMOR_HAS_GBM
|
||||
struct gbm_device *gbm;
|
||||
#endif
|
||||
int has_gem;
|
||||
|
||||
PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr;
|
||||
PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr;
|
||||
|
@ -188,6 +189,19 @@ glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_egl_check_has_gem(int fd)
|
||||
{
|
||||
struct drm_gem_flink flink;
|
||||
flink.handle = 0;
|
||||
int err;
|
||||
|
||||
ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
|
||||
if (errno == ENOENT || err == EINVAL)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
||||
{
|
||||
|
@ -200,12 +214,16 @@ glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
|||
|
||||
glamor_egl = glamor_egl_get_screen_private(scrn);
|
||||
|
||||
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Couldn't flink pixmap handle\n");
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
|
||||
exit(1);
|
||||
}
|
||||
if (glamor_egl->has_gem) {
|
||||
if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Couldn't flink pixmap handle\n");
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_DRM_ONLY);
|
||||
exit(1);
|
||||
}
|
||||
} else
|
||||
name = handle;
|
||||
|
||||
image = _glamor_egl_create_image(glamor_egl,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
|
@ -312,6 +330,8 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
glamor_egl->display = eglGetDisplay((EGLNativeDisplayType)fd);
|
||||
#endif
|
||||
|
||||
glamor_egl->has_gem = glamor_egl_check_has_gem(fd);
|
||||
|
||||
#ifndef GLAMOR_GLES2
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue
Block a user