Lines Matching refs:dev
47 static __inline__ int drm_device_is_agp(struct drm_device *dev)
49 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
51 if (dev->driver->device_is_agp != NULL) {
52 int err = (*dev->driver->device_is_agp) (dev);
59 return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP);
62 static int drm_setup(struct drm_device * dev)
70 if (drm_core_has_AGP(dev)) {
71 if (drm_device_is_agp(dev))
72 dev->agp = drm_agp_init(dev);
73 if (drm_core_check_feature(dev, DRIVER_REQUIRE_AGP)
74 && (dev->agp == NULL)) {
81 if (dev->driver->firstopen) {
82 ret = dev->driver->firstopen(dev);
90 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
91 ret = drm_mode_group_init_legacy_group(dev, &dev->primary->mode_group);
97 atomic_set(&dev->ioctl_count, 0);
99 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA) &&
100 !drm_core_check_feature(dev, DRIVER_MODESET)) {
101 dev->buf_use = 0;
102 atomic_set(&dev->buf_alloc, 0);
104 i = drm_dma_setup(dev);
109 for (i = 0; i < DRM_ARRAY_SIZE(dev->counts); i++)
110 atomic_set(&dev->counts[i], 0);
112 dev->context_flag = 0;
113 dev->last_context = 0;
114 dev->if_version = 0;
142 struct drm_device *dev = minor->dev;
149 atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
150 spin_lock(&dev->count_lock);
151 if (!dev->open_count++) {
152 spin_unlock(&dev->count_lock);
153 retcode = drm_setup(dev);
156 spin_unlock(&dev->count_lock);
163 * Called whenever a process opens /dev/drm.
166 * filp and add it into the double linked list in \p dev.
171 struct drm_device *dev = minor->dev;
179 if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
202 DRM_INIT_WAITQUEUE(&priv->event_wait, DRM_INTR_PRI(dev));
205 if (dev->driver->driver_features & DRIVER_GEM)
206 drm_gem_open(dev, priv);
208 if (dev->driver->open) {
209 ret = dev->driver->open(dev, priv);
216 mutex_lock(&dev->struct_mutex);
221 mutex_unlock(&dev->struct_mutex);
232 mutex_unlock(&dev->struct_mutex);
233 if (dev->driver->master_create) {
234 ret = dev->driver->master_create(dev, priv->master);
236 mutex_lock(&dev->struct_mutex);
240 mutex_unlock(&dev->struct_mutex);
244 mutex_lock(&dev->struct_mutex);
245 if (dev->driver->master_set) {
246 ret = dev->driver->master_set(dev, priv, true);
251 mutex_unlock(&dev->struct_mutex);
255 mutex_unlock(&dev->struct_mutex);
259 mutex_unlock(&dev->struct_mutex);
262 mutex_lock(&dev->struct_mutex);
263 list_add(&priv->lhead, &dev->filelist, (caddr_t)priv);
264 mutex_unlock(&dev->struct_mutex);
272 void drm_master_release(struct drm_device *dev, struct drm_file *fpriv)
276 if (drm_i_have_hw_lock(dev, fpriv)) {
287 struct drm_device *dev = file_priv->minor->dev;
292 spin_lock_irqsave(&dev->event_lock, flags);
295 list_for_each_entry_safe(v, vt, struct drm_pending_vblank_event, &dev->vblank_event_list, base.link)
298 drm_vblank_put(dev, v->pipe);
306 spin_unlock_irqrestore(&dev->event_lock, flags);
322 struct drm_device *dev = file_priv->minor->dev;
327 DRM_DEBUG("open_count = %d\n", dev->open_count);
329 if (dev->driver->preclose)
330 dev->driver->preclose(dev, file_priv);
343 drm_master_release(dev, file_priv);
345 if (drm_core_check_feature(dev, DRIVER_HAVE_DMA))
346 drm_core_reclaim_buffers(dev, file_priv);
350 if (dev->driver->driver_features & DRIVER_MODESET)
353 if (dev->driver->driver_features & DRIVER_GEM)
354 drm_gem_release(dev, file_priv);
356 mutex_lock(&dev->ctxlist_mutex);
357 if (!list_empty(&dev->ctxlist)) {
360 list_for_each_entry_safe(pos, n, struct drm_ctx_list, &dev->ctxlist, head) {
363 if (dev->driver->context_dtor)
364 dev->driver->context_dtor(dev,
367 drm_ctxbitmap_free(dev, pos->handle);
371 --dev->ctx_count;
375 mutex_unlock(&dev->ctxlist_mutex);
377 mutex_lock(&dev->struct_mutex);
382 list_for_each_entry(temp, struct drm_file, &dev->filelist, lhead) {
400 if (dev->driver->master_drop)
401 dev->driver->master_drop(dev, file_priv, true);
410 mutex_unlock(&dev->struct_mutex);
412 if (dev->driver->postclose)
413 dev->driver->postclose(dev, file_priv);
420 atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
421 spin_lock(&dev->count_lock);
422 if (!--dev->open_count) {
423 if (atomic_read(&dev->ioctl_count)) {
425 atomic_read(&dev->ioctl_count));
426 spin_unlock(&dev->count_lock);
429 spin_unlock(&dev->count_lock);
430 return drm_lastclose(dev);
432 spin_unlock(&dev->count_lock);
441 struct drm_device *dev = file_priv->minor->dev;
446 spin_lock_irqsave(&dev->event_lock, flags);
462 spin_unlock_irqrestore(&dev->event_lock, flags);