aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2009-04-29 17:43:54 -0400
committerEric Anholt <eric@anholt.net>2009-05-14 19:00:32 -0400
commit08d7b3d1edff84bd673d9e9ab36b5aa62e1ba903 (patch)
tree0dcbb40ceb39aafab750bb06e2cd165dd906f8d3
parent9d2949a4cdb77b9b5c243c79be6489d34d770c7c (diff)
drm/i915: Add new GET_PIPE_FROM_CRTC_ID ioctl.
This allows userlevel code 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. Failure to use the right pipe mapping can result in GPU hangs, or at least failure to actually sync to vblank. Signed-off-by: Carl Worth <cworth@cworth.org> [anholt: Style touchups from review] Signed-off-by: Eric Anholt <eric@anholt.net>
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c1
-rw-r--r--drivers/gpu/drm/i915/intel_display.c31
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h2
-rw-r--r--include/drm/i915_drm.h10
4 files changed, 44 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 3133f991968d..53d544552625 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1358,6 +1358,7 @@ struct drm_ioctl_desc i915_ioctls[] = {
1358 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0), 1358 DRM_IOCTL_DEF(DRM_I915_GEM_SET_TILING, i915_gem_set_tiling, 0),
1359 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0), 1359 DRM_IOCTL_DEF(DRM_I915_GEM_GET_TILING, i915_gem_get_tiling, 0),
1360 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0), 1360 DRM_IOCTL_DEF(DRM_I915_GEM_GET_APERTURE, i915_gem_get_aperture_ioctl, 0),
1361 DRM_IOCTL_DEF(DRM_I915_GET_PIPE_FROM_CRTC_ID, intel_get_pipe_from_crtc_id, 0),
1361}; 1362};
1362 1363
1363int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls); 1364int i915_max_ioctl = DRM_ARRAY_SIZE(i915_ioctls);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index bdcda36953b0..3387cf32f385 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1804,6 +1804,37 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
1804 } 1804 }
1805} 1805}
1806 1806
1807int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
1808 struct drm_file *file_priv)
1809{
1810 drm_i915_private_t *dev_priv = dev->dev_private;
1811 struct drm_i915_get_pipe_from_crtc_id *pipe_from_crtc_id = data;
1812 struct drm_crtc *crtc = NULL;
1813 int pipe = -1;
1814
1815 if (!dev_priv) {
1816 DRM_ERROR("called with no initialization\n");
1817 return -EINVAL;
1818 }
1819
1820 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
1821 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
1822 if (crtc->base.id == pipe_from_crtc_id->crtc_id) {
1823 pipe = intel_crtc->pipe;
1824 break;
1825 }
1826 }
1827
1828 if (pipe == -1) {
1829 DRM_ERROR("no such CRTC id\n");
1830 return -EINVAL;
1831 }
1832
1833 pipe_from_crtc_id->pipe = pipe;
1834
1835 return 0;
1836}
1837
1807struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe) 1838struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
1808{ 1839{
1809 struct drm_crtc *crtc = NULL; 1840 struct drm_crtc *crtc = NULL;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index cf2943028936..cd4b9c5f715e 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -125,6 +125,8 @@ extern struct drm_encoder *intel_best_encoder(struct drm_connector *connector);
125 125
126extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, 126extern struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
127 struct drm_crtc *crtc); 127 struct drm_crtc *crtc);
128int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
129 struct drm_file *file_priv);
128extern void intel_wait_for_vblank(struct drm_device *dev); 130extern void intel_wait_for_vblank(struct drm_device *dev);
129extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe); 131extern struct drm_crtc *intel_get_crtc_from_pipe(struct drm_device *dev, int pipe);
130extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output, 132extern struct drm_crtc *intel_get_load_detect_pipe(struct intel_output *intel_output,
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index 95962fa8398a..8e1e92583fbc 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -184,6 +184,7 @@ typedef struct _drm_i915_sarea {
184#define DRM_I915_GEM_GET_TILING 0x22 184#define DRM_I915_GEM_GET_TILING 0x22
185#define DRM_I915_GEM_GET_APERTURE 0x23 185#define DRM_I915_GEM_GET_APERTURE 0x23
186#define DRM_I915_GEM_MMAP_GTT 0x24 186#define DRM_I915_GEM_MMAP_GTT 0x24
187#define DRM_I915_GET_PIPE_FROM_CRTC_ID 0x25
187 188
188#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t) 189#define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
189#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH) 190#define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
@@ -219,6 +220,7 @@ typedef struct _drm_i915_sarea {
219#define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling) 220#define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
220#define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling) 221#define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
221#define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture) 222#define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
223#define DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_PIPE_FROM_CRTC_ID, struct drm_intel_get_pipe_from_crtc_id)
222 224
223/* Allow drivers to submit batchbuffers directly to hardware, relying 225/* Allow drivers to submit batchbuffers directly to hardware, relying
224 * on the security mechanisms provided by hardware. 226 * on the security mechanisms provided by hardware.
@@ -657,4 +659,12 @@ struct drm_i915_gem_get_aperture {
657 __u64 aper_available_size; 659 __u64 aper_available_size;
658}; 660};
659 661
662struct drm_i915_get_pipe_from_crtc_id {
663 /** ID of CRTC being requested **/
664 __u32 crtc_id;
665
666 /** pipe of requested CRTC **/
667 __u32 pipe;
668};
669
660#endif /* _I915_DRM_H_ */ 670#endif /* _I915_DRM_H_ */