VirtualBox

source: vbox/trunk/src/VBox/Additions/solaris/DRM/include/drmP.h@ 54934

Last change on this file since 54934 was 33540, checked in by vboxsync, 14 years ago

*: spelling fixes, thanks Timeless!

  • Property svn:eol-style set to native
File size: 26.9 KB
Line 
1/*
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/*
36 * Copyright 2009-2010 Oracle Corporation
37 * All rights reserved.
38 * Use is subject to license terms.
39 */
40
41#ifndef _DRMP_H
42#define _DRMP_H
43
44#include <sys/types.h>
45#include <sys/conf.h>
46#include <sys/modctl.h>
47#include <sys/stat.h>
48#include <sys/file.h>
49#include <sys/cmn_err.h>
50#include <sys/varargs.h>
51#include <sys/pci.h>
52#include <sys/ddi.h>
53#include <sys/sunddi.h>
54#include <sys/sunldi.h>
55#include <sys/pmem.h>
56#include <sys/agpgart.h>
57#include <sys/time.h>
58#include "drm_atomic.h"
59#include "drm.h"
60#include "queue.h"
61#include "drm_linux_list.h"
62
63#ifndef __inline__
64#define __inline__ inline
65#endif
66
67#if !defined(__FUNCTION__)
68#if defined(C99)
69#define __FUNCTION__ __func__
70#else
71#define __FUNCTION__ " "
72#endif
73#endif
74
75/* DRM space units */
76#define DRM_PAGE_SHIFT PAGESHIFT
77#define DRM_PAGE_SIZE (1 << DRM_PAGE_SHIFT)
78#define DRM_PAGE_OFFSET (DRM_PAGE_SIZE - 1)
79#define DRM_PAGE_MASK ~(DRM_PAGE_SIZE - 1)
80#define DRM_MB2PAGES(x) ((x) << 8)
81#define DRM_PAGES2BYTES(x) ((x) << DRM_PAGE_SHIFT)
82#define DRM_BYTES2PAGES(x) ((x) >> DRM_PAGE_SHIFT)
83#define DRM_PAGES2KB(x) ((x) << 2)
84#define DRM_ALIGNED(offset) (((offset) & DRM_PAGE_OFFSET) == 0)
85
86#define PAGE_SHIFT DRM_PAGE_SHIFT
87#define PAGE_SIZE DRM_PAGE_SIZE
88
89#define DRM_MAX_INSTANCES 8
90#define DRM_DEVNODE "drm"
91#define DRM_UNOPENED 0
92#define DRM_OPENED 1
93
94#define DRM_HASH_SIZE 16 /* Size of key hash table */
95#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
96#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
97
98#define DRM_MEM_DMA 0
99#define DRM_MEM_SAREA 1
100#define DRM_MEM_DRIVER 2
101#define DRM_MEM_MAGIC 3
102#define DRM_MEM_IOCTLS 4
103#define DRM_MEM_MAPS 5
104#define DRM_MEM_BUFS 6
105#define DRM_MEM_SEGS 7
106#define DRM_MEM_PAGES 8
107#define DRM_MEM_FILES 9
108#define DRM_MEM_QUEUES 10
109#define DRM_MEM_CMDS 11
110#define DRM_MEM_MAPPINGS 12
111#define DRM_MEM_BUFLISTS 13
112#define DRM_MEM_DRMLISTS 14
113#define DRM_MEM_TOTALDRM 15
114#define DRM_MEM_BOUNDDRM 16
115#define DRM_MEM_CTXBITMAP 17
116#define DRM_MEM_STUB 18
117#define DRM_MEM_SGLISTS 19
118#define DRM_MEM_AGPLISTS 20
119#define DRM_MEM_CTXLIST 21
120#define DRM_MEM_MM 22
121#define DRM_MEM_HASHTAB 23
122#define DRM_MEM_OBJECTS 24
123
124#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
125#define DRM_MAP_HASH_OFFSET 0x10000000
126#define DRM_MAP_HASH_ORDER 12
127#define DRM_OBJECT_HASH_ORDER 12
128#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
129#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
130#define DRM_MM_INIT_MAX_PAGES 256
131
132
133/* Internal types and structures */
134#define DRM_ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
135#define DRM_MIN(a, b) ((a) < (b) ? (a) : (b))
136#define DRM_MAX(a, b) ((a) > (b) ? (a) : (b))
137
138#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
139
140#define __OS_HAS_AGP 1
141
142#define DRM_DEV_MOD (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
143#define DRM_DEV_UID 0
144#define DRM_DEV_GID 0
145
146#define DRM_CURRENTPID ddi_get_pid()
147#define DRM_SPINLOCK(l) mutex_enter(l)
148#define DRM_SPINUNLOCK(u) mutex_exit(u)
149#define DRM_SPINLOCK_ASSERT(l)
150#define DRM_LOCK() mutex_enter(&dev->dev_lock)
151#define DRM_UNLOCK() mutex_exit(&dev->dev_lock)
152#define DRM_LOCK_OWNED() ASSERT(mutex_owned(&dev->dev_lock))
153#define spin_lock_irqsave(l, flag) mutex_enter(l)
154#define spin_unlock_irqrestore(u, flag) mutex_exit(u)
155#define spin_lock(l) mutex_enter(l)
156#define spin_unlock(u) mutex_exit(u)
157
158#define DRM_UDELAY(sec) delay(drv_usectohz(sec *1000))
159#define DRM_MEMORYBARRIER()
160
161typedef struct drm_file drm_file_t;
162typedef struct drm_device drm_device_t;
163typedef struct drm_driver_info drm_driver_t;
164
165#define DRM_DEVICE drm_device_t *dev = dev1
166#define DRM_IOCTL_ARGS \
167 drm_device_t *dev1, intptr_t data, drm_file_t *fpriv, int mode
168
169#define DRM_COPYFROM_WITH_RETURN(dest, src, size) \
170 if (ddi_copyin(src, dest, size, 0)) \
171 return (EFAULT)
172
173#define DRM_COPYTO_WITH_RETURN(dest, src, size) \
174 if (ddi_copyout((src), (dest), (size), 0)) \
175 return (EFAULT)
176
177#define DRM_COPY_FROM_USER(dest, src, size) \
178 ddi_copyin((src), (dest), (size), 0) /* flag for src */
179
180#define DRM_COPY_TO_USER(dest, src, size) \
181 ddi_copyout((src), (dest), (size), 0) /* flags for dest */
182
183#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
184 ddi_copyin((arg2), (arg1), (arg3), 0)
185
186#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \
187 ddi_copyout((arg2), arg1, arg3, 0)
188
189#define DRM_READ8(map, offset) \
190 *(uint8_t *)((uintptr_t)((map)->dev_addr) + (offset))
191#define DRM_READ16(map, offset) \
192 *(uint16_t *)((uintptr_t)((map)->dev_addr) + (offset))
193#define DRM_READ32(map, offset) \
194 *(uint32_t *)((uintptr_t)((map)->dev_addr) + (offset))
195#define DRM_WRITE8(map, offset, val) \
196 *(uint8_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
197#define DRM_WRITE16(map, offset, val) \
198 *(uint16_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
199#define DRM_WRITE32(map, offset, val) \
200 *(uint32_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
201
202typedef struct drm_wait_queue {
203 kcondvar_t cv;
204 kmutex_t lock;
205}wait_queue_head_t;
206
207#define DRM_INIT_WAITQUEUE(q, pri) \
208{ \
209 mutex_init(&(q)->lock, NULL, MUTEX_DRIVER, pri); \
210 cv_init(&(q)->cv, NULL, CV_DRIVER, NULL); \
211}
212
213#define DRM_FINI_WAITQUEUE(q) \
214{ \
215 mutex_destroy(&(q)->lock); \
216 cv_destroy(&(q)->cv); \
217}
218
219#define DRM_WAKEUP(q) \
220{ \
221 mutex_enter(&(q)->lock); \
222 cv_broadcast(&(q)->cv); \
223 mutex_exit(&(q)->lock); \
224}
225
226#define jiffies ddi_get_lbolt()
227#define DRM_WAIT_ON(ret, q, timeout, condition) \
228mutex_enter(&(q)->lock); \
229while (!(condition)) { \
230 ret = cv_timedwait_sig(&(q)->cv, &(q)->lock, jiffies + timeout); \
231 if (ret == -1) { \
232 ret = EBUSY; \
233 break; \
234 } else if (ret == 0) { \
235 ret = EINTR; \
236 break; \
237 } else { \
238 ret = 0; \
239 } \
240} \
241mutex_exit(&(q)->lock);
242
243#define DRM_GETSAREA() \
244{ \
245 drm_local_map_t *map; \
246 DRM_SPINLOCK_ASSERT(&dev->dev_lock); \
247 TAILQ_FOREACH(map, &dev->maplist, link) { \
248 if (map->type == _DRM_SHM && \
249 map->flags & _DRM_CONTAINS_LOCK) { \
250 dev_priv->sarea = map; \
251 break; \
252 } \
253 } \
254}
255
256#define LOCK_TEST_WITH_RETURN(dev, fpriv) \
257 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
258 dev->lock.filp != fpriv) { \
259 DRM_ERROR("called without lock held"); \
260 return (EINVAL); \
261 }
262
263#define DRM_IRQ_ARGS caddr_t arg
264#define IRQ_HANDLED DDI_INTR_CLAIMED
265#define IRQ_NONE DDI_INTR_UNCLAIMED
266
267enum {
268 DRM_IS_NOT_AGP,
269 DRM_IS_AGP,
270 DRM_MIGHT_BE_AGP
271};
272
273/* Capabilities taken from src/sys/dev/pci/pcireg.h. */
274#ifndef PCIY_AGP
275#define PCIY_AGP 0x02
276#endif
277
278#ifndef PCIY_EXPRESS
279#define PCIY_EXPRESS 0x10
280#endif
281
282#define PAGE_ALIGN(addr) (((addr) + DRM_PAGE_SIZE - 1) & DRM_PAGE_MASK)
283#define DRM_SUSER(p) (crgetgid(p) == 0 || crgetuid(p) == 0)
284
285/*
286 * wait for 400 milliseconds
287 */
288#define DRM_HZ drv_usectohz(400000)
289
290typedef unsigned long dma_addr_t;
291typedef uint64_t u64;
292typedef uint32_t u32;
293typedef uint16_t u16;
294typedef uint8_t u8;
295typedef uint_t irqreturn_t;
296
297#define DRM_SUPPORT 1
298#define DRM_UNSUPPORT 0
299
300#define __OS_HAS_AGP 1
301
302#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
303#define offsetof(type, field) __offsetof(type, field)
304
305typedef struct drm_pci_id_list
306{
307 int vendor;
308 int device;
309 long driver_private;
310 char *name;
311} drm_pci_id_list_t;
312
313#define DRM_AUTH 0x1
314#define DRM_MASTER 0x2
315#define DRM_ROOT_ONLY 0x4
316typedef int drm_ioctl_t(DRM_IOCTL_ARGS);
317typedef struct drm_ioctl_desc {
318 int (*func)(DRM_IOCTL_ARGS);
319 int flags;
320} drm_ioctl_desc_t;
321
322typedef struct drm_magic_entry {
323 drm_magic_t magic;
324 struct drm_file *priv;
325 struct drm_magic_entry *next;
326} drm_magic_entry_t;
327
328typedef struct drm_magic_head {
329 struct drm_magic_entry *head;
330 struct drm_magic_entry *tail;
331} drm_magic_head_t;
332
333typedef struct drm_buf {
334 int idx; /* Index into master buflist */
335 int total; /* Buffer size */
336 int order; /* log-base-2(total) */
337 int used; /* Amount of buffer in use (for DMA) */
338 unsigned long offset; /* Byte offset (used internally) */
339 void *address; /* Address of buffer */
340 unsigned long bus_address; /* Bus address of buffer */
341 struct drm_buf *next; /* Kernel-only: used for free list */
342 volatile int pending; /* On hardware DMA queue */
343 drm_file_t *filp;
344 /* Uniq. identifier of holding process */
345 int context; /* Kernel queue for this buffer */
346 enum {
347 DRM_LIST_NONE = 0,
348 DRM_LIST_FREE = 1,
349 DRM_LIST_WAIT = 2,
350 DRM_LIST_PEND = 3,
351 DRM_LIST_PRIO = 4,
352 DRM_LIST_RECLAIM = 5
353 } list; /* Which list we're on */
354
355 int dev_priv_size; /* Size of buffer private storage */
356 void *dev_private; /* Per-buffer private storage */
357} drm_buf_t;
358
359typedef struct drm_freelist {
360 int initialized; /* Freelist in use */
361 uint32_t count; /* Number of free buffers */
362 drm_buf_t *next; /* End pointer */
363
364 int low_mark; /* Low water mark */
365 int high_mark; /* High water mark */
366} drm_freelist_t;
367
368typedef struct drm_buf_entry {
369 int buf_size;
370 int buf_count;
371 drm_buf_t *buflist;
372 int seg_count;
373 int page_order;
374
375 uint32_t *seglist;
376 unsigned long *seglist_bus;
377
378 drm_freelist_t freelist;
379} drm_buf_entry_t;
380
381typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
382struct drm_file {
383 TAILQ_ENTRY(drm_file) link;
384 int authenticated;
385 int master;
386 int minor;
387 pid_t pid;
388 uid_t uid;
389 int refs;
390 drm_magic_t magic;
391 unsigned long ioctl_count;
392 void *driver_priv;
393};
394
395typedef struct drm_lock_data {
396 drm_hw_lock_t *hw_lock; /* Hardware lock */
397 drm_file_t *filp;
398 /* Uniq. identifier of holding process */
399 kcondvar_t lock_cv; /* lock queue - SOLARIS Specific */
400 kmutex_t lock_mutex; /* lock - SOLARIS Specific */
401 unsigned long lock_time; /* Time of last lock in jiffies */
402} drm_lock_data_t;
403
404/*
405 * This structure, in drm_device_t, is always initialized while the device
406 * is open. dev->dma_lock protects the incrementing of dev->buf_use, which
407 * when set marks that no further bufs may be allocated until device teardown
408 * occurs (when the last open of the device has closed). The high/low
409 * watermarks of bufs are only touched by the X Server, and thus not
410 * concurrently accessed, so no locking is needed.
411 */
412typedef struct drm_device_dma {
413 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
414 int buf_count;
415 drm_buf_t **buflist; /* Vector of pointers info bufs */
416 int seg_count;
417 int page_count;
418 unsigned long *pagelist;
419 unsigned long byte_count;
420 enum {
421 _DRM_DMA_USE_AGP = 0x01,
422 _DRM_DMA_USE_SG = 0x02
423 } flags;
424} drm_device_dma_t;
425
426typedef struct drm_agp_mem {
427 void *handle;
428 unsigned long bound; /* address */
429 int pages;
430 caddr_t phys_addr;
431 struct drm_agp_mem *prev;
432 struct drm_agp_mem *next;
433} drm_agp_mem_t;
434
435typedef struct drm_agp_head {
436 agp_info_t agp_info;
437 const char *chipset;
438 drm_agp_mem_t *memory;
439 unsigned long mode;
440 int enabled;
441 int acquired;
442 unsigned long base;
443 int mtrr;
444 int cant_use_aperture;
445 unsigned long page_mask;
446 ldi_ident_t agpgart_li;
447 ldi_handle_t agpgart_lh;
448} drm_agp_head_t;
449
450
451typedef struct drm_dma_handle {
452 ddi_dma_handle_t dma_hdl;
453 ddi_acc_handle_t acc_hdl;
454 ddi_dma_cookie_t cookie;
455 uint_t cookie_num;
456 uintptr_t vaddr; /* virtual addr */
457 uintptr_t paddr; /* physical addr */
458 size_t real_sz; /* real size of memory */
459} drm_dma_handle_t;
460
461typedef struct drm_sg_mem {
462 unsigned long handle;
463 void *virtual;
464 int pages;
465 dma_addr_t *busaddr;
466 ddi_umem_cookie_t *umem_cookie;
467 drm_dma_handle_t *dmah_sg;
468 drm_dma_handle_t *dmah_gart; /* Handle to PCI memory */
469} drm_sg_mem_t;
470
471typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t;
472
473/* BEGIN CSTYLED */
474typedef struct drm_local_map {
475 unsigned long offset; /* Physical address (0 for SAREA) */
476 unsigned long size; /* Physical size (bytes) */
477 drm_map_type_t type; /* Type of memory mapped */
478 drm_map_flags_t flags; /* Flags */
479 void *handle; /* User-space: "Handle" to pass to mmap */
480 /* Kernel-space: kernel-virtual address */
481 int mtrr; /* Boolean: MTRR used */
482 /* Private data */
483 int rid; /* PCI resource ID for bus_space */
484 int kernel_owned; /* Boolean: 1= initmapped, 0= addmapped */
485 caddr_t dev_addr; /* base device address */
486 ddi_acc_handle_t dev_handle; /* The data access handle */
487 ddi_umem_cookie_t drm_umem_cookie; /* For SAREA alloc and free */
488 TAILQ_ENTRY(drm_local_map) link;
489} drm_local_map_t;
490/* END CSTYLED */
491
492typedef TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig) drm_vbl_sig_list_t;
493typedef struct drm_vbl_sig {
494 TAILQ_ENTRY(drm_vbl_sig) link;
495 unsigned int sequence;
496 int signo;
497 int pid;
498} drm_vbl_sig_t;
499
500
501/* used for clone device */
502typedef TAILQ_HEAD(drm_cminor_list, drm_cminor) drm_cminor_list_t;
503typedef struct drm_cminor {
504 TAILQ_ENTRY(drm_cminor) link;
505 drm_file_t *fpriv;
506 int minor;
507} drm_cminor_t;
508
509/* location of GART table */
510#define DRM_ATI_GART_MAIN 1
511#define DRM_ATI_GART_FB 2
512
513typedef struct ati_pcigart_info {
514 int gart_table_location;
515 int is_pcie;
516 void *addr;
517 dma_addr_t bus_addr;
518 drm_local_map_t mapping;
519} drm_ati_pcigart_info;
520
521/* DRM device structure */
522struct drm_device;
523struct drm_driver_info {
524 int (*load)(struct drm_device *, unsigned long);
525 int (*firstopen)(struct drm_device *);
526 int (*open)(struct drm_device *, drm_file_t *);
527 void (*preclose)(struct drm_device *, drm_file_t *);
528 void (*postclose)(struct drm_device *, drm_file_t *);
529 void (*lastclose)(struct drm_device *);
530 int (*unload)(struct drm_device *);
531 void (*reclaim_buffers_locked)(struct drm_device *, drm_file_t *);
532 int (*presetup)(struct drm_device *);
533 int (*postsetup)(struct drm_device *);
534 int (*open_helper)(struct drm_device *, drm_file_t *);
535 void (*free_filp_priv)(struct drm_device *, drm_file_t *);
536 void (*release)(struct drm_device *, void *);
537 int (*dma_ioctl)(DRM_IOCTL_ARGS);
538 void (*dma_ready)(struct drm_device *);
539 int (*dma_quiescent)(struct drm_device *);
540 int (*dma_flush_block_and_flush)(struct drm_device *,
541 int, drm_lock_flags_t);
542 int (*dma_flush_unblock)(struct drm_device *, int,
543 drm_lock_flags_t);
544 int (*context_ctor)(struct drm_device *, int);
545 int (*context_dtor)(struct drm_device *, int);
546 int (*kernel_context_switch)(struct drm_device *, int, int);
547 int (*kernel_context_switch_unlock)(struct drm_device *);
548 int (*device_is_agp) (struct drm_device *);
549 int (*irq_preinstall)(struct drm_device *);
550 void (*irq_postinstall)(struct drm_device *);
551 void (*irq_uninstall)(struct drm_device *dev);
552 uint_t (*irq_handler)(DRM_IRQ_ARGS);
553 int (*vblank_wait)(struct drm_device *, unsigned int *);
554 int (*vblank_wait2)(struct drm_device *, unsigned int *);
555 /* added for intel minimized vblank */
556 u32 (*get_vblank_counter)(struct drm_device *dev, int crtc);
557 int (*enable_vblank)(struct drm_device *dev, int crtc);
558 void (*disable_vblank)(struct drm_device *dev, int crtc);
559
560 drm_ioctl_desc_t *driver_ioctls;
561 int max_driver_ioctl;
562
563 int buf_priv_size;
564 int driver_major;
565 int driver_minor;
566 int driver_patchlevel;
567 const char *driver_name; /* Simple driver name */
568 const char *driver_desc; /* Longer driver name */
569 const char *driver_date; /* Date of last major changes. */
570
571 unsigned use_agp :1;
572 unsigned require_agp :1;
573 unsigned use_sg :1;
574 unsigned use_dma :1;
575 unsigned use_pci_dma :1;
576 unsigned use_dma_queue :1;
577 unsigned use_irq :1;
578 unsigned use_vbl_irq :1;
579 unsigned use_vbl_irq2 :1;
580 unsigned use_mtrr :1;
581};
582
583/*
584 * hardware-specific code needs to initialize mutexes which
585 * can be used in interrupt context, so they need to know
586 * the interrupt priority. Interrupt cookie in drm_device
587 * structure is the intr_block field.
588 */
589#define DRM_INTR_PRI(dev) \
590 DDI_INTR_PRI((dev)->intr_block)
591
592struct drm_device {
593 drm_driver_t *driver;
594 drm_cminor_list_t minordevs;
595 dev_info_t *dip;
596 void *drm_handle;
597 int drm_supported;
598 const char *desc; /* current driver description */
599 kmutex_t *irq_mutex;
600 kcondvar_t *irq_cv;
601
602 ddi_iblock_cookie_t intr_block;
603 uint32_t pci_device; /* PCI device id */
604 uint32_t pci_vendor;
605 char *unique; /* Unique identifier: e.g., busid */
606 int unique_len; /* Length of unique field */
607 int if_version; /* Highest interface version set */
608 int flags; /* Flags to open(2) */
609
610 /* Locks */
611 kmutex_t vbl_lock; /* protects vblank operations */
612 kmutex_t dma_lock; /* protects dev->dma */
613 kmutex_t irq_lock; /* protects irq condition checks */
614 kmutex_t dev_lock; /* protects everything else */
615 drm_lock_data_t lock; /* Information on hardware lock */
616
617 /* Usage Counters */
618 int open_count; /* Outstanding files open */
619 int buf_use; /* Buffers in use -- cannot alloc */
620
621 /* Performance counters */
622 unsigned long counters;
623 drm_stat_type_t types[15];
624 uint32_t counts[15];
625
626 /* Authentication */
627 drm_file_list_t files;
628 drm_magic_head_t magiclist[DRM_HASH_SIZE];
629
630 /* Linked list of mappable regions. Protected by dev_lock */
631 drm_map_list_t maplist;
632
633 drm_local_map_t **context_sareas;
634 int max_context;
635
636 /* DMA queues (contexts) */
637 drm_device_dma_t *dma; /* Optional pointer for DMA support */
638
639 /* Context support */
640 int irq; /* Interrupt used by board */
641 int irq_enabled; /* True if the irq handler is enabled */
642 int pci_domain;
643 int pci_bus;
644 int pci_slot;
645 int pci_func;
646 atomic_t context_flag; /* Context swapping flag */
647 int last_context; /* Last current context */
648
649 /* Only used for Radeon */
650 atomic_t vbl_received;
651 atomic_t vbl_received2;
652
653 drm_vbl_sig_list_t vbl_sig_list;
654 drm_vbl_sig_list_t vbl_sig_list2;
655
656 wait_queue_head_t vbl_queue; /* vbl wait channel */
657 /* vbl wait channel array */
658 wait_queue_head_t *vbl_queues;
659
660 /* number of VBLANK interrupts */
661 /* (driver must alloc the right number of counters) */
662 atomic_t *_vblank_count;
663 /* signal list to send on VBLANK */
664 struct drm_vbl_sig_list *vbl_sigs;
665
666 /* number of signals pending on all crtcs */
667 atomic_t vbl_signal_pending;
668 /* number of users of vblank interrupts per crtc */
669 atomic_t *vblank_refcount;
670 /* protected by dev->vbl_lock, used for wraparound handling */
671 u32 *last_vblank;
672 /* so we don't call enable more than */
673 atomic_t *vblank_enabled;
674 /* for compensation of spurious wraparounds */
675 u32 *vblank_premodeset;
676 /* Don't wait while crtc is likely disabled */
677 int *vblank_suspend;
678 /* size of vblank counter register */
679 u32 max_vblank_count;
680 int num_crtcs;
681 kmutex_t tasklet_lock;
682 void (*locked_tasklet_func)(struct drm_device *dev);
683
684 pid_t buf_pgid;
685 drm_agp_head_t *agp;
686 drm_sg_mem_t *sg; /* Scatter gather memory */
687 uint32_t *ctx_bitmap;
688 void *dev_private;
689 unsigned int agp_buffer_token;
690 drm_local_map_t *agp_buffer_map;
691
692 kstat_t *asoft_ksp; /* kstat support */
693
694 /* name Drawable information */
695 kmutex_t drw_lock;
696 unsigned int drw_bitfield_length;
697 u32 *drw_bitfield;
698 unsigned int drw_info_length;
699 drm_drawable_info_t **drw_info;
700 /*
701 * Saving S3 context
702 */
703 void *s3_private;
704};
705
706/* Memory management support (drm_memory.c) */
707void drm_mem_init(void);
708void drm_mem_uninit(void);
709void *drm_alloc(size_t, int);
710void *drm_calloc(size_t, size_t, int);
711void *drm_realloc(void *, size_t, size_t, int);
712void drm_free(void *, size_t, int);
713int drm_ioremap(drm_device_t *, drm_local_map_t *);
714void drm_ioremapfree(drm_local_map_t *);
715
716void drm_core_ioremap(struct drm_local_map *, struct drm_device *);
717void drm_core_ioremapfree(struct drm_local_map *, struct drm_device *);
718
719void drm_pci_free(drm_device_t *, drm_dma_handle_t *);
720void *drm_pci_alloc(drm_device_t *, size_t, size_t, dma_addr_t, int);
721
722struct drm_local_map *drm_core_findmap(struct drm_device *, unsigned long);
723
724int drm_context_switch(drm_device_t *, int, int);
725int drm_context_switch_complete(drm_device_t *, int);
726int drm_ctxbitmap_init(drm_device_t *);
727void drm_ctxbitmap_cleanup(drm_device_t *);
728void drm_ctxbitmap_free(drm_device_t *, int);
729int drm_ctxbitmap_next(drm_device_t *);
730
731/* Locking IOCTL support (drm_lock.c) */
732int drm_lock_take(drm_lock_data_t *, unsigned int);
733int drm_lock_transfer(drm_device_t *,
734 drm_lock_data_t *, unsigned int);
735int drm_lock_free(drm_device_t *,
736 volatile unsigned int *, unsigned int);
737
738/* Buffer management support (drm_bufs.c) */
739unsigned long drm_get_resource_start(drm_device_t *, unsigned int);
740unsigned long drm_get_resource_len(drm_device_t *, unsigned int);
741int drm_initmap(drm_device_t *, unsigned long, unsigned long,
742 unsigned int, int, int);
743void drm_rmmap(drm_device_t *, drm_local_map_t *);
744int drm_addmap(drm_device_t *, unsigned long, unsigned long,
745 drm_map_type_t, drm_map_flags_t, drm_local_map_t **);
746int drm_order(unsigned long);
747
748/* DMA support (drm_dma.c) */
749int drm_dma_setup(drm_device_t *);
750void drm_dma_takedown(drm_device_t *);
751void drm_free_buffer(drm_device_t *, drm_buf_t *);
752void drm_reclaim_buffers(drm_device_t *, drm_file_t *);
753#define drm_core_reclaim_buffers drm_reclaim_buffers
754
755/* IRQ support (drm_irq.c) */
756int drm_irq_install(drm_device_t *);
757int drm_irq_uninstall(drm_device_t *);
758uint_t drm_irq_handler(DRM_IRQ_ARGS);
759void drm_driver_irq_preinstall(drm_device_t *);
760void drm_driver_irq_postinstall(drm_device_t *);
761void drm_driver_irq_uninstall(drm_device_t *);
762int drm_vblank_wait(drm_device_t *, unsigned int *);
763void drm_vbl_send_signals(drm_device_t *);
764void drm_handle_vblank(struct drm_device *dev, int crtc);
765u32 drm_vblank_count(struct drm_device *dev, int crtc);
766int drm_vblank_get(struct drm_device *dev, int crtc);
767void drm_vblank_put(struct drm_device *dev, int crtc);
768int drm_vblank_init(struct drm_device *dev, int num_crtcs);
769void drm_locked_tasklet(drm_device_t *, void(*func)(drm_device_t *));
770
771/* AGP/GART support (drm_agpsupport.c) */
772int drm_device_is_agp(drm_device_t *);
773int drm_device_is_pcie(drm_device_t *);
774drm_agp_head_t *drm_agp_init(drm_device_t *);
775void drm_agp_fini(drm_device_t *);
776int drm_agp_do_release(drm_device_t *);
777void *drm_agp_allocate_memory(size_t, uint32_t);
778int drm_agp_free_memory(void *);
779int drm_agp_bind_memory(unsigned int, uint32_t, drm_device_t *);
780int drm_agp_unbind_memory(unsigned long, drm_device_t *);
781
782/* kstat support (drm_kstats.c) */
783int drm_init_kstats(drm_device_t *);
784void drm_fini_kstats(drm_device_t *);
785
786/* Scatter Gather Support (drm_scatter.c) */
787void drm_sg_cleanup(drm_device_t *, drm_sg_mem_t *);
788
789/* ATI PCIGART support (ati_pcigart.c) */
790int drm_ati_pcigart_init(drm_device_t *, drm_ati_pcigart_info *);
791int drm_ati_pcigart_cleanup(drm_device_t *, drm_ati_pcigart_info *);
792
793/* Locking IOCTL support (drm_drv.c) */
794int drm_lock(DRM_IOCTL_ARGS);
795int drm_unlock(DRM_IOCTL_ARGS);
796int drm_version(DRM_IOCTL_ARGS);
797int drm_setversion(DRM_IOCTL_ARGS);
798
799/* Misc. IOCTL support (drm_ioctl.c) */
800int drm_irq_by_busid(DRM_IOCTL_ARGS);
801int drm_getunique(DRM_IOCTL_ARGS);
802int drm_setunique(DRM_IOCTL_ARGS);
803int drm_getmap(DRM_IOCTL_ARGS);
804int drm_getclient(DRM_IOCTL_ARGS);
805int drm_getstats(DRM_IOCTL_ARGS);
806int drm_noop(DRM_IOCTL_ARGS);
807
808/* Context IOCTL support (drm_context.c) */
809int drm_resctx(DRM_IOCTL_ARGS);
810int drm_addctx(DRM_IOCTL_ARGS);
811int drm_modctx(DRM_IOCTL_ARGS);
812int drm_getctx(DRM_IOCTL_ARGS);
813int drm_switchctx(DRM_IOCTL_ARGS);
814int drm_newctx(DRM_IOCTL_ARGS);
815int drm_rmctx(DRM_IOCTL_ARGS);
816int drm_setsareactx(DRM_IOCTL_ARGS);
817int drm_getsareactx(DRM_IOCTL_ARGS);
818
819/* Drawable IOCTL support (drm_drawable.c) */
820int drm_adddraw(DRM_IOCTL_ARGS);
821int drm_rmdraw(DRM_IOCTL_ARGS);
822int drm_update_draw(DRM_IOCTL_ARGS);
823
824/* Authentication IOCTL support (drm_auth.c) */
825int drm_getmagic(DRM_IOCTL_ARGS);
826int drm_authmagic(DRM_IOCTL_ARGS);
827int drm_remove_magic(drm_device_t *, drm_magic_t);
828drm_file_t *drm_find_file(drm_device_t *, drm_magic_t);
829/* Buffer management support (drm_bufs.c) */
830int drm_addmap_ioctl(DRM_IOCTL_ARGS);
831int drm_rmmap_ioctl(DRM_IOCTL_ARGS);
832int drm_addbufs_ioctl(DRM_IOCTL_ARGS);
833int drm_infobufs(DRM_IOCTL_ARGS);
834int drm_markbufs(DRM_IOCTL_ARGS);
835int drm_freebufs(DRM_IOCTL_ARGS);
836int drm_mapbufs(DRM_IOCTL_ARGS);
837
838/* DMA support (drm_dma.c) */
839int drm_dma(DRM_IOCTL_ARGS);
840
841/* IRQ support (drm_irq.c) */
842int drm_control(DRM_IOCTL_ARGS);
843int drm_wait_vblank(DRM_IOCTL_ARGS);
844
845/* AGP/GART support (drm_agpsupport.c) */
846int drm_agp_acquire(DRM_IOCTL_ARGS);
847int drm_agp_release(DRM_IOCTL_ARGS);
848int drm_agp_enable(DRM_IOCTL_ARGS);
849int drm_agp_info(DRM_IOCTL_ARGS);
850int drm_agp_alloc(DRM_IOCTL_ARGS);
851int drm_agp_free(DRM_IOCTL_ARGS);
852int drm_agp_unbind(DRM_IOCTL_ARGS);
853int drm_agp_bind(DRM_IOCTL_ARGS);
854
855/* Scatter Gather Support (drm_scatter.c) */
856int drm_sg_alloc(DRM_IOCTL_ARGS);
857int drm_sg_free(DRM_IOCTL_ARGS);
858
859extern int drm_debug_flag;
860
861
862/* We add function to support DRM_DEBUG,DRM_ERROR,DRM_INFO */
863extern void drm_debug(const char *fmt, ...);
864extern void drm_error(const char *fmt, ...);
865extern void drm_info(const char *fmt, ...);
866
867#ifdef DEBUG
868#define DRM_DEBUG if (drm_debug_flag >= 2) drm_debug
869#define DRM_INFO if (drm_debug_flag >= 1) drm_info
870#else
871#define DRM_DEBUG(...)
872#define DRM_INFO(...)
873#endif
874
875#define DRM_ERROR drm_error
876
877
878#define MAX_INSTNUMS 16
879
880extern int drm_dev_to_instance(dev_t);
881extern int drm_dev_to_minor(dev_t);
882extern void *drm_supp_register(dev_info_t *, drm_device_t *);
883extern int drm_supp_unregister(void *);
884
885extern int drm_open(drm_device_t *, drm_cminor_t *, int, int, cred_t *);
886extern int drm_close(drm_device_t *, int, int, int, cred_t *);
887extern int drm_attach(drm_device_t *);
888extern int drm_detach(drm_device_t *);
889extern int drm_probe(drm_device_t *, drm_pci_id_list_t *);
890
891extern int drm_pci_init(drm_device_t *);
892extern void drm_pci_end(drm_device_t *);
893extern int pci_get_info(drm_device_t *, int *, int *, int *);
894extern int pci_get_irq(drm_device_t *);
895extern int pci_get_vendor(drm_device_t *);
896extern int pci_get_device(drm_device_t *);
897
898extern struct drm_drawable_info *drm_get_drawable_info(drm_device_t *,
899 drm_drawable_t);
900/* File Operations helpers (drm_fops.c) */
901extern drm_file_t *drm_find_file_by_proc(drm_device_t *, cred_t *);
902extern drm_cminor_t *drm_find_file_by_minor(drm_device_t *, int);
903extern int drm_open_helper(drm_device_t *, drm_cminor_t *, int, int,
904 cred_t *);
905
906#endif /* _DRMP_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette