aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/i915_irq.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2006-06-24 03:07:34 -0400
committerDave Airlie <airlied@linux.ie>2006-06-24 03:32:58 -0400
commit702880f24373dfb31edb0bcd997ff924d07decc3 (patch)
treece78f61ee3b9b71d97bed31437af84c5fa0682da /drivers/char/drm/i915_irq.c
parentd6fece051a4ef330922bfafb9d64e3e133e3a8a6 (diff)
Add i915 ioctls to configure pipes for vblank interrupt.
i915 vblanks can be generated from either pipe a or b, however a disabled pipe generates no interrupts. This change allows the X server to select which pipe generates vblank interrupts. From: Keith Packard <keith.packard@intel.com> via DRM CVS Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/i915_irq.c')
-rw-r--r--drivers/char/drm/i915_irq.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index a752afd86ab8..cd96cfa430db 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -44,7 +44,8 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
44 u16 temp; 44 u16 temp;
45 45
46 temp = I915_READ16(I915REG_INT_IDENTITY_R); 46 temp = I915_READ16(I915REG_INT_IDENTITY_R);
47 temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG); 47
48 temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG);
48 49
49 DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp); 50 DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp);
50 51
@@ -58,7 +59,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
58 if (temp & USER_INT_FLAG) 59 if (temp & USER_INT_FLAG)
59 DRM_WAKEUP(&dev_priv->irq_queue); 60 DRM_WAKEUP(&dev_priv->irq_queue);
60 61
61 if (temp & VSYNC_PIPEA_FLAG) { 62 if (temp & (VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG)) {
62 atomic_inc(&dev->vbl_received); 63 atomic_inc(&dev->vbl_received);
63 DRM_WAKEUP(&dev->vbl_queue); 64 DRM_WAKEUP(&dev->vbl_queue);
64 drm_vbl_send_signals(dev); 65 drm_vbl_send_signals(dev);
@@ -182,6 +183,68 @@ int i915_irq_wait(DRM_IOCTL_ARGS)
182 return i915_wait_irq(dev, irqwait.irq_seq); 183 return i915_wait_irq(dev, irqwait.irq_seq);
183} 184}
184 185
186static int i915_enable_interrupt (drm_device_t *dev)
187{
188 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
189 u16 flag;
190
191 flag = 0;
192 if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A)
193 flag |= VSYNC_PIPEA_FLAG;
194 if (dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B)
195 flag |= VSYNC_PIPEB_FLAG;
196 if (dev_priv->vblank_pipe & ~(DRM_I915_VBLANK_PIPE_A|DRM_I915_VBLANK_PIPE_B)) {
197 DRM_ERROR("%s called with invalid pipe 0x%x\n",
198 __FUNCTION__, dev_priv->vblank_pipe);
199 return DRM_ERR(EINVAL);
200 }
201 I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | flag);
202 return 0;
203}
204
205/* Set the vblank monitor pipe
206 */
207int i915_vblank_pipe_set(DRM_IOCTL_ARGS)
208{
209 DRM_DEVICE;
210 drm_i915_private_t *dev_priv = dev->dev_private;
211 drm_i915_vblank_pipe_t pipe;
212
213 if (!dev_priv) {
214 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
215 return DRM_ERR(EINVAL);
216 }
217
218 DRM_COPY_FROM_USER_IOCTL(pipe, (drm_i915_vblank_pipe_t __user *) data,
219 sizeof(pipe));
220
221 dev_priv->vblank_pipe = pipe.pipe;
222 return i915_enable_interrupt (dev);
223}
224
225int i915_vblank_pipe_get(DRM_IOCTL_ARGS)
226{
227 DRM_DEVICE;
228 drm_i915_private_t *dev_priv = dev->dev_private;
229 drm_i915_vblank_pipe_t pipe;
230 u16 flag;
231
232 if (!dev_priv) {
233 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
234 return DRM_ERR(EINVAL);
235 }
236
237 flag = I915_READ(I915REG_INT_ENABLE_R);
238 pipe.pipe = 0;
239 if (flag & VSYNC_PIPEA_FLAG)
240 pipe.pipe |= DRM_I915_VBLANK_PIPE_A;
241 if (flag & VSYNC_PIPEB_FLAG)
242 pipe.pipe |= DRM_I915_VBLANK_PIPE_B;
243 DRM_COPY_TO_USER_IOCTL((drm_i915_vblank_pipe_t __user *) data, pipe,
244 sizeof(pipe));
245 return 0;
246}
247
185/* drm_dma.h hooks 248/* drm_dma.h hooks
186*/ 249*/
187void i915_driver_irq_preinstall(drm_device_t * dev) 250void i915_driver_irq_preinstall(drm_device_t * dev)
@@ -197,7 +260,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
197{ 260{
198 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 261 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
199 262
200 I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | VSYNC_PIPEA_FLAG); 263 i915_enable_interrupt(dev);
201 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); 264 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
202} 265}
203 266