diff options
author | Jesse Barnes <jbarnes@hobbes.virtuousgeek.org> | 2007-05-18 09:42:51 -0700 |
---|---|---|
committer | Jesse Barnes <jbarnes@hobbes.virtuousgeek.org> | 2007-05-18 09:42:51 -0700 |
commit | a4929b921e44dcd3cae8e384b9b7eabc51db28ff (patch) | |
tree | 876a2ba492fd2786ed44ff26c514a0f2951f9096 /linux-core/drm_drv.c | |
parent | f89458722173b364b8c3c27788b6c61889da554c (diff) | |
parent | d42c1de3fb05405820b03ec9bb12f0b9a7eb0a7b (diff) |
Merge branch 'modesetting-101' of git+ssh://git.freedesktop.org/git/mesa/drm into origin/modesetting-101
Conflicts:
linux-core/drm_crtc.c - reconcile with locking changes
Diffstat (limited to 'linux-core/drm_drv.c')
-rw-r--r-- | linux-core/drm_drv.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/linux-core/drm_drv.c b/linux-core/drm_drv.c index dc52f302..76fb90c9 100644 --- a/linux-core/drm_drv.c +++ b/linux-core/drm_drv.c @@ -632,3 +632,45 @@ err_i1: return retcode; } EXPORT_SYMBOL(drm_ioctl); + +int drm_wait_on(drm_device_t *dev, wait_queue_head_t *queue, int timeout, + int (*fn)(drm_device_t *dev, void *priv), void *priv) +{ + DECLARE_WAITQUEUE(entry, current); + unsigned long end = jiffies + (timeout); + int ret = 0; + add_wait_queue(queue, &entry); + + for (;;) { + __set_current_state(TASK_INTERRUPTIBLE); + if ((*fn)(dev, priv)) + break; + if (time_after_eq(jiffies, end)) { + ret = -EBUSY; + break; + } + schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); + if (signal_pending(current)) { + ret = -EINTR; + break; + } + } + __set_current_state(TASK_RUNNING); + remove_wait_queue(queue, &entry); + return ret; +} +EXPORT_SYMBOL(drm_wait_on); + +drm_local_map_t *drm_getsarea(struct drm_device *dev) +{ + drm_map_list_t *entry; + + list_for_each_entry(entry, &dev->maplist->head, head) { + if (entry->map && entry->map->type == _DRM_SHM && + (entry->map->flags & _DRM_CONTAINS_LOCK)) { + return entry->map; + } + } + return NULL; +} +EXPORT_SYMBOL(drm_getsarea); |