summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/drmP.h22
-rw-r--r--linux-core/drm_drv.c1
-rw-r--r--linux-core/drm_irq.c145
-rw-r--r--shared-core/drm.h17
-rw-r--r--shared-core/i915_dma.c14
-rw-r--r--shared-core/i915_drm.h2
-rw-r--r--shared-core/i915_drv.h6
-rw-r--r--shared-core/i915_irq.c143
8 files changed, 209 insertions, 141 deletions
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index c3f20311..c8b72257 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -648,7 +648,7 @@ struct drm_driver {
/* these have to be filled in */
irqreturn_t(*irq_handler) (DRM_IRQ_ARGS);
void (*irq_preinstall) (struct drm_device * dev);
- void (*irq_postinstall) (struct drm_device * dev);
+ int (*irq_postinstall) (struct drm_device * dev);
void (*irq_uninstall) (struct drm_device * dev);
void (*reclaim_buffers) (struct drm_device *dev, struct file * filp);
void (*reclaim_buffers_locked) (struct drm_device *dev,
@@ -786,10 +786,14 @@ typedef struct drm_device {
wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
atomic_t *vblank_count; /**< number of VBLANK interrupts (driver must alloc the right number of counters) */
spinlock_t vbl_lock;
- struct list_head vbl_sigs; /**< signal list to send on VBLANK */
- struct list_head vbl_sigs2; /**< signals to send on secondary VBLANK */
- atomic_t *vbl_pending;
- u32 *last_vblank; /* protected by dev->vbl_lock */
+ struct list_head *vbl_sigs; /**< signal list to send on VBLANK */
+ atomic_t vbl_pending; /* number of signals pending on all crtcs*/
+ atomic_t *vblank_usage; /* number of users of vblank interrupts per crtc */
+ u32 *last_vblank; /* protected by dev->vbl_lock, used */
+ /* for wraparound handling */
+ u32 *vblank_offset; /* used to track how many vblanks */
+ u32 *vblank_premodeset; /* were lost during modeset */
+
unsigned long max_vblank_count; /**< size of vblank counter register */
spinlock_t tasklet_lock; /**< For drm_locked_tasklet */
void (*locked_tasklet_func)(struct drm_device *dev);
@@ -810,6 +814,7 @@ typedef struct drm_device {
#ifdef __alpha__
struct pci_controller *hose;
#endif
+ int num_crtcs; /**< Number of CRTCs on this device */
drm_sg_mem_t *sg; /**< Scatter gather memory */
void *dev_private; /**< device private data */
drm_sigdata_t sigdata; /**< For block_all_signals */
@@ -1074,11 +1079,18 @@ extern void drm_driver_irq_preinstall(drm_device_t * dev);
extern void drm_driver_irq_postinstall(drm_device_t * dev);
extern void drm_driver_irq_uninstall(drm_device_t * dev);
+extern int drm_vblank_init(drm_device_t *dev, int num_crtcs);
extern int drm_wait_vblank(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int drm_vblank_wait(drm_device_t * dev, unsigned int *vbl_seq);
extern void drm_vbl_send_signals(drm_device_t * dev);
extern void drm_locked_tasklet(drm_device_t *dev, void(*func)(drm_device_t*));
+extern void drm_vblank_get(drm_device_t *dev, int crtc);
+extern void drm_vblank_put(drm_device_t *dev, int crtc);
+
+ /* Modesetting support */
+extern int drm_modeset_ctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
/* AGP/GART support (drm_agpsupport.h) */
extern drm_agp_head_t *drm_agp_init(drm_device_t *dev);
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c
index d5eb9713..1b37ee4a 100644
--- a/linux-core/drm_drv.c
+++ b/linux-core/drm_drv.c
@@ -123,6 +123,7 @@ static drm_ioctl_desc_t drm_ioctls[] = {
DRM_AUTH },
[DRM_IOCTL_NR(DRM_IOCTL_UPDATE_DRAW)] = {drm_update_drawable_info, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY},
+ [DRM_IOCTL_NR(DRM_IOCTL_MODESET_CTL)] = {drm_modeset_ctl, 0},
};
#define DRM_CORE_IOCTL_COUNT ARRAY_SIZE( drm_ioctls )
diff --git a/linux-core/drm_irq.c b/linux-core/drm_irq.c
index f229f778..8125b75c 100644
--- a/linux-core/drm_irq.c
+++ b/linux-core/drm_irq.c
@@ -77,6 +77,70 @@ int drm_irq_by_busid(struct inode *inode, struct file *filp,
return 0;
}
+int drm_vblank_init(drm_device_t *dev, int num_crtcs)
+{
+ int i, ret = -ENOMEM;
+
+ init_waitqueue_head(&dev->vbl_queue);
+ spin_lock_init(&dev->vbl_lock);
+ atomic_set(&dev->vbl_pending, 0);
+ dev->num_crtcs = num_crtcs;
+
+ dev->vbl_sigs = drm_alloc(sizeof(struct list_head) * num_crtcs,
+ DRM_MEM_DRIVER);
+ if (!dev->vbl_sigs)
+ goto err;
+
+ dev->vblank_count = drm_alloc(sizeof(atomic_t) * num_crtcs,
+ DRM_MEM_DRIVER);
+ if (!dev->vblank_count)
+ goto err;
+
+ dev->vblank_usage = drm_alloc(sizeof(atomic_t) * num_crtcs,
+ DRM_MEM_DRIVER);
+ if (!dev->vblank_count)
+ goto err;
+
+ dev->last_vblank = drm_alloc(sizeof(u32) * num_crtcs,
+ DRM_MEM_DRIVER);
+ if (!dev->last_vblank)
+ goto err;
+
+ dev->vblank_premodeset = drm_alloc(sizeof(u32) * num_crtcs,
+ DRM_MEM_DRIVER);
+ if (!dev->vblank_premodeset)
+ goto err;
+
+ dev->vblank_offset = drm_alloc(sizeof(u32) * num_crtcs,
+ DRM_MEM_DRIVER);
+ if (!dev->vblank_offset)
+ goto err;
+
+ /* Zero per-crtc vblank stuff */
+ for (i = 0; i < num_crtcs; i++) {
+ INIT_LIST_HEAD(&dev->vbl_sigs[i]);
+ atomic_set(&dev->vblank_count[i], 0);
+ atomic_set(&dev->vblank_usage[i], 0);
+ dev->last_vblank[i] = 0;
+ dev->vblank_premodeset[i] = 0;
+ dev->vblank_offset[i] = 0;
+ }
+
+ ret = 0;
+ goto out;
+
+err:
+ kfree(dev->vbl_sigs);
+ kfree(dev->vblank_count);
+ kfree(dev->vblank_usage);
+ kfree(dev->last_vblank);
+ kfree(dev->vblank_premodeset);
+ kfree(dev->vblank_offset);
+out:
+ return ret;
+}
+EXPORT_SYMBOL(drm_vblank_init);
+
/**
* Install IRQ handler.
*
@@ -88,7 +152,7 @@ int drm_irq_by_busid(struct inode *inode, struct file *filp,
*/
static int drm_irq_install(drm_device_t * dev)
{
- int ret;
+ int ret = 0;
unsigned long sh_flags = 0;
if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
@@ -114,17 +178,6 @@ static int drm_irq_install(drm_device_t * dev)
DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
- if (drm_core_check_feature(dev, DRIVER_IRQ_VBL)) {
- init_waitqueue_head(&dev->vbl_queue);
-
- spin_lock_init(&dev->vbl_lock);
-
- INIT_LIST_HEAD(&dev->vbl_sigs);
- INIT_LIST_HEAD(&dev->vbl_sigs2);
-
- dev->vbl_pending = 0;
- }
-
/* Before installing handler */
dev->driver->irq_preinstall(dev);
@@ -142,9 +195,9 @@ static int drm_irq_install(drm_device_t * dev)
}
/* After installing handler */
- dev->driver->irq_postinstall(dev);
+ ret = dev->driver->irq_postinstall(dev);
- return 0;
+ return ret;
}
/**
@@ -221,12 +274,12 @@ int drm_control(struct inode *inode, struct file *filp,
}
}
-static void drm_vblank_get(drm_device_t *dev, int crtc)
+void drm_vblank_get(drm_device_t *dev, int crtc)
{
unsigned long irqflags;
u32 cur_vblank, diff;
- if (atomic_add_return(1, &dev->vbl_pending[crtc]) != 1)
+ if (atomic_add_return(1, &dev->vblank_count[crtc]) != 1)
return;
/*
@@ -243,21 +296,60 @@ static void drm_vblank_get(drm_device_t *dev, int crtc)
dev->last_vblank[crtc];
diff += cur_vblank;
} else {
- diff = cur_vblank - last_vblank;
+ diff = cur_vblank - dev->last_vblank[crtc];
}
dev->last_vblank[crtc] = cur_vblank;
- spin_lock_irqrestore(&dev->vbl_lock, irqflags);
+ spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
atomic_add(diff, &dev->vblank_count[crtc]);
dev->driver->enable_vblank(dev, crtc);
}
+EXPORT_SYMBOL(drm_vblank_get);
-static void drm_vblank_put(drm_device_t *dev, int crtc)
+void drm_vblank_put(drm_device_t *dev, int crtc)
{
- if (atomic_dec_and_test(&dev->vbl_pending[crtc]))
+ if (atomic_dec_and_test(&dev->vblank_count[crtc]))
dev->driver->disable_vblank(dev, crtc);
}
+EXPORT_SYMBOL(drm_vblank_put);
+int drm_modeset_ctl(DRM_IOCTL_ARGS)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->head->dev;
+ drm_modeset_ctl_t __user *argp = (void __user *)data;
+ drm_modeset_ctl_t modeset;
+ int crtc, ret = 0;
+ u32 new;
+
+ if (copy_from_user(&modeset, argp, sizeof(modeset))) {
+ ret = -EFAULT;
+ goto out;
+ }
+
+ crtc = modeset.arg;
+ if (crtc > dev->num_crtcs) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ switch (modeset.cmd) {
+ case _DRM_PRE_MODESET:
+ dev->vblank_premodeset[crtc] =
+ dev->driver->get_vblank_counter(dev, crtc);
+ break;
+ case _DRM_POST_MODESET:
+ new = dev->driver->get_vblank_counter(dev, crtc);
+ dev->vblank_offset[crtc] = dev->vblank_premodeset[crtc] - new;
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+out:
+ return ret;
+}
/**
* Wait for VBLANK.
@@ -329,8 +421,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
if (flags & _DRM_VBLANK_SIGNAL) {
unsigned long irqflags;
- struct list_head *vbl_sigs = (flags & _DRM_VBLANK_SECONDARY)
- ? &dev->vbl_sigs2 : &dev->vbl_sigs;
+ struct list_head *vbl_sigs = &dev->vbl_sigs[crtc];
drm_vbl_sig_t *vbl_sig;
spin_lock_irqsave(&dev->vbl_lock, irqflags);
@@ -351,7 +442,7 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
}
}
- if (atomic_read(&dev->vbl_pending[crtc]) >= 100) {
+ if (atomic_read(&dev->vbl_pending) >= 100) {
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
drm_vblank_put(dev, crtc);
return -EBUSY;
@@ -359,6 +450,8 @@ int drm_wait_vblank(DRM_IOCTL_ARGS)
spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
+ atomic_inc(&dev->vbl_pending);
+
if (!
(vbl_sig =
drm_alloc(sizeof(drm_vbl_sig_t), DRM_MEM_DRIVER))) {
@@ -414,9 +507,9 @@ void drm_vbl_send_signals(drm_device_t * dev)
spin_lock_irqsave(&dev->vbl_lock, flags);
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < dev->num_crtcs; i++) {
drm_vbl_sig_t *vbl_sig, *tmp;
- struct list_head *vbl_sigs = i ? &dev->vbl_sigs2 : &dev->vbl_sigs;
+ struct list_head *vbl_sigs = &dev->vbl_sigs[i];
unsigned int vbl_seq = atomic_read(&dev->vblank_count[i]);
list_for_each_entry_safe(vbl_sig, tmp, vbl_sigs, head) {
@@ -429,7 +522,7 @@ void drm_vbl_send_signals(drm_device_t * dev)
drm_free(vbl_sig, sizeof(*vbl_sig),
DRM_MEM_DRIVER);
-
+ atomic_dec(&dev->vbl_pending);
drm_vblank_put(dev, i);
}
}
diff --git a/shared-core/drm.h b/shared-core/drm.h
index b4195419..15081f92 100644
--- a/shared-core/drm.h
+++ b/shared-core/drm.h
@@ -587,6 +587,21 @@ typedef union drm_wait_vblank {
struct drm_wait_vblank_reply reply;
} drm_wait_vblank_t;
+typedef enum {
+ _DRM_PRE_MODESET = 1,
+ _DRM_POST_MODESET = 2,
+} drm_modeset_ctl_cmd_t;
+
+/**
+ * DRM_IOCTL_MODESET_CTL ioctl argument type
+ *
+ * \sa drmModesetCtl().
+ */
+typedef struct drm_modeset_ctl {
+ drm_modeset_ctl_cmd_t cmd;
+ unsigned long arg;
+} drm_modeset_ctl_t;
+
/**
* DRM_IOCTL_AGP_ENABLE ioctl argument type.
*
@@ -953,6 +968,8 @@ typedef union drm_mm_init_arg{
#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, drm_update_draw_t)
+#define DRM_IOCTL_MODESET_CTL DRM_IOW(0x40, drm_modeset_ctl_t)
+
/*@}*/
/**
diff --git a/shared-core/i915_dma.c b/shared-core/i915_dma.c
index 73972d56..ebb184cc 100644
--- a/shared-core/i915_dma.c
+++ b/shared-core/i915_dma.c
@@ -833,20 +833,6 @@ static int i915_setparam(DRM_IOCTL_ARGS)
case I915_SETPARAM_ALLOW_BATCHBUFFER:
dev_priv->allow_batchbuffer = param.value;
break;
- case I915_SETPARAM_PREMODESET:
- if (param.value > 1) {
- DRM_ERROR("bad crtc\n");
- return -EINVAL;
- }
- i915_premodeset(dev, param.value);
- break;
- case I915_SETPARAM_POSTMODESET:
- if (param.value > 1) {
- DRM_ERROR("bad crtc\n");
- return -EINVAL;
- }
- i915_postmodeset(dev, param.value);
- break;
default:
DRM_ERROR("unknown parameter %d\n", param.param);
return DRM_ERR(EINVAL);
diff --git a/shared-core/i915_drm.h b/shared-core/i915_drm.h
index aea048fa..1c6ff4d3 100644
--- a/shared-core/i915_drm.h
+++ b/shared-core/i915_drm.h
@@ -235,8 +235,6 @@ typedef struct drm_i915_getparam {
#define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
#define I915_SETPARAM_ALLOW_BATCHBUFFER 3
-#define I915_SETPARAM_PREMODESET 4
-#define I915_SETPARAM_POSTMODESET 5
typedef struct drm_i915_setparam {
int param;
diff --git a/shared-core/i915_drv.h b/shared-core/i915_drv.h
index 88949ad0..079e9017 100644
--- a/shared-core/i915_drv.h
+++ b/shared-core/i915_drv.h
@@ -132,8 +132,6 @@ typedef struct drm_i915_private {
spinlock_t swaps_lock;
drm_i915_vbl_swap_t vbl_swaps;
unsigned int swaps_pending;
- unsigned long vblank_offset[2];
- unsigned long vblank_premodeset[2];
} drm_i915_private_t;
enum intel_chip_family {
@@ -165,7 +163,7 @@ extern int i915_irq_wait(DRM_IOCTL_ARGS);
extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
extern void i915_driver_irq_preinstall(drm_device_t * dev);
-extern void i915_driver_irq_postinstall(drm_device_t * dev);
+extern int i915_driver_irq_postinstall(drm_device_t * dev);
extern void i915_driver_irq_uninstall(drm_device_t * dev);
extern int i915_vblank_pipe_set(DRM_IOCTL_ARGS);
extern int i915_vblank_pipe_get(DRM_IOCTL_ARGS);
@@ -176,8 +174,6 @@ extern int i915_vblank_swap(DRM_IOCTL_ARGS);
extern void i915_enable_vblank(drm_device_t *dev, int crtc);
extern void i915_disable_vblank(drm_device_t *dev, int crtc);
extern u32 i915_get_vblank_counter(drm_device_t *dev, int crtc);
-extern void i915_premodeset(drm_device_t *dev, int crtc);
-extern void i915_postmodeset(drm_device_t *dev, int crtc);
/* i915_mem.c */
extern int i915_mem_alloc(DRM_IOCTL_ARGS);
diff --git a/shared-core/i915_irq.c b/shared-core/i915_irq.c
index 1019c942..0f4d1a81 100644
--- a/shared-core/i915_irq.c
+++ b/shared-core/i915_irq.c
@@ -117,12 +117,14 @@ static void i915_vblank_tasklet(drm_device_t *dev)
list_for_each_safe(list, tmp, &dev_priv->vbl_swaps.head) {
drm_i915_vbl_swap_t *vbl_swap =
list_entry(list, drm_i915_vbl_swap_t, head);
+ int crtc = vbl_swap->pipe;
if ((counter[vbl_swap->pipe] - vbl_swap->sequence) > (1<<23))
continue;
list_del(list);
dev_priv->swaps_pending--;
+ drm_vblank_put(dev, crtc);
spin_unlock(&dev_priv->swaps_lock);
spin_lock(&dev->drw_lock);
@@ -274,6 +276,32 @@ static void i915_vblank_tasklet(drm_device_t *dev)
}
}
+u32 i915_get_vblank_counter(drm_device_t *dev, int crtc)
+{
+ drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
+ unsigned long high_frame = crtc ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH;
+ unsigned long low_frame = crtc ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL;
+ u32 high1, high2, low, count;
+
+ /*
+ * High & low register fields aren't synchronized, so make sure
+ * we get a low value that's stable across two reads of the high
+ * register.
+ */
+ do {
+ high1 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
+ PIPE_FRAME_HIGH_SHIFT);
+ low = ((I915_READ(low_frame) & PIPE_FRAME_LOW_MASK) >>
+ PIPE_FRAME_LOW_SHIFT);
+ high2 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
+ PIPE_FRAME_HIGH_SHIFT);
+ } while (high1 != high2);
+
+ count = (high1 << 8) | low;
+
+ return count;
+}
+
irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
{
drm_device_t *dev = (drm_device_t *) arg;
@@ -306,22 +334,14 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
#endif
}
- if (temp & (VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG)) {
- int vblank_pipe = dev_priv->vblank_pipe;
-
- if ((vblank_pipe &
- (DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B))
- == (DRM_I915_VBLANK_PIPE_A | DRM_I915_VBLANK_PIPE_B)) {
- if (temp & VSYNC_PIPEA_FLAG)
- atomic_inc(&dev->vblank_count[0]);
- if (temp & VSYNC_PIPEB_FLAG)
- atomic_inc(&dev->vblank_count[1]);
- } else if (((temp & VSYNC_PIPEA_FLAG) &&
- (vblank_pipe & DRM_I915_VBLANK_PIPE_A)) ||
- ((temp & VSYNC_PIPEB_FLAG) &&
- (vblank_pipe & DRM_I915_VBLANK_PIPE_B)))
- atomic_inc(&dev->vblank_count[0]);
+ if (temp & VSYNC_PIPEA_FLAG)
+ atomic_add(i915_get_vblank_counter(dev, 0),
+ &dev->vblank_count[0]);
+ if (temp & VSYNC_PIPEB_FLAG)
+ atomic_add(i915_get_vblank_counter(dev, 1),
+ &dev->vblank_count[1]);
+ if (temp & (VSYNC_PIPEA_FLAG | VSYNC_PIPEB_FLAG)) {
DRM_WAKEUP(&dev->vbl_queue);
drm_vbl_send_signals(dev);
@@ -461,6 +481,9 @@ int i915_irq_wait(DRM_IOCTL_ARGS)
void i915_enable_vblank(drm_device_t *dev, int crtc)
{
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
+
+ if (crtc > dev_priv->vblank_pipe)
+ return;
switch (crtc) {
case 0:
@@ -481,6 +504,9 @@ void i915_enable_vblank(drm_device_t *dev, int crtc)
void i915_disable_vblank(drm_device_t *dev, int crtc)
{
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
+
+ if (crtc > dev_priv->vblank_pipe)
+ return;
switch (crtc) {
case 0:
@@ -498,54 +524,6 @@ void i915_disable_vblank(drm_device_t *dev, int crtc)
I915_WRITE16(I915REG_INT_ENABLE_R, dev_priv->irq_enable_reg);
}
-static u32 i915_vblank_counter(drm_device_t *dev, int crtc)
-{
- drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
- unsigned long high_frame = crtc ? PIPEBFRAMEHIGH : PIPEAFRAMEHIGH;
- unsigned long low_frame = crtc ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL;
- u32 high1, high2, low, count;
-
- /*
- * High & low register fields aren't synchronized, so make sure
- * we get a low value that's stable across two reads of the high
- * register.
- */
- do {
- high1 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
- PIPE_FRAME_HIGH_SHIFT);
- low = ((I915_READ(low_frame) & PIPE_FRAME_LOW_MASK) >>
- PIPE_FRAME_LOW_SHIFT);
- high2 = ((I915_READ(high_frame) & PIPE_FRAME_HIGH_MASK) >>
- PIPE_FRAME_HIGH_SHIFT);
- } while (high1 != high2);
-
- count = (high1 << 8) | low;
-
- return count;
-}
-
-u32 i915_get_vblank_counter(drm_device_t *dev, int crtc)
-{
- drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
- return i915_vblank_counter(dev, crtc) + dev_priv->vblank_offset[crtc];
-}
-
-void i915_premodeset(drm_device_t *dev, int crtc)
-{
- drm_i915_private_t *dev_priv = dev->dev_private;
-
- dev_priv->vblank_premodeset[crtc] = i915_vblank_counter(dev, crtc);
-}
-
-void i915_postmodeset(drm_device_t *dev, int crtc)
-{
- drm_i915_private_t *dev_priv = dev->dev_private;
- u32 new;
-
- new = i915_vblank_counter(dev, crtc);
- dev_priv->vblank_offset[crtc] = dev_priv->vblank_premodeset[crtc] - new;
-}
-
static void i915_enable_interrupt (drm_device_t *dev)
{
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
@@ -660,6 +638,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
+ drm_vblank_get(dev, pipe);
curseq = atomic_read(&dev->vblank_count[pipe]);
if (seqtype == _DRM_VBLANK_RELATIVE)
@@ -670,6 +649,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
swap.sequence = curseq + 1;
} else {
DRM_DEBUG("Missed target sequence\n");
+ drm_vblank_put(dev, pipe);
return DRM_ERR(EINVAL);
}
}
@@ -690,6 +670,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
DRM_DEBUG("Invalid drawable ID %d\n",
swap.drawable);
+ drm_vblank_put(dev, pipe);
return DRM_ERR(EINVAL);
}
@@ -697,6 +678,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
spin_unlock_irqrestore(&dev->drw_lock, irqflags);
+ drm_vblank_put(dev, pipe);
return 0;
}
}
@@ -712,6 +694,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
vbl_swap->flip = (swap.seqtype & _DRM_VBLANK_FLIP);
spin_unlock_irqrestore(&dev_priv->swaps_lock, irqflags);
DRM_DEBUG("Already scheduled\n");
+ drm_vblank_put(dev, pipe);
return 0;
}
}
@@ -720,6 +703,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
if (dev_priv->swaps_pending >= 100) {
DRM_DEBUG("Too many swaps queued\n");
+ drm_vblank_put(dev, pipe);
return DRM_ERR(EBUSY);
}
@@ -727,6 +711,7 @@ int i915_vblank_swap(DRM_IOCTL_ARGS)
if (!vbl_swap) {
DRM_ERROR("Failed to allocate memory to queue swap\n");
+ drm_vblank_put(dev, pipe);
return DRM_ERR(ENOMEM);
}
@@ -764,10 +749,10 @@ void i915_driver_irq_preinstall(drm_device_t * dev)
I915_WRITE16(I915REG_INT_ENABLE_R, 0x0);
}
-void i915_driver_irq_postinstall(drm_device_t * dev)
+int i915_driver_irq_postinstall(drm_device_t * dev)
{
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
- int i;
+ int ret, num_pipes = 2;
spin_lock_init(&dev_priv->swaps_lock);
INIT_LIST_HEAD(&dev_priv->vbl_swaps.head);
@@ -776,31 +761,10 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
dev_priv->user_irq_lock = SPIN_LOCK_UNLOCKED;
dev_priv->user_irq_refcount = 0;
dev_priv->irq_enable_reg = 0;
- dev->vblank_count = kmalloc(sizeof(atomic_t) * 2, GFP_KERNEL);
- if (!dev->vblank_count) {
- DRM_ERROR("out of memory\n");
- return;
- }
- dev->vbl_pending = kmalloc(sizeof(atomic_t) * 2, GFP_KERNEL);
- if (!dev->vbl_pending) {
- DRM_ERROR("out of memory\n");
- kfree(dev->vblank_count);
- return;
- }
- dev->last_vblank = kmalloc(sizeof(atomic_t) * 2, GFP_KERNEL);
- if (!dev->last_vblank) {
- DRM_ERROR("out of memory\n");
- kfree(dev->vblank_count);
- return;
- }
- /* Zero per-crtc vblank stuff */
- for (i = 0; i < 2; i++) {
- atomic_set(&dev->vbl_pending[i], 0);
- atomic_set(&dev->vblank_count[i], 0);
- dev->last_vblank[i] = 0;
- dev_priv->vblank_offset[i] = 0;
- }
+ ret = drm_vblank_init(dev, num_pipes);
+ if (ret)
+ return ret;
dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
@@ -812,6 +776,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
*/
I915_WRITE(I915REG_INSTPM, ( 1 << 5) | ( 1 << 21));
+ return 0;
}
void i915_driver_irq_uninstall(drm_device_t * dev)