From afd245dd7fd85cf3ffd3e6d5fe9711252aa2ed7f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Wed, 29 Apr 2009 14:43:55 -0700 Subject: Add new drm_intel_get_pipe_from_crtc_id function. This wraps the new DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID ioctl, allowing applications to discover the pipe number corresponding to a given CRTC ID. This is necessary for doing pipe-specific operations such as waiting for vblank on a given CRTC. --- libdrm/intel/intel_bufmgr.h | 2 ++ libdrm/intel/intel_bufmgr_gem.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'libdrm') diff --git a/libdrm/intel/intel_bufmgr.h b/libdrm/intel/intel_bufmgr.h index 75d06cad..758558df 100644 --- a/libdrm/intel/intel_bufmgr.h +++ b/libdrm/intel/intel_bufmgr.h @@ -120,6 +120,8 @@ int drm_intel_gem_bo_map_gtt(drm_intel_bo *bo); int drm_intel_gem_bo_unmap_gtt(drm_intel_bo *bo); void drm_intel_gem_bo_start_gtt_access(drm_intel_bo *bo, int write_enable); +int drm_intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, int crtc_id); + /* drm_intel_bufmgr_fake.c */ drm_intel_bufmgr *drm_intel_bufmgr_fake_init(int fd, unsigned long low_offset, diff --git a/libdrm/intel/intel_bufmgr_gem.c b/libdrm/intel/intel_bufmgr_gem.c index 5ae4d668..3f792da1 100644 --- a/libdrm/intel/intel_bufmgr_gem.c +++ b/libdrm/intel/intel_bufmgr_gem.c @@ -815,6 +815,29 @@ 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) +{ + drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bufmgr; + struct drm_i915_get_pipe_from_crtc_id get_pipe_from_crtc_id; + int ret; + + get_pipe_from_crtc_id.crtc_id = 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. + */ + return 0; + } + + return get_pipe_from_crtc_id.pipe; +} + static int drm_intel_gem_bo_get_subdata (drm_intel_bo *bo, unsigned long offset, unsigned long size, void *data) -- cgit v1.2.3