From f57d7f4b0b14972f92a83f155ae8033478aa7729 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 14 May 2009 16:58:14 -0700 Subject: libdrm/intel: Make get_pipe_from_crtc_id per-bufmgr. Return -1 on failure. The convention is that all APIs are per-bufmgr, so make this one the same. Then, have it return -1 on failure so that the application can know what's going on and do something sensible. Signed-off-by: Keith Packard --- libdrm/intel/intel_bufmgr.c | 9 +++++++++ libdrm/intel/intel_bufmgr_gem.c | 17 +++++++++-------- libdrm/intel/intel_bufmgr_priv.h | 13 +++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) (limited to 'libdrm') diff --git a/libdrm/intel/intel_bufmgr.c b/libdrm/intel/intel_bufmgr.c index 5057fe69..f170e7fc 100644 --- a/libdrm/intel/intel_bufmgr.c +++ b/libdrm/intel/intel_bufmgr.c @@ -219,3 +219,12 @@ int drm_intel_bo_disable_reuse(drm_intel_bo *bo) return bo->bufmgr->bo_disable_reuse(bo); return 0; } + +int +drm_intel_get_pipe_from_crtc_id (drm_intel_bufmgr *bufmgr, int crtc_id) +{ + if (bufmgr->get_pipe_from_crtc_id) + return bufmgr->get_pipe_from_crtc_id(bufmgr, crtc_id); + return -1; +} + diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index 3f792da1..61943f0d 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -815,8 +815,8 @@ drm_intel_gem_bo_subdata (drm_intel_bo *bo, unsigned long offset, return 0; } -int -drm_intel_get_pipe_from_crtc_id (drm_intel_bufmgr *bufmgr, int crtc_id) +static int +drm_intel_gem_get_pipe_from_crtc_id (drm_intel_bufmgr *bufmgr, int crtc_id) { drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bufmgr; struct drm_i915_get_pipe_from_crtc_id get_pipe_from_crtc_id; @@ -826,13 +826,13 @@ drm_intel_get_pipe_from_crtc_id (drm_intel_bufmgr *bufmgr, int crtc_id) ret = ioctl (bufmgr_gem->fd, DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID, &get_pipe_from_crtc_id); if (ret != 0) { - /* We're intentionally silent here so that there is no - * complaint when simply running with an older kernel that - * doesn't have the GET_PIPE_FROM_CRTC_ID ioctly. In that - * case, we just punt and try to sync on pipe 0, which is - * hopefully the right pipe in some cases at least. + /* We return -1 here to signal that we don't + * know which pipe is associated with this crtc. + * This lets the caller know that this information + * isn't available; using the wrong pipe for + * vblank waiting can cause the chipset to lock up */ - return 0; + return -1; } return get_pipe_from_crtc_id.pipe; @@ -1482,6 +1482,7 @@ drm_intel_bufmgr_gem_init(int fd, int batch_size) bufmgr_gem->bufmgr.debug = 0; bufmgr_gem->bufmgr.check_aperture_space = drm_intel_gem_check_aperture_space; bufmgr_gem->bufmgr.bo_disable_reuse = drm_intel_gem_bo_disable_reuse; + bufmgr_gem->bufmgr.get_pipe_from_crtc_id = drm_intel_gem_get_pipe_from_crtc_id; /* Initialize the linked lists for BO reuse cache. */ for (i = 0; i < DRM_INTEL_GEM_BO_BUCKETS; i++) DRMINITLISTHEAD(&bufmgr_gem->cache_bucket[i].head); diff --git a/libdrm/intel/intel_bufmgr_priv.h b/libdrm/intel/intel_bufmgr_priv.h index 3484dee8..0098076e 100644 --- a/libdrm/intel/intel_bufmgr_priv.h +++ b/libdrm/intel/intel_bufmgr_priv.h @@ -188,6 +188,19 @@ struct _drm_intel_bufmgr { */ int (*bo_disable_reuse)(drm_intel_bo *bo); + /** + * + * Return the pipe associated with a crtc_id so that vblank + * synchronization can use the correct data in the request. + * This is only supported for KMS and gem at this point, when + * unsupported, this function returns -1 and leaves the decision + * of what to do in that case to the caller + * + * \param bufmgr the associated buffer manager + * \param crtc_id the crtc identifier + */ + int (*get_pipe_from_crtc_id)(drm_intel_bufmgr *bufmgr, int crtc_id); + int debug; /**< Enables verbose debugging printouts */ }; -- cgit v1.2.3