Lines Matching refs:dev
39 int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev) in drm_open_helper() argument
58 priv->dev = dev; in drm_open_helper()
62 down(&dev->struct_sem); in drm_open_helper()
63 if (!dev->file_last) { in drm_open_helper()
66 dev->file_first = priv; in drm_open_helper()
67 dev->file_last = priv; in drm_open_helper()
70 priv->prev = dev->file_last; in drm_open_helper()
71 dev->file_last->next = priv; in drm_open_helper()
72 dev->file_last = priv; in drm_open_helper()
74 up(&dev->struct_sem); in drm_open_helper()
82 drm_device_t *dev = priv->dev; in drm_flush() local
85 current->pid, dev->device, dev->open_count); in drm_flush()
95 drm_device_t *dev = priv->dev; in drm_release() local
98 current->pid, dev->device, dev->open_count); in drm_release()
100 if (dev->lock.hw_lock in drm_release()
101 && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) in drm_release()
102 && dev->lock.pid == current->pid) { in drm_release()
105 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); in drm_release()
106 drm_lock_free(dev, in drm_release()
107 &dev->lock.hw_lock->lock, in drm_release()
108 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); in drm_release()
115 drm_reclaim_buffers(dev, priv->pid); in drm_release()
119 down(&dev->struct_sem); in drm_release()
121 else dev->file_first = priv->next; in drm_release()
123 else dev->file_last = priv->prev; in drm_release()
124 up(&dev->struct_sem); in drm_release()
134 drm_device_t *dev = priv->dev; in drm_fasync() local
137 DRM_DEBUG("fd = %d, device = 0x%x\n", fd, dev->device); in drm_fasync()
138 retcode = fasync_helper(fd, filp, on, &dev->buf_async); in drm_fasync()
151 drm_device_t *dev = priv->dev; in drm_read() local
157 DRM_DEBUG("%p, %p\n", dev->buf_rp, dev->buf_wp); in drm_read()
159 while (dev->buf_rp == dev->buf_wp) { in drm_read()
164 interruptible_sleep_on(&dev->buf_readers); in drm_read()
172 left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ; in drm_read()
177 if (dev->buf_wp > dev->buf_rp) { in drm_read()
178 cur = DRM_MIN(send, dev->buf_wp - dev->buf_rp); in drm_read()
180 cur = DRM_MIN(send, dev->buf_end - dev->buf_rp); in drm_read()
182 if (copy_to_user(buf, dev->buf_rp, cur)) in drm_read()
184 dev->buf_rp += cur; in drm_read()
185 if (dev->buf_rp == dev->buf_end) dev->buf_rp = dev->buf; in drm_read()
189 wake_up_interruptible(&dev->buf_writers); in drm_read()
193 int drm_write_string(drm_device_t *dev, const char *s) in drm_write_string() argument
195 int left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ; in drm_write_string()
200 left, send, dev->buf_rp, dev->buf_wp); in drm_write_string()
202 if (left == 1 || dev->buf_wp != dev->buf_rp) { in drm_write_string()
205 dev->buf_wp, in drm_write_string()
206 dev->buf_rp); in drm_write_string()
210 if (dev->buf_wp >= dev->buf_rp) { in drm_write_string()
211 count = DRM_MIN(send, dev->buf_end - dev->buf_wp); in drm_write_string()
214 count = DRM_MIN(send, dev->buf_rp - dev->buf_wp - 1); in drm_write_string()
216 strncpy(dev->buf_wp, s, count); in drm_write_string()
217 dev->buf_wp += count; in drm_write_string()
218 if (dev->buf_wp == dev->buf_end) dev->buf_wp = dev->buf; in drm_write_string()
228 if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO); in drm_write_string()
233 if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO, POLL_IN); in drm_write_string()
237 if (dev->buf_async) kill_fasync(&dev->buf_async, SIGIO, POLL_IN); in drm_write_string()
241 wake_up_interruptible(&dev->buf_readers); in drm_write_string()
248 drm_device_t *dev = priv->dev; in drm_poll() local
250 poll_wait(filp, &dev->buf_readers, wait); in drm_poll()
251 if (dev->buf_wp != dev->buf_rp) return POLLIN | POLLRDNORM; in drm_poll()