Line data Source code
1 : /* $OpenBSD: drmP.h,v 1.219 2018/08/20 19:36:04 kettenis Exp $ */
2 : /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
3 : * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
4 : */
5 : /*-
6 : * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
7 : * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 : * All rights reserved.
9 : *
10 : * Permission is hereby granted, free of charge, to any person obtaining a
11 : * copy of this software and associated documentation files (the "Software"),
12 : * to deal in the Software without restriction, including without limitation
13 : * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 : * and/or sell copies of the Software, and to permit persons to whom the
15 : * Software is furnished to do so, subject to the following conditions:
16 : *
17 : * The above copyright notice and this permission notice (including the next
18 : * paragraph) shall be included in all copies or substantial portions of the
19 : * Software.
20 : *
21 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 : * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 : * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 : * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 : * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 : * OTHER DEALINGS IN THE SOFTWARE.
28 : *
29 : * Authors:
30 : * Rickard E. (Rik) Faith <faith@valinux.com>
31 : * Gareth Hughes <gareth@valinux.com>
32 : *
33 : */
34 :
35 : #ifndef _DRM_P_H_
36 : #define _DRM_P_H_
37 :
38 : #if defined(_KERNEL) || defined(__KERNEL__)
39 :
40 : //#define DRMDEBUG
41 :
42 : #include <sys/param.h>
43 : #include <sys/queue.h>
44 : #include <sys/malloc.h>
45 : #include <sys/pool.h>
46 : #include <sys/kernel.h>
47 : #include <sys/systm.h>
48 : #include <sys/proc.h>
49 : #include <sys/conf.h>
50 : #include <sys/mutex.h>
51 : #include <sys/tree.h>
52 : #include <sys/endian.h>
53 : #include <sys/stdint.h>
54 : #include <sys/memrange.h>
55 : #include <sys/extent.h>
56 : #include <sys/rwlock.h>
57 :
58 : #ifdef DDB
59 : #include <ddb/db_var.h>
60 : #endif
61 :
62 : #include <uvm/uvm_extern.h>
63 : #include <uvm/uvm_object.h>
64 :
65 : #include <dev/pci/pcidevs.h>
66 : #include <dev/pci/pcivar.h>
67 : #include <dev/pci/agpvar.h>
68 : #include <machine/bus.h>
69 :
70 : #define CONFIG_DRM_FBDEV_EMULATION 1
71 : #define CONFIG_BACKLIGHT_CLASS_DEVICE 1
72 :
73 : #include "drm_linux.h"
74 : #include "drm_linux_list.h"
75 : #include "drm.h"
76 : #include "drm_vma_manager.h"
77 : #include <dev/pci/drm/drm_crtc.h>
78 : #include "drm_mm.h"
79 : #include "drm_linux_atomic.h"
80 : #include "agp.h"
81 :
82 : struct fb_cmap;
83 : struct fb_fillrect;
84 : struct fb_copyarea;
85 : struct fb_image;
86 :
87 : #define drm_debug 0
88 : #define DRM_UT_KMS 0
89 :
90 : /***********************************************************************/
91 : /** \name DRM template customization defaults */
92 : /*@{*/
93 :
94 : /* driver capabilities and requirements mask */
95 : #define DRIVER_USE_AGP 0x1
96 : #define DRIVER_PCI_DMA 0x8
97 : #define DRIVER_SG 0x10
98 : #define DRIVER_HAVE_DMA 0x20
99 : #define DRIVER_HAVE_IRQ 0x40
100 : #define DRIVER_IRQ_SHARED 0x80
101 : #define DRIVER_GEM 0x1000
102 : #define DRIVER_MODESET 0x2000
103 : #define DRIVER_PRIME 0x4000
104 : #define DRIVER_RENDER 0x8000
105 : #define DRIVER_ATOMIC 0x10000
106 :
107 : #define DRM_DEBUGBITS_DEBUG 0x1
108 : #define DRM_DEBUGBITS_KMS 0x2
109 : #define DRM_DEBUGBITS_FAILED_IOCTL 0x4
110 :
111 : #define __OS_HAS_AGP (NAGP > 0)
112 :
113 : /* Internal types and structures */
114 : #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
115 :
116 : #define DRM_CURRENTPID curproc->p_p->ps_pid
117 : #define DRM_MAXUNITS 8
118 :
119 : /* DRM_SUSER returns true if the user is superuser */
120 : #define DRM_SUSER(p) (suser(p) == 0)
121 : #define DRM_MTRR_WC MDF_WRITECOMBINE
122 :
123 : #define DRM_WAKEUP(x) wakeup(x)
124 :
125 : #define drm_msleep(x) mdelay(x)
126 :
127 : extern struct cfdriver drm_cd;
128 :
129 : /* freebsd compat */
130 : #define TAILQ_CONCAT(head1, head2, field) do { \
131 : if (!TAILQ_EMPTY(head2)) { \
132 : *(head1)->tqh_last = (head2)->tqh_first; \
133 : (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \
134 : (head1)->tqh_last = (head2)->tqh_last; \
135 : TAILQ_INIT((head2)); \
136 : } \
137 : } while (0)
138 :
139 : #define DRM_ARRAY_SIZE nitems
140 :
141 : /* DRM_READMEMORYBARRIER() prevents reordering of reads.
142 : * DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
143 : * DRM_MEMORYBARRIER() prevents reordering of reads and writes.
144 : */
145 : #if defined(__i386__)
146 : #define DRM_READMEMORYBARRIER() __asm __volatile( \
147 : "lock; addl $0,0(%%esp)" : : : "memory");
148 : #define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory");
149 : #define DRM_MEMORYBARRIER() __asm __volatile( \
150 : "lock; addl $0,0(%%esp)" : : : "memory");
151 : #elif defined(__alpha__)
152 : #define DRM_READMEMORYBARRIER() alpha_mb();
153 : #define DRM_WRITEMEMORYBARRIER() alpha_wmb();
154 : #define DRM_MEMORYBARRIER() alpha_mb();
155 : #elif defined(__amd64__)
156 : #define DRM_READMEMORYBARRIER() __asm __volatile( \
157 : "lock; addl $0,0(%%rsp)" : : : "memory");
158 : #define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory");
159 : #define DRM_MEMORYBARRIER() __asm __volatile( \
160 : "lock; addl $0,0(%%rsp)" : : : "memory");
161 : #elif defined(__aarch64__)
162 : #define DRM_READMEMORYBARRIER() __membar("dsb ld")
163 : #define DRM_WRITEMEMORYBARRIER() __membar("dsb st")
164 : #define DRM_MEMORYBARRIER() __membar("dsb sy")
165 : #elif defined(__mips64__)
166 : #define DRM_READMEMORYBARRIER() DRM_MEMORYBARRIER()
167 : #define DRM_WRITEMEMORYBARRIER() DRM_MEMORYBARRIER()
168 : #define DRM_MEMORYBARRIER() mips_sync()
169 : #elif defined(__powerpc__)
170 : #define DRM_READMEMORYBARRIER() DRM_MEMORYBARRIER()
171 : #define DRM_WRITEMEMORYBARRIER() DRM_MEMORYBARRIER()
172 : #define DRM_MEMORYBARRIER() __asm __volatile("sync" : : : "memory");
173 : #elif defined(__sparc64__)
174 : #define DRM_READMEMORYBARRIER() DRM_MEMORYBARRIER()
175 : #define DRM_WRITEMEMORYBARRIER() DRM_MEMORYBARRIER()
176 : #define DRM_MEMORYBARRIER() membar_sync()
177 : #endif
178 :
179 : #define smp_mb__before_atomic() DRM_MEMORYBARRIER()
180 : #define smp_mb__before_atomic_dec() DRM_MEMORYBARRIER()
181 : #define smp_mb__after_atomic_dec() DRM_MEMORYBARRIER()
182 : #define smp_mb__before_atomic_inc() DRM_MEMORYBARRIER()
183 : #define smp_mb__after_atomic_inc() DRM_MEMORYBARRIER()
184 :
185 : #define mb() DRM_MEMORYBARRIER()
186 : #define rmb() DRM_READMEMORYBARRIER()
187 : #define wmb() DRM_WRITEMEMORYBARRIER()
188 : #define smp_rmb() DRM_READMEMORYBARRIER()
189 : #define smp_wmb() DRM_WRITEMEMORYBARRIER()
190 : #define mmiowb() DRM_WRITEMEMORYBARRIER()
191 :
192 : #define DRM_COPY_TO_USER(user, kern, size) copyout(kern, user, size)
193 : #define DRM_COPY_FROM_USER(kern, user, size) copyin(user, kern, size)
194 :
195 : #define DRM_UDELAY(udelay) DELAY(udelay)
196 :
197 : static inline bool
198 0 : drm_can_sleep(void)
199 : {
200 : #if defined(__i386__) || defined(__amd64__)
201 0 : if (pagefault_disabled() || in_dbg_master() || irqs_disabled())
202 : #else
203 : if (in_dbg_master() || irqs_disabled())
204 : #endif
205 0 : return false;
206 0 : return true;
207 0 : }
208 :
209 : #define DRM_WAIT_ON(ret, wq, timo, condition) do { \
210 : ret = wait_event_interruptible_timeout(wq, condition, timo); \
211 : if (ret == 0) \
212 : ret = -EBUSY; \
213 : if (ret > 0) \
214 : ret = 0; \
215 : } while (0)
216 :
217 : #define DRM_ERROR(fmt, arg...) \
218 : printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \
219 : curproc->p_p->ps_pid, __func__ , ## arg)
220 :
221 :
222 : #ifdef DRMDEBUG
223 : #define DRM_INFO(fmt, arg...) printf("drm: " fmt, ## arg)
224 : #define DRM_INFO_ONCE(fmt, arg...) printf("drm: " fmt, ## arg)
225 : #else
226 : #define DRM_INFO(fmt, arg...) do { } while(/* CONSTCOND */ 0)
227 : #define DRM_INFO_ONCE(fmt, arg...) do { } while(/* CONSTCOND */ 0)
228 : #endif
229 :
230 : #ifdef DRMDEBUG
231 : #undef DRM_DEBUG
232 : #define DRM_DEBUG(fmt, arg...) do { \
233 : if (drm_debug_flag) \
234 : printf("[" DRM_NAME ":pid%d:%s] " fmt, \
235 : curproc->p_p->ps_pid, __func__ , ## arg); \
236 : } while (0)
237 : #else
238 : #define DRM_DEBUG(fmt, arg...) do { } while(/* CONSTCOND */ 0)
239 : #endif
240 :
241 : #ifdef DRMDEBUG
242 : #undef DRM_DEBUG_KMS
243 : #define DRM_DEBUG_KMS(fmt, arg...) do { \
244 : if (drm_debug_flag) \
245 : printf("[" DRM_NAME ":pid%d:%s] " fmt, \
246 : curproc->p_p->ps_pid, __func__ , ## arg); \
247 : } while (0)
248 : #else
249 : #define DRM_DEBUG_KMS(fmt, arg...) do { } while(/* CONSTCOND */ 0)
250 : #endif
251 :
252 : #ifdef DRMDEBUG
253 : #undef DRM_LOG_KMS
254 : #define DRM_LOG_KMS(fmt, arg...) do { \
255 : if (drm_debug_flag) \
256 : printf(fmt, ## arg); \
257 : } while (0)
258 : #else
259 : #define DRM_LOG_KMS(fmt, arg...) do { } while(/* CONSTCOND */ 0)
260 : #endif
261 :
262 : #ifdef DRMDEBUG
263 : #undef DRM_DEBUG_DRIVER
264 : #define DRM_DEBUG_DRIVER(fmt, arg...) do { \
265 : if (drm_debug_flag) \
266 : printf("[" DRM_NAME ":pid%d:%s] " fmt, \
267 : curproc->p_p->ps_pid, __func__ , ## arg); \
268 : } while (0)
269 : #else
270 : #define DRM_DEBUG_DRIVER(fmt, arg...) do { } while(/* CONSTCOND */ 0)
271 : #endif
272 :
273 : #ifdef DRMDEBUG
274 : #undef DRM_DEBUG_ATOMIC
275 : #define DRM_DEBUG_ATOMIC(fmt, arg...) do { \
276 : if (drm_debug_flag) \
277 : printf("[" DRM_NAME ":pid%d:%s] " fmt, \
278 : curproc->p_p->ps_pid, __func__ , ## arg); \
279 : } while (0)
280 : #else
281 : #define DRM_DEBUG_ATOMIC(fmt, arg...) do { } while(0)
282 : #endif
283 :
284 : #define DRM_DEBUG_VBL(fmt, arg...) do {} while(0)
285 :
286 : struct drm_pcidev {
287 : uint16_t vendor;
288 : uint16_t device;
289 : uint16_t subvendor;
290 : uint16_t subdevice;
291 : uint32_t class;
292 : uint32_t class_mask;
293 : unsigned long driver_data;
294 : };
295 :
296 : struct drm_file;
297 : struct drm_device;
298 :
299 : /**
300 : * Ioctl function type.
301 : *
302 : * \param inode device inode.
303 : * \param file_priv DRM file private pointer.
304 : * \param cmd command.
305 : * \param arg argument.
306 : */
307 : typedef int drm_ioctl_t(struct drm_device *dev, void *data,
308 : struct drm_file *file_priv);
309 :
310 : typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
311 : unsigned long arg);
312 :
313 : #define DRM_AUTH 0x1
314 : #define DRM_MASTER 0x2
315 : #define DRM_ROOT_ONLY 0x4
316 : #define DRM_CONTROL_ALLOW 0x8
317 : #define DRM_UNLOCKED 0x10
318 : #define DRM_RENDER_ALLOW 0x20
319 :
320 : struct drm_ioctl_desc {
321 : unsigned int cmd;
322 : int flags;
323 : drm_ioctl_t *func;
324 : unsigned int cmd_drv;
325 : };
326 :
327 : /**
328 : * Creates a driver or general drm_ioctl_desc array entry for the given
329 : * ioctl, for use by drm_ioctl().
330 : */
331 :
332 : #define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
333 : [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl}
334 :
335 : struct drm_dmamem {
336 : bus_dmamap_t map;
337 : caddr_t kva;
338 : bus_size_t size;
339 : int nsegs;
340 : bus_dma_segment_t segs[1];
341 : };
342 :
343 : typedef struct drm_dma_handle {
344 : struct drm_dmamem *mem;
345 : dma_addr_t busaddr;
346 : void *vaddr;
347 : size_t size;
348 : } drm_dma_handle_t;
349 :
350 : struct drm_pending_event {
351 : struct drm_event *event;
352 : struct list_head link;
353 : struct drm_file *file_priv;
354 : pid_t pid; /* pid of requester, no guarantee it's valid by the time
355 : we deliver the event, for tracing only */
356 : void (*destroy)(struct drm_pending_event *event);
357 : };
358 :
359 : /* initial implementaton using a linked list - todo hashtab */
360 : struct drm_prime_file_private {
361 : struct list_head head;
362 : struct rwlock lock;
363 : };
364 :
365 : /** File private data */
366 : struct drm_file {
367 : unsigned always_authenticated :1;
368 : unsigned authenticated :1;
369 : unsigned is_master :1; /* this file private is a master for a minor */
370 : /* true when the client has asked us to expose stereo 3D mode flags */
371 : unsigned stereo_allowed :1;
372 : /*
373 : * true if client understands CRTC primary planes and cursor planes
374 : * in the plane list
375 : */
376 : unsigned universal_planes:1;
377 : /* true if client understands atomic properties */
378 : unsigned atomic:1;
379 :
380 : drm_magic_t magic;
381 : int minor;
382 :
383 : /** Mapping of mm object handles to object pointers. */
384 : struct idr object_idr;
385 : /** Lock for synchronization of access to object_idr. */
386 : spinlock_t table_lock;
387 :
388 : struct file *filp;
389 : void *driver_priv;
390 :
391 : /**
392 : * fbs - List of framebuffers associated with this file.
393 : *
394 : * Protected by fbs_lock. Note that the fbs list holds a reference on
395 : * the fb object to prevent it from untimely disappearing.
396 : */
397 : struct list_head fbs;
398 : struct rwlock fbs_lock;
399 :
400 : /** User-created blob properties; this retains a reference on the
401 : * property. */
402 : struct list_head blobs;
403 :
404 : wait_queue_head_t event_wait;
405 : struct list_head event_list;
406 : int event_space;
407 :
408 : struct drm_prime_file_private prime;
409 :
410 : struct selinfo rsel;
411 : SPLAY_ENTRY(drm_file) link;
412 : };
413 :
414 : struct drm_agp_head {
415 : struct agp_softc *agpdev;
416 : const char *chipset;
417 : TAILQ_HEAD(agp_memlist, drm_agp_mem) memory;
418 : struct agp_info info;
419 : unsigned long base;
420 : unsigned long mode;
421 : unsigned long page_mask;
422 : int acquired;
423 : int cant_use_aperture;
424 : int enabled;
425 : int mtrr;
426 : };
427 :
428 : /* location of GART table */
429 : #define DRM_ATI_GART_MAIN 1
430 : #define DRM_ATI_GART_FB 2
431 :
432 : #define DRM_ATI_GART_PCI 1
433 : #define DRM_ATI_GART_PCIE 2
434 : #define DRM_ATI_GART_IGP 3
435 : #define DRM_ATI_GART_R600 4
436 :
437 : /**
438 : * This structure defines the drm_mm memory object, which will be used by the
439 : * DRM for its buffer objects.
440 : */
441 : struct drm_gem_object {
442 : /** Reference count of this object */
443 : struct kref refcount;
444 :
445 : /**
446 : * handle_count - gem file_priv handle count of this object
447 : *
448 : * Each handle also holds a reference. Note that when the handle_count
449 : * drops to 0 any global names (e.g. the id in the flink namespace) will
450 : * be cleared.
451 : *
452 : * Protected by dev->object_name_lock.
453 : * */
454 : unsigned handle_count;
455 :
456 : /** Related drm device */
457 : struct drm_device *dev;
458 :
459 : /** File representing the shmem storage */
460 : struct file *filp;
461 :
462 : /* Mapping info for this object */
463 : struct drm_vma_offset_node vma_node;
464 :
465 : /**
466 : * Size of the object, in bytes. Immutable over the object's
467 : * lifetime.
468 : */
469 : size_t size;
470 :
471 : /**
472 : * Global name for this object, starts at 1. 0 means unnamed.
473 : * Access is covered by the object_name_lock in the related drm_device
474 : */
475 : int name;
476 :
477 : /**
478 : * Memory domains. These monitor which caches contain read/write data
479 : * related to the object. When transitioning from one set of domains
480 : * to another, the driver is called to ensure that caches are suitably
481 : * flushed and invalidated
482 : */
483 : uint32_t read_domains;
484 : uint32_t write_domain;
485 :
486 : /**
487 : * While validating an exec operation, the
488 : * new read/write domain values are computed here.
489 : * They will be transferred to the above values
490 : * at the point that any cache flushing occurs
491 : */
492 : uint32_t pending_read_domains;
493 : uint32_t pending_write_domain;
494 :
495 : /**
496 : * dma_buf - dma buf associated with this GEM object
497 : *
498 : * Pointer to the dma-buf associated with this gem object (either
499 : * through importing or exporting). We break the resulting reference
500 : * loop when the last gem handle for this object is released.
501 : *
502 : * Protected by obj->object_name_lock
503 : */
504 : struct dma_buf *dma_buf;
505 :
506 : /**
507 : * import_attach - dma buf attachment backing this object
508 : *
509 : * Any foreign dma_buf imported as a gem object has this set to the
510 : * attachment point for the device. This is invariant over the lifetime
511 : * of a gem object.
512 : *
513 : * The driver's ->gem_free_object callback is responsible for cleaning
514 : * up the dma_buf attachment and references acquired at import time.
515 : *
516 : * Note that the drm gem/prime core does not depend upon drivers setting
517 : * this field any more. So for drivers where this doesn't make sense
518 : * (e.g. virtual devices or a displaylink behind an usb bus) they can
519 : * simply leave it as NULL.
520 : */
521 : struct dma_buf_attachment *import_attach;
522 :
523 : struct uvm_object uobj;
524 : SPLAY_ENTRY(drm_gem_object) entry;
525 : struct uvm_object *uao;
526 : };
527 :
528 : /* Size of ringbuffer for vblank timestamps. Just double-buffer
529 : * in initial implementation.
530 : */
531 : #define DRM_VBLANKTIME_RBSIZE 2
532 :
533 : /* Flags and return codes for get_vblank_timestamp() driver function. */
534 : #define DRM_CALLED_FROM_VBLIRQ 1
535 : #define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
536 : #define DRM_VBLANKTIME_IN_VBLANK (1 << 1)
537 :
538 : /* get_scanout_position() return flags */
539 : #define DRM_SCANOUTPOS_VALID (1 << 0)
540 : #define DRM_SCANOUTPOS_IN_VBLANK (1 << 1)
541 : #define DRM_SCANOUTPOS_ACCURATE (1 << 2)
542 :
543 : struct drm_driver {
544 : int (*firstopen)(struct drm_device *);
545 : int (*open)(struct drm_device *, struct drm_file *);
546 : void (*close)(struct drm_device *, struct drm_file *);
547 : void (*preclose)(struct drm_device *, struct drm_file *);
548 : void (*postclose)(struct drm_device *, struct drm_file *);
549 : void (*lastclose)(struct drm_device *);
550 : struct uvm_object *(*mmap)(struct drm_device *, voff_t, vsize_t);
551 : int (*dma_ioctl)(struct drm_device *, struct drm_dma *,
552 : struct drm_file *);
553 : int (*irq_handler)(int, void *);
554 : void (*irq_preinstall) (struct drm_device *);
555 : int (*irq_install)(struct drm_device *);
556 : int (*irq_postinstall) (struct drm_device *);
557 : void (*irq_uninstall)(struct drm_device *);
558 : int vblank_pipes;
559 :
560 : /**
561 : * get_vblank_counter - get raw hardware vblank counter
562 : * @dev: DRM device
563 : * @pipe: counter to fetch
564 : *
565 : * Driver callback for fetching a raw hardware vblank counter for @crtc.
566 : * If a device doesn't have a hardware counter, the driver can simply
567 : * return the value of drm_vblank_count. The DRM core will account for
568 : * missed vblank events while interrupts where disabled based on system
569 : * timestamps.
570 : *
571 : * Wraparound handling and loss of events due to modesetting is dealt
572 : * with in the DRM core code.
573 : *
574 : * RETURNS
575 : * Raw vblank counter value.
576 : */
577 : u32 (*get_vblank_counter) (struct drm_device *dev, unsigned int pipe);
578 :
579 : /**
580 : * enable_vblank - enable vblank interrupt events
581 : * @dev: DRM device
582 : * @pipe: which irq to enable
583 : *
584 : * Enable vblank interrupts for @crtc. If the device doesn't have
585 : * a hardware vblank counter, this routine should be a no-op, since
586 : * interrupts will have to stay on to keep the count accurate.
587 : *
588 : * RETURNS
589 : * Zero on success, appropriate errno if the given @crtc's vblank
590 : * interrupt cannot be enabled.
591 : */
592 : int (*enable_vblank) (struct drm_device *dev, unsigned int pipe);
593 :
594 : /**
595 : * disable_vblank - disable vblank interrupt events
596 : * @dev: DRM device
597 : * @pipe: which irq to enable
598 : *
599 : * Disable vblank interrupts for @crtc. If the device doesn't have
600 : * a hardware vblank counter, this routine should be a no-op, since
601 : * interrupts will have to stay on to keep the count accurate.
602 : */
603 : void (*disable_vblank) (struct drm_device *dev, unsigned int pipe);
604 :
605 : /**
606 : * Called by vblank timestamping code.
607 : *
608 : * Return the current display scanout position from a crtc, and an
609 : * optional accurate ktime_get timestamp of when position was measured.
610 : *
611 : * \param dev DRM device.
612 : * \param pipe Id of the crtc to query.
613 : * \param flags Flags from the caller (DRM_CALLED_FROM_VBLIRQ or 0).
614 : * \param *vpos Target location for current vertical scanout position.
615 : * \param *hpos Target location for current horizontal scanout position.
616 : * \param *stime Target location for timestamp taken immediately before
617 : * scanout position query. Can be NULL to skip timestamp.
618 : * \param *etime Target location for timestamp taken immediately after
619 : * scanout position query. Can be NULL to skip timestamp.
620 : * \param mode Current display timings.
621 : *
622 : * Returns vpos as a positive number while in active scanout area.
623 : * Returns vpos as a negative number inside vblank, counting the number
624 : * of scanlines to go until end of vblank, e.g., -1 means "one scanline
625 : * until start of active scanout / end of vblank."
626 : *
627 : * \return Flags, or'ed together as follows:
628 : *
629 : * DRM_SCANOUTPOS_VALID = Query successful.
630 : * DRM_SCANOUTPOS_INVBL = Inside vblank.
631 : * DRM_SCANOUTPOS_ACCURATE = Returned position is accurate. A lack of
632 : * this flag means that returned position may be offset by a constant
633 : * but unknown small number of scanlines wrt. real scanout position.
634 : *
635 : */
636 : int (*get_scanout_position) (struct drm_device *dev, unsigned int pipe,
637 : unsigned int flags, int *vpos, int *hpos,
638 : ktime_t *stime, ktime_t *etime,
639 : const struct drm_display_mode *mode);
640 :
641 : /**
642 : * Called by \c drm_get_last_vbltimestamp. Should return a precise
643 : * timestamp when the most recent VBLANK interval ended or will end.
644 : *
645 : * Specifically, the timestamp in @vblank_time should correspond as
646 : * closely as possible to the time when the first video scanline of
647 : * the video frame after the end of VBLANK will start scanning out,
648 : * the time immediately after end of the VBLANK interval. If the
649 : * @crtc is currently inside VBLANK, this will be a time in the future.
650 : * If the @crtc is currently scanning out a frame, this will be the
651 : * past start time of the current scanout. This is meant to adhere
652 : * to the OpenML OML_sync_control extension specification.
653 : *
654 : * \param dev dev DRM device handle.
655 : * \param pipe crtc for which timestamp should be returned.
656 : * \param *max_error Maximum allowable timestamp error in nanoseconds.
657 : * Implementation should strive to provide timestamp
658 : * with an error of at most *max_error nanoseconds.
659 : * Returns true upper bound on error for timestamp.
660 : * \param *vblank_time Target location for returned vblank timestamp.
661 : * \param flags 0 = Defaults, no special treatment needed.
662 : * \param DRM_CALLED_FROM_VBLIRQ = Function is called from vblank
663 : * irq handler. Some drivers need to apply some workarounds
664 : * for gpu-specific vblank irq quirks if flag is set.
665 : *
666 : * \returns
667 : * Zero if timestamping isn't supported in current display mode or a
668 : * negative number on failure. A positive status code on success,
669 : * which describes how the vblank_time timestamp was computed.
670 : */
671 : int (*get_vblank_timestamp) (struct drm_device *dev, unsigned int pipe,
672 : int *max_error,
673 : struct timeval *vblank_time,
674 : unsigned flags);
675 :
676 : /**
677 : * Driver-specific constructor for drm_gem_objects, to set up
678 : * obj->driver_private.
679 : *
680 : * Returns 0 on success.
681 : */
682 : void (*gem_free_object) (struct drm_gem_object *obj);
683 : int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
684 : void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
685 :
686 : int (*gem_fault)(struct drm_gem_object *, struct uvm_faultinfo *,
687 : off_t, vaddr_t, vm_page_t *, int, int, vm_prot_t, int);
688 :
689 : /* prime: */
690 : /* export handle -> fd (see drm_gem_prime_handle_to_fd() helper) */
691 : int (*prime_handle_to_fd)(struct drm_device *dev, struct drm_file *file_priv,
692 : uint32_t handle, uint32_t flags, int *prime_fd);
693 : /* import fd -> handle (see drm_gem_prime_fd_to_handle() helper) */
694 : int (*prime_fd_to_handle)(struct drm_device *dev, struct drm_file *file_priv,
695 : int prime_fd, uint32_t *handle);
696 : /* export GEM -> dmabuf */
697 : struct dma_buf * (*gem_prime_export)(struct drm_device *dev,
698 : struct drm_gem_object *obj, int flags);
699 : /* import dmabuf -> GEM */
700 : struct drm_gem_object * (*gem_prime_import)(struct drm_device *dev,
701 : struct dma_buf *dma_buf);
702 :
703 : int (*dumb_create)(struct drm_file *file_priv,
704 : struct drm_device *dev, struct drm_mode_create_dumb *args);
705 : int (*dumb_map_offset)(struct drm_file *file_priv,
706 : struct drm_device *dev, uint32_t handle, uint64_t *offset);
707 : int (*dumb_destroy)(struct drm_file *file_priv,
708 : struct drm_device *dev, uint32_t handle);
709 :
710 : size_t gem_size;
711 : size_t buf_priv_size;
712 : size_t file_priv_size;
713 :
714 : int major;
715 : int minor;
716 : int patchlevel;
717 : const char *name; /* Simple driver name */
718 : const char *desc; /* Longer driver name */
719 : const char *date; /* Date of last major changes. */
720 :
721 : u32 driver_features;
722 : const struct drm_ioctl_desc *ioctls;
723 : int num_ioctls;
724 :
725 : };
726 :
727 : enum drm_minor_type {
728 : DRM_MINOR_LEGACY,
729 : DRM_MINOR_CONTROL,
730 : DRM_MINOR_RENDER,
731 : DRM_MINOR_CNT,
732 : };
733 :
734 : #include "drm_crtc.h"
735 :
736 : #if 0
737 : /* mode specified on the command line */
738 : struct drm_cmdline_mode {
739 : bool specified;
740 : bool refresh_specified;
741 : bool bpp_specified;
742 : int xres, yres;
743 : int bpp;
744 : int refresh;
745 : bool rb;
746 : bool interlace;
747 : bool cvt;
748 : bool margins;
749 : enum drm_connector_force force;
750 : };
751 : #endif
752 :
753 : struct drm_minor;
754 :
755 : struct drm_pending_vblank_event {
756 : struct drm_pending_event base;
757 : int pipe;
758 : struct drm_event_vblank event;
759 : };
760 :
761 : struct drm_vblank_crtc {
762 : struct drm_device *dev; /* pointer to the drm_device */
763 : wait_queue_head_t queue; /**< VBLANK wait queue */
764 : struct timeout disable_timer; /* delayed disable timer */
765 :
766 : /* vblank counter, protected by dev->vblank_time_lock for writes */
767 : u32 count;
768 : /* vblank timestamps, protected by dev->vblank_time_lock for writes */
769 : struct timeval time[DRM_VBLANKTIME_RBSIZE];
770 :
771 : atomic_t refcount; /* number of users of vblank interruptsper crtc */
772 : u32 last; /* protected by dev->vbl_lock, used */
773 : /* for wraparound handling */
774 : u32 last_wait; /* Last vblank seqno waited per CRTC */
775 : unsigned int inmodeset; /* Display driver is setting mode */
776 : unsigned int pipe; /* crtc index */
777 : int framedur_ns; /* frame/field duration in ns */
778 : int linedur_ns; /* line duration in ns */
779 : bool enabled; /* so we don't call enable more than
780 : once per disable */
781 : };
782 :
783 : /**
784 : * DRM device functions structure
785 : */
786 : struct drm_device {
787 : struct device device; /* softc is an extension of struct device */
788 : struct device *dev;
789 :
790 : struct drm_driver *driver;
791 :
792 : struct klist note;
793 :
794 : struct pci_dev _pdev;
795 : struct pci_dev *pdev;
796 : u_int16_t pci_device;
797 : u_int16_t pci_vendor;
798 :
799 : pci_chipset_tag_t pc;
800 : pcitag_t *bridgetag;
801 :
802 : bus_dma_tag_t dmat;
803 : bus_space_tag_t bst;
804 :
805 : struct mutex quiesce_mtx;
806 : int quiesce;
807 : int quiesce_count;
808 :
809 : char *unique; /* Unique identifier: e.g., busid */
810 : int unique_len; /* Length of unique field */
811 :
812 : int if_version; /* Highest interface version set */
813 : /* Locks */
814 : struct rwlock struct_mutex; /* protects everything else */
815 :
816 : /* Usage Counters */
817 : int open_count; /* Outstanding files open */
818 :
819 : /* Authentication */
820 : SPLAY_HEAD(drm_file_tree, drm_file) files;
821 : drm_magic_t magicid;
822 :
823 : /* Context support */
824 :
825 : /** \name VBLANK IRQ support */
826 : /*@{ */
827 : bool irq_enabled;
828 : int irq;
829 :
830 : /*
831 : * At load time, disabling the vblank interrupt won't be allowed since
832 : * old clients may not call the modeset ioctl and therefore misbehave.
833 : * Once the modeset ioctl *has* been called though, we can safely
834 : * disable them when unused.
835 : */
836 : bool vblank_disable_allowed;
837 :
838 : /*
839 : * If true, vblank interrupt will be disabled immediately when the
840 : * refcount drops to zero, as opposed to via the vblank disable
841 : * timer.
842 : * This can be set to true it the hardware has a working vblank
843 : * counter and the driver uses drm_vblank_on() and drm_vblank_off()
844 : * appropriately.
845 : */
846 : bool vblank_disable_immediate;
847 :
848 : /* array of size num_crtcs */
849 : struct drm_vblank_crtc *vblank;
850 :
851 : struct mutex vblank_time_lock; /**< Protects vblank count and time updates during vblank enable/disable */
852 : struct mutex vbl_lock;
853 :
854 : u32 max_vblank_count; /**< size of vblank counter register */
855 :
856 : /**
857 : * List of events
858 : */
859 : struct list_head vblank_event_list;
860 : spinlock_t event_lock;
861 :
862 : /*@} */
863 :
864 : int *vblank_enabled;
865 : int *vblank_inmodeset;
866 : u32 *last_vblank_wait;
867 :
868 : int num_crtcs;
869 :
870 : pid_t buf_pgid;
871 :
872 : struct drm_agp_head *agp;
873 : void *dev_private;
874 : struct address_space *dev_mapping;
875 : struct drm_local_map *agp_buffer_map;
876 :
877 : struct drm_mode_config mode_config; /* Current mode config */
878 :
879 : /* GEM info */
880 : atomic_t obj_count;
881 : u_int obj_name;
882 : atomic_t obj_memory;
883 : struct pool objpl;
884 :
885 : /** \name GEM information */
886 : /*@{ */
887 : struct rwlock object_name_lock;
888 : struct idr object_name_idr;
889 : struct drm_vma_offset_manager *vma_offset_manager;
890 : /*@} */
891 : };
892 :
893 : struct drm_attach_args {
894 : struct drm_driver *driver;
895 : char *busid;
896 : bus_dma_tag_t dmat;
897 : bus_space_tag_t bst;
898 : size_t busid_len;
899 : int is_agp;
900 : u_int16_t pci_vendor;
901 : u_int16_t pci_device;
902 : u_int16_t pci_subvendor;
903 : u_int16_t pci_subdevice;
904 : u_int8_t pci_revision;
905 : struct pci_attach_args *pa;
906 : pci_chipset_tag_t pc;
907 : pcitag_t tag;
908 : pcitag_t *bridgetag;
909 : int console;
910 : };
911 :
912 : #define DRMDEVCF_CONSOLE 0
913 : #define drmdevcf_console cf_loc[DRMDEVCF_CONSOLE]
914 : /* spec'd as console? */
915 : #define DRMDEVCF_CONSOLE_UNK -1
916 :
917 : extern int drm_debug_flag;
918 :
919 : /* Device setup support (drm_drv.c) */
920 : int drm_pciprobe(struct pci_attach_args *, const struct drm_pcidev * );
921 : struct device *drm_attach_pci(struct drm_driver *,
922 : struct pci_attach_args *, int, int, struct device *);
923 : dev_type_ioctl(drmioctl);
924 : dev_type_read(drmread);
925 : dev_type_poll(drmpoll);
926 : dev_type_open(drmopen);
927 : dev_type_close(drmclose);
928 : dev_type_mmap(drmmmap);
929 : struct drm_local_map *drm_getsarea(struct drm_device *);
930 : struct drm_dmamem *drm_dmamem_alloc(bus_dma_tag_t, bus_size_t, bus_size_t,
931 : int, bus_size_t, int, int);
932 : void drm_dmamem_free(bus_dma_tag_t, struct drm_dmamem *);
933 :
934 : extern struct drm_dma_handle *drm_pci_alloc(struct drm_device *dev, size_t size,
935 : size_t align);
936 : extern void drm_pci_free(struct drm_device *dev, struct drm_dma_handle * dmah);
937 :
938 : const struct drm_pcidev *drm_find_description(int , int ,
939 : const struct drm_pcidev *);
940 : int drm_order(unsigned long);
941 :
942 : /* File operations helpers (drm_fops.c) */
943 : struct drm_file *drm_find_file_by_minor(struct drm_device *, int);
944 : struct drm_device *drm_get_device_from_kdev(dev_t);
945 :
946 : /* Memory management support (drm_memory.c) */
947 : void *drm_alloc(size_t);
948 : void *drm_calloc(size_t, size_t);
949 : void *drm_realloc(void *, size_t, size_t);
950 : void drm_free(void *);
951 :
952 : #include "drm_mem_util.h"
953 :
954 : /* XXX until we get PAT support */
955 : #define drm_core_ioremap_wc drm_core_ioremap
956 : void drm_core_ioremap(struct drm_local_map *, struct drm_device *);
957 : void drm_core_ioremapfree(struct drm_local_map *, struct drm_device *);
958 :
959 : int drm_mtrr_add(unsigned long, size_t, int);
960 : int drm_mtrr_del(int, unsigned long, size_t, int);
961 :
962 : /* Misc. IOCTL support (drm_ioctl.c) */
963 : int drm_noop(struct drm_device *dev, void *data,
964 : struct drm_file *file_priv);
965 : int drm_invalid_op(struct drm_device *dev, void *data,
966 : struct drm_file *file_priv);
967 :
968 : /* Cache management (drm_cache.c) */
969 : void drm_clflush_pages(struct vm_page *pages[], unsigned long num_pages);
970 : void drm_clflush_sg(struct sg_table *st);
971 : void drm_clflush_virt_range(void *addr, unsigned long length);
972 :
973 : /*
974 : * These are exported to drivers so that they can implement fencing using
975 : * DMA quiscent + idle. DMA quiescent usually requires the hardware lock.
976 : */
977 :
978 : /* IRQ support (drm_irq.h) */
979 : extern int drm_irq_install(struct drm_device *dev, int irq);
980 : extern int drm_irq_uninstall(struct drm_device *dev);
981 :
982 : extern int drm_vblank_init(struct drm_device *dev, unsigned int num_crtcs);
983 : extern int drm_wait_vblank(struct drm_device *dev, void *data,
984 : struct drm_file *filp);
985 : extern u32 drm_vblank_count(struct drm_device *dev, unsigned int pipe);
986 : extern u32 drm_crtc_vblank_count(struct drm_crtc *crtc);
987 : extern u32 drm_vblank_count_and_time(struct drm_device *dev, unsigned int pipe,
988 : struct timeval *vblanktime);
989 : extern u32 drm_crtc_vblank_count_and_time(struct drm_crtc *crtc,
990 : struct timeval *vblanktime);
991 : extern void drm_send_vblank_event(struct drm_device *dev, unsigned int pipe,
992 : struct drm_pending_vblank_event *e);
993 : extern void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
994 : struct drm_pending_vblank_event *e);
995 : extern void drm_arm_vblank_event(struct drm_device *dev, unsigned int pipe,
996 : struct drm_pending_vblank_event *e);
997 : extern void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
998 : struct drm_pending_vblank_event *e);
999 : extern bool drm_handle_vblank(struct drm_device *dev, unsigned int pipe);
1000 : extern bool drm_crtc_handle_vblank(struct drm_crtc *crtc);
1001 : extern int drm_vblank_get(struct drm_device *dev, unsigned int pipe);
1002 : extern void drm_vblank_put(struct drm_device *dev, unsigned int pipe);
1003 : extern int drm_crtc_vblank_get(struct drm_crtc *crtc);
1004 : extern void drm_crtc_vblank_put(struct drm_crtc *crtc);
1005 : extern void drm_wait_one_vblank(struct drm_device *dev, unsigned int pipe);
1006 : extern void drm_crtc_wait_one_vblank(struct drm_crtc *crtc);
1007 : extern void drm_vblank_off(struct drm_device *dev, unsigned int pipe);
1008 : extern void drm_vblank_on(struct drm_device *dev, unsigned int pipe);
1009 : extern void drm_crtc_vblank_off(struct drm_crtc *crtc);
1010 : extern void drm_crtc_vblank_reset(struct drm_crtc *crtc);
1011 : extern void drm_crtc_vblank_on(struct drm_crtc *crtc);
1012 : extern void drm_vblank_cleanup(struct drm_device *dev);
1013 : extern u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
1014 :
1015 : extern int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
1016 : unsigned int pipe, int *max_error,
1017 : struct timeval *vblank_time,
1018 : unsigned flags,
1019 : const struct drm_display_mode *mode);
1020 : extern void drm_calc_timestamping_constants(struct drm_crtc *crtc,
1021 : const struct drm_display_mode *mode);
1022 :
1023 : /**
1024 : * drm_crtc_vblank_waitqueue - get vblank waitqueue for the CRTC
1025 : * @crtc: which CRTC's vblank waitqueue to retrieve
1026 : *
1027 : * This function returns a pointer to the vblank waitqueue for the CRTC.
1028 : * Drivers can use this to implement vblank waits using wait_event() & co.
1029 : */
1030 0 : static inline wait_queue_head_t *drm_crtc_vblank_waitqueue(struct drm_crtc *crtc)
1031 : {
1032 0 : return &crtc->dev->vblank[drm_crtc_index(crtc)].queue;
1033 : }
1034 :
1035 : /* Modesetting support */
1036 : extern void drm_vblank_pre_modeset(struct drm_device *dev, unsigned int pipe);
1037 : extern void drm_vblank_post_modeset(struct drm_device *dev, unsigned int pipe);
1038 :
1039 : extern struct dma_buf *drm_gem_prime_export(struct drm_device *dev,
1040 : struct drm_gem_object *obj,
1041 : int flags);
1042 : extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
1043 : struct drm_file *file_priv, uint32_t handle, uint32_t flags,
1044 : int *prime_fd);
1045 : extern struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
1046 : struct dma_buf *dma_buf);
1047 : extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
1048 : struct drm_file *file_priv, int prime_fd, uint32_t *handle);
1049 : extern void drm_gem_dmabuf_release(struct dma_buf *dma_buf);
1050 :
1051 : bool drm_mode_parse_command_line_for_connector(const char *,
1052 : struct drm_connector *, struct drm_cmdline_mode *);
1053 : struct drm_display_mode *
1054 : drm_mode_create_from_cmdline_mode(struct drm_device *,
1055 : struct drm_cmdline_mode *);
1056 :
1057 : extern unsigned int drm_timestamp_monotonic;
1058 :
1059 : /* AGP/PCI Express/GART support (drm_agpsupport.c) */
1060 : struct drm_agp_head *drm_agp_init(void);
1061 : void drm_agp_takedown(struct drm_device *);
1062 : int drm_agp_acquire(struct drm_device *);
1063 : int drm_agp_release(struct drm_device *);
1064 : int drm_agp_info(struct drm_device *, struct drm_agp_info *);
1065 : int drm_agp_enable(struct drm_device *, struct drm_agp_mode);
1066 : void *drm_agp_allocate_memory(size_t, u32);
1067 : int drm_agp_free_memory(void *);
1068 : int drm_agp_bind_memory(void *, off_t);
1069 : int drm_agp_unbind_memory(void *);
1070 : int drm_agp_alloc(struct drm_device *, struct drm_agp_buffer *);
1071 : int drm_agp_free(struct drm_device *, struct drm_agp_buffer *);
1072 : int drm_agp_bind(struct drm_device *, struct drm_agp_binding *);
1073 : int drm_agp_unbind(struct drm_device *, struct drm_agp_binding *);
1074 :
1075 : /* AGP/GART support (drm_agpsupport.c) */
1076 : int drm_agp_acquire_ioctl(struct drm_device *, void *, struct drm_file *);
1077 : int drm_agp_release_ioctl(struct drm_device *, void *, struct drm_file *);
1078 : int drm_agp_enable_ioctl(struct drm_device *, void *, struct drm_file *);
1079 : int drm_agp_info_ioctl(struct drm_device *, void *, struct drm_file *);
1080 : int drm_agp_alloc_ioctl(struct drm_device *, void *, struct drm_file *);
1081 : int drm_agp_free_ioctl(struct drm_device *, void *, struct drm_file *);
1082 : int drm_agp_unbind_ioctl(struct drm_device *, void *, struct drm_file *);
1083 : int drm_agp_bind_ioctl(struct drm_device *, void *, struct drm_file *);
1084 :
1085 : /* hotplug support */
1086 : void drm_sysfs_hotplug_event(struct drm_device *);
1087 :
1088 : static inline int
1089 0 : drm_sysfs_connector_add(struct drm_connector *connector)
1090 : {
1091 0 : return 0;
1092 : }
1093 :
1094 : static inline void
1095 0 : drm_sysfs_connector_remove(struct drm_connector *connector)
1096 : {
1097 0 : }
1098 :
1099 : /* Graphics Execution Manager library functions (drm_gem.c) */
1100 : int drm_gem_init(struct drm_device *dev);
1101 : void drm_gem_destroy(struct drm_device *dev);
1102 : void drm_gem_object_release(struct drm_gem_object *obj);
1103 : void drm_gem_object_free(struct kref *kref);
1104 : int drm_gem_object_init(struct drm_device *dev,
1105 : struct drm_gem_object *obj, size_t size);
1106 : void drm_gem_private_object_init(struct drm_device *dev,
1107 : struct drm_gem_object *obj, size_t size);
1108 :
1109 : int drm_gem_handle_create_tail(struct drm_file *file_priv,
1110 : struct drm_gem_object *obj,
1111 : u32 *handlep);
1112 : int drm_gem_handle_create(struct drm_file *file_priv,
1113 : struct drm_gem_object *obj,
1114 : u32 *handlep);
1115 : int drm_gem_handle_delete(struct drm_file *filp, u32 handle);
1116 :
1117 : void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1118 : int drm_gem_create_mmap_offset(struct drm_gem_object *obj);
1119 :
1120 : struct drm_gem_object *drm_gem_object_lookup(struct drm_device *dev,
1121 : struct drm_file *filp,
1122 : u32 handle);
1123 : struct drm_gem_object *drm_gem_object_find(struct drm_file *, u32);
1124 : int drm_gem_close_ioctl(struct drm_device *dev, void *data,
1125 : struct drm_file *file_priv);
1126 : int drm_gem_flink_ioctl(struct drm_device *dev, void *data,
1127 : struct drm_file *file_priv);
1128 : int drm_gem_open_ioctl(struct drm_device *dev, void *data,
1129 : struct drm_file *file_priv);
1130 : void drm_gem_open(struct drm_device *dev, struct drm_file *file_private);
1131 : void drm_gem_release(struct drm_device *dev,struct drm_file *file_private);
1132 :
1133 : static __inline void
1134 0 : drm_gem_object_reference(struct drm_gem_object *obj)
1135 : {
1136 0 : kref_get(&obj->refcount);
1137 0 : }
1138 :
1139 : static __inline void
1140 0 : drm_gem_object_unreference(struct drm_gem_object *obj)
1141 : {
1142 0 : if (obj != NULL)
1143 0 : kref_put(&obj->refcount, drm_gem_object_free);
1144 0 : }
1145 :
1146 : static __inline void
1147 0 : drm_gem_object_unreference_unlocked(struct drm_gem_object *obj)
1148 : {
1149 0 : if (obj && !atomic_add_unless(&obj->refcount.refcount, -1, 1)) {
1150 0 : struct drm_device *dev = obj->dev;
1151 :
1152 0 : mutex_lock(&dev->struct_mutex);
1153 0 : if (likely(atomic_dec_and_test(&obj->refcount.refcount)))
1154 0 : drm_gem_object_free(&obj->refcount);
1155 0 : mutex_unlock(&dev->struct_mutex);
1156 0 : }
1157 0 : }
1158 :
1159 : int drm_gem_dumb_destroy(struct drm_file *file,
1160 : struct drm_device *dev,
1161 : uint32_t handle);
1162 :
1163 0 : static __inline__ int drm_core_check_feature(struct drm_device *dev,
1164 : int feature)
1165 : {
1166 0 : return ((dev->driver->driver_features & feature) ? 1 : 0);
1167 : }
1168 :
1169 : static inline bool drm_is_render_client(const struct drm_file *file_priv)
1170 : {
1171 : #ifdef notyet
1172 : return file_priv->minor->type == DRM_MINOR_RENDER;
1173 : #else
1174 : return 0;
1175 : #endif
1176 : }
1177 :
1178 0 : static inline bool drm_is_control_client(const struct drm_file *file_priv)
1179 : {
1180 : #ifdef notyet
1181 : return file_priv->minor->type == DRM_MINOR_CONTROL;
1182 : #else
1183 0 : return 0;
1184 : #endif
1185 : }
1186 :
1187 : static inline bool drm_is_primary_client(const struct drm_file *file_priv)
1188 : {
1189 : #ifdef notyet
1190 : return file_priv->minor->type == DRM_MINOR_LEGACY;
1191 : #else
1192 : return 1;
1193 : #endif
1194 : }
1195 :
1196 : static inline int drm_dev_to_irq(struct drm_device *dev)
1197 : {
1198 : return -1;
1199 : }
1200 :
1201 : #define DRM_PCIE_SPEED_25 1
1202 : #define DRM_PCIE_SPEED_50 2
1203 : #define DRM_PCIE_SPEED_80 4
1204 :
1205 : int drm_pcie_get_speed_cap_mask(struct drm_device *, u32 *);
1206 :
1207 : #endif /* __KERNEL__ */
1208 : #endif /* _DRM_P_H_ */
|