summaryrefslogtreecommitdiff
path: root/linux/ffb_context.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux/ffb_context.c')
-rw-r--r--linux/ffb_context.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/linux/ffb_context.c b/linux/ffb_context.c
index ffc9b090..add2a743 100644
--- a/linux/ffb_context.c
+++ b/linux/ffb_context.c
@@ -537,3 +537,63 @@ int DRM(rmctx)(struct inode *inode, struct file *filp, unsigned int cmd,
}
return 0;
}
+
+static void ffb_driver_release(drm_device_t *dev)
+{
+ ffb_dev_priv_t *fpriv = (ffb_dev_priv_t *) dev->dev_private;
+ int context = _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock);
+ int idx;
+
+ idx = context - 1;
+ if (fpriv &&
+ context != DRM_KERNEL_CONTEXT &&
+ fpriv->hw_state[idx] != NULL) {
+ kfree(fpriv->hw_state[idx]);
+ fpriv->hw_state[idx] = NULL;
+ }
+}
+
+static int ffb_driver_presetup(drm_device_t *dev)
+{
+ int ret;
+ ret = ffb_presetup(dev);
+ if (_ret != 0) return ret;
+}
+
+static void ffb_driver_pretakedown(drm_device_t *dev)
+{
+ if (dev->dev_private) kfree(dev->dev_private);
+}
+
+static void ffb_driver_postcleanup(drm_device_t *dev)
+{
+ if (ffb_position != NULL) kfree(ffb_position);
+}
+
+static int ffb_driver_kernel_context_switch_unlock(struct drm_device *dev)
+{
+ dev->lock.filp = 0;
+ {
+ __volatile__ unsigned int *plock = &dev->lock.hw_lock->lock;
+ unsigned int old, new, prev, ctx;
+
+ ctx = lock.context;
+ do {
+ old = *plock;
+ new = ctx;
+ prev = cmpxchg(plock, old, new);
+ } while (prev != old);
+ }
+ wake_up_interruptible(&dev->lock.lock_queue);
+}
+
+static void ffb_driver_register_fns(drm_device_t *dev)
+{
+ DRM(fops).get_unmapped_area = ffb_get_unmapped_area;
+ dev->fn_tbl.release = ffb_driver_release;
+ dev->fn_tbl.presetup = ffb_driver_presetup;
+ dev->fn_tbl.pretakedown = ffb_driver_pretakedown;
+ dev->fn_tbl.postcleanup = ffb_driver_postcleanup;
+ dev->fn_tbl.kernel_context_switch = ffb_context_switch;
+ dev->fn_tbl.kernel_context_switch_unlock = ffb_driver_kernel_context_switch_unlock;
+}