Lines Matching refs:dev
38 __FBSDID("$FreeBSD: releng/11.0/sys/dev/drm2/drm_fops.c 288653 2015-10-04 07:45:36Z adrian $");
40 #include <dev/drm2/drmP.h>
43 DRM_STRUCTPROC *p, struct drm_device *dev);
45 static int drm_setup(struct drm_device * dev)
50 if (dev->driver->firstopen) {
51 ret = dev->driver->firstopen(dev);
56 atomic_set(&dev->ioctl_count, 0);
57 atomic_set(&dev->vma_count, 0);
59 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
60 !drm_core_check_feature(dev, DRIVER_MODESET)) {
61 dev->buf_use = 0;
62 atomic_set(&dev->buf_alloc, 0);
64 i = drm_dma_setup(dev);
74 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
75 atomic_set(&dev->counts[i], 0);
78 dev->sigdata.lock = NULL;
80 dev->context_flag = 0;
81 dev->interrupt_flag = 0;
82 dev->dma_flag = 0;
83 dev->last_context = 0;
84 dev->last_switch = 0;
85 dev->last_checked = 0;
86 DRM_INIT_WAITQUEUE(&dev->context_wait);
87 dev->if_version = 0;
90 dev->ctx_start = 0;
91 dev->lck_start = 0;
93 dev->buf_async = NULL;
94 DRM_INIT_WAITQUEUE(&dev->buf_readers);
95 DRM_INIT_WAITQUEUE(&dev->buf_writers);
124 struct drm_device *dev = NULL;
133 if (!(dev = minor->dev))
142 if (!dev->open_count++)
145 retcode = drm_open_helper(kdev, flags, fmt, p, dev);
150 atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
152 retcode = drm_setup(dev);
161 device_unbusy(dev->dev);
163 dev->open_count--;
170 * Called whenever a process opens /dev/drm.
174 * \param dev device.
178 * filp and add it into the double linked list in \p dev.
181 DRM_STRUCTPROC *p, struct drm_device *dev)
188 if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
210 if (dev->driver->driver_features & DRIVER_GEM)
211 drm_gem_open(dev, priv);
214 if (drm_core_check_feature(dev, DRIVER_PRIME))
218 if (dev->driver->open) {
219 ret = dev->driver->open(dev, priv);
226 DRM_LOCK(dev);
231 DRM_UNLOCK(dev);
242 DRM_UNLOCK(dev);
243 if (dev->driver->master_create) {
244 ret = dev->driver->master_create(dev, priv->master);
246 DRM_LOCK(dev);
250 DRM_UNLOCK(dev);
254 DRM_LOCK(dev);
255 if (dev->driver->master_set) {
256 ret = dev->driver->master_set(dev, priv, true);
261 DRM_UNLOCK(dev);
265 DRM_UNLOCK(dev);
269 DRM_UNLOCK(dev);
272 DRM_LOCK(dev);
273 list_add(&priv->lhead, &dev->filelist);
274 DRM_UNLOCK(dev);
277 device_busy(dev->dev);
290 static void drm_master_release(struct drm_device *dev, struct drm_file *file_priv)
293 if (drm_i_have_hw_lock(dev, file_priv)) {
303 struct drm_device *dev = file_priv->minor->dev;
308 DRM_SPINLOCK_IRQSAVE(&dev->event_lock, flags);
311 list_for_each_entry_safe(v, vt, &dev->vblank_event_list, base.link)
314 drm_vblank_put(dev, v->pipe);
322 DRM_SPINUNLOCK_IRQRESTORE(&dev->event_lock, flags);
340 struct drm_device *dev = file_priv->minor->dev;
344 DRM_DEBUG("open_count = %d\n", dev->open_count);
346 if (dev->driver->preclose)
347 dev->driver->preclose(dev, file_priv);
356 dev->open_count);
365 drm_master_release(dev, file_priv);
367 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
368 drm_core_reclaim_buffers(dev, file_priv);
374 if (dev->driver->driver_features & DRIVER_MODESET)
377 if (dev->driver->driver_features & DRIVER_GEM)
378 drm_gem_release(dev, file_priv);
381 mutex_lock(&dev->ctxlist_mutex);
382 if (!list_empty(&dev->ctxlist)) {
385 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
388 if (dev->driver->context_dtor)
389 dev->driver->context_dtor(dev,
392 drm_ctxbitmap_free(dev, pos->handle);
396 --dev->ctx_count;
400 mutex_unlock(&dev->ctxlist_mutex);
403 DRM_LOCK(dev);
408 list_for_each_entry(temp, &dev->filelist, lhead) {
420 if (dev->sigdata.lock == master->lock.hw_lock)
421 dev->sigdata.lock = NULL;
429 if (dev->driver->master_drop)
430 dev->driver->master_drop(dev, file_priv, true);
439 DRM_UNLOCK(dev);
441 if (dev->driver->postclose)
442 dev->driver->postclose(dev, file_priv);
445 if (drm_core_check_feature(dev, DRIVER_PRIME))
455 atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
457 device_unbusy(dev->dev);
459 if (!--dev->open_count) {
460 if (atomic_read(&dev->ioctl_count)) {
462 atomic_read(&dev->ioctl_count));
464 drm_lastclose(dev);
478 /* DRM_SPINLOCK_IRQSAVE(&dev->event_lock, flags); */
494 /* DRM_SPINUNLOCK_IRQRESTORE(&dev->event_lock, flags); */
502 struct drm_device *dev;
512 dev = drm_get_device_from_kdev(kdev);
513 mtx_lock(&dev->event_lock);
519 error = msleep(&file_priv->event_space, &dev->event_lock,
526 mtx_unlock(&dev->event_lock);
534 mtx_lock(&dev->event_lock);
538 mtx_unlock(&dev->event_lock);
547 struct drm_device *dev;
550 dev = file_priv->minor->dev;
551 mtx_assert(&dev->event_lock, MA_OWNED);
561 struct drm_device *dev;
570 dev = drm_get_device_from_kdev(kdev);
573 mtx_lock(&dev->event_lock);
583 mtx_unlock(&dev->event_lock);
592 struct drm_device *dev;
594 dev = drm_get_device_from_kdev(kdev);
595 if (dev->drm_ttm_bdev != NULL) {
596 return (-ttm_bo_mmap_single(dev->drm_ttm_bdev, offset, size,
598 } else if ((dev->driver->driver_features & DRIVER_GEM) != 0) {
599 return (-drm_gem_mmap_single(dev, offset, size, obj_res, nprot));