Deleted Added
full compact
drmP.h (254848) drmP.h (254858)
1/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
2 * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
1/**
2 * \file drmP.h
3 * Private header for Direct Rendering Manager
4 *
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 * \author Gareth Hughes <gareth@valinux.com>
3 */
7 */
4/*-
8
9/*
5 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
6 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12 * Copyright (c) 2009-2010, Code Aurora Forum.
7 * All rights reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:

--- 4 unchanged lines hidden (view full) ---

19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
13 * All rights reserved.
14 *
15 * Permission is hereby granted, free of charge, to any person obtaining a
16 * copy of this software and associated documentation files (the "Software"),
17 * to deal in the Software without restriction, including without limitation
18 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 * and/or sell copies of the Software, and to permit persons to whom the
20 * Software is furnished to do so, subject to the following conditions:

--- 4 unchanged lines hidden (view full) ---

25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
29 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
30 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
31 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
32 * OTHER DEALINGS IN THE SOFTWARE.
27 *
28 * Authors:
29 * Rickard E. (Rik) Faith <faith@valinux.com>
30 * Gareth Hughes <gareth@valinux.com>
31 *
32 */
33
34#include <sys/cdefs.h>
33 */
34
35#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/dev/drm2/drmP.h 254848 2013-08-25 11:34:37Z dumbbell $");
36__FBSDID("$FreeBSD: head/sys/dev/drm2/drmP.h 254858 2013-08-25 14:27:14Z dumbbell $");
36
37#ifndef _DRM_P_H_
38#define _DRM_P_H_
39
40#if defined(_KERNEL) || defined(__KERNEL__)
41
37
38#ifndef _DRM_P_H_
39#define _DRM_P_H_
40
41#if defined(_KERNEL) || defined(__KERNEL__)
42
42struct drm_device;
43struct drm_file;
44
45#include <sys/param.h>
46#include <sys/queue.h>
47#include <sys/malloc.h>
48#include <sys/kernel.h>
49#include <sys/ktr.h>
50#include <sys/module.h>
51#include <sys/systm.h>
52#include <sys/conf.h>

--- 41 unchanged lines hidden (view full) ---

94#include <sys/agpio.h>
95#include <sys/mutex.h>
96#include <dev/pci/pcivar.h>
97#include <dev/pci/pcireg.h>
98#include <sys/selinfo.h>
99#include <sys/bus.h>
100
101#include <dev/drm2/drm.h>
43#include <sys/param.h>
44#include <sys/queue.h>
45#include <sys/malloc.h>
46#include <sys/kernel.h>
47#include <sys/ktr.h>
48#include <sys/module.h>
49#include <sys/systm.h>
50#include <sys/conf.h>

--- 41 unchanged lines hidden (view full) ---

92#include <sys/agpio.h>
93#include <sys/mutex.h>
94#include <dev/pci/pcivar.h>
95#include <dev/pci/pcireg.h>
96#include <sys/selinfo.h>
97#include <sys/bus.h>
98
99#include <dev/drm2/drm.h>
100#include <dev/drm2/drm_sarea.h>
101
102#include <dev/drm2/drm_atomic.h>
103#include <dev/drm2/drm_internal.h>
104#include <dev/drm2/drm_linux_list.h>
105#include <dev/drm2/drm_gem_names.h>
102#include <dev/drm2/drm_atomic.h>
103#include <dev/drm2/drm_internal.h>
104#include <dev/drm2/drm_linux_list.h>
105#include <dev/drm2/drm_gem_names.h>
106#include <dev/drm2/drm_mm.h>
106
107struct drm_file;
108struct drm_device;
109
110#include <dev/drm2/drm_os_freebsd.h>
107#include <dev/drm2/drm_hashtab.h>
111#include <dev/drm2/drm_hashtab.h>
112#include <dev/drm2/drm_mm.h>
108
109#include "opt_compat.h"
110#include "opt_drm.h"
111#ifdef DRM_DEBUG
112#undef DRM_DEBUG
113#define DRM_DEBUG_DEFAULT_ON 1
114#endif /* DRM_DEBUG */
115
116#define DRM_DEBUGBITS_DEBUG 0x1
117#define DRM_DEBUGBITS_KMS 0x2
118#define DRM_DEBUGBITS_FAILED_IOCTL 0x4
119
120#undef DRM_LINUX
121#define DRM_LINUX 0
122
113
114#include "opt_compat.h"
115#include "opt_drm.h"
116#ifdef DRM_DEBUG
117#undef DRM_DEBUG
118#define DRM_DEBUG_DEFAULT_ON 1
119#endif /* DRM_DEBUG */
120
121#define DRM_DEBUGBITS_DEBUG 0x1
122#define DRM_DEBUGBITS_KMS 0x2
123#define DRM_DEBUGBITS_FAILED_IOCTL 0x4
124
125#undef DRM_LINUX
126#define DRM_LINUX 0
127
128/***********************************************************************/
129/** \name DRM template customization defaults */
130/*@{*/
131
123/* driver capabilities and requirements mask */
124#define DRIVER_USE_AGP 0x1
125#define DRIVER_REQUIRE_AGP 0x2
126#define DRIVER_USE_MTRR 0x4
127#define DRIVER_PCI_DMA 0x8
128#define DRIVER_SG 0x10
129#define DRIVER_HAVE_DMA 0x20
130#define DRIVER_HAVE_IRQ 0x40
131#define DRIVER_IRQ_SHARED 0x80
132#define DRIVER_IRQ_VBL 0x100
133#define DRIVER_DMA_QUEUE 0x200
134#define DRIVER_FB_DMA 0x400
135#define DRIVER_IRQ_VBL2 0x800
136#define DRIVER_GEM 0x1000
137#define DRIVER_MODESET 0x2000
132/* driver capabilities and requirements mask */
133#define DRIVER_USE_AGP 0x1
134#define DRIVER_REQUIRE_AGP 0x2
135#define DRIVER_USE_MTRR 0x4
136#define DRIVER_PCI_DMA 0x8
137#define DRIVER_SG 0x10
138#define DRIVER_HAVE_DMA 0x20
139#define DRIVER_HAVE_IRQ 0x40
140#define DRIVER_IRQ_SHARED 0x80
141#define DRIVER_IRQ_VBL 0x100
142#define DRIVER_DMA_QUEUE 0x200
143#define DRIVER_FB_DMA 0x400
144#define DRIVER_IRQ_VBL2 0x800
145#define DRIVER_GEM 0x1000
146#define DRIVER_MODESET 0x2000
138#define DRIVER_USE_PLATFORM_DEVICE 0x4000
139#define DRIVER_LOCKLESS_IRQ 0x8000
147#define DRIVER_PRIME 0x4000
148#define DRIVER_LOCKLESS_IRQ 0x8000
140
141
142#define DRM_HASH_SIZE 16 /* Size of key hash table */
143#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
144#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
145
146#define DRM_GEM_MAPPING_MASK (3ULL << 62)
147#define DRM_GEM_MAPPING_KEY (2ULL << 62) /* Non-canonical address form */

--- 24 unchanged lines hidden (view full) ---

172MALLOC_DECLARE(DRM_MEM_MM);
173MALLOC_DECLARE(DRM_MEM_HASHTAB);
174MALLOC_DECLARE(DRM_MEM_KMS);
175
176SYSCTL_DECL(_hw_drm);
177
178#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
179
149
150
151#define DRM_HASH_SIZE 16 /* Size of key hash table */
152#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
153#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
154
155#define DRM_GEM_MAPPING_MASK (3ULL << 62)
156#define DRM_GEM_MAPPING_KEY (2ULL << 62) /* Non-canonical address form */

--- 24 unchanged lines hidden (view full) ---

181MALLOC_DECLARE(DRM_MEM_MM);
182MALLOC_DECLARE(DRM_MEM_HASHTAB);
183MALLOC_DECLARE(DRM_MEM_KMS);
184
185SYSCTL_DECL(_hw_drm);
186
187#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
188
180 /* Internal types and structures */
189/***********************************************************************/
190/** \name Internal types and structures */
191/*@{*/
192
181#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
182#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
183#define DRM_MAX(a,b) ((a)>(b)?(a):(b))
184
185#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
186
187#define __OS_HAS_AGP 1
188

--- 34 unchanged lines hidden (view full) ---

223
224#define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS)
225
226#define DRM_IRQ_ARGS void *arg
227typedef void irqreturn_t;
228#define IRQ_HANDLED /* nothing */
229#define IRQ_NONE /* nothing */
230
193#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
194#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
195#define DRM_MAX(a,b) ((a)>(b)?(a):(b))
196
197#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
198
199#define __OS_HAS_AGP 1
200

--- 34 unchanged lines hidden (view full) ---

235
236#define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS)
237
238#define DRM_IRQ_ARGS void *arg
239typedef void irqreturn_t;
240#define IRQ_HANDLED /* nothing */
241#define IRQ_NONE /* nothing */
242
231#define unlikely(x) __builtin_expect(!!(x), 0)
232#define likely(x) __builtin_expect(!!(x), 1)
233#define container_of(ptr, type, member) ({ \
234 __typeof( ((type *)0)->member ) *__mptr = (ptr); \
235 (type *)( (char *)__mptr - offsetof(type,member) );})
236
237enum {
238 DRM_IS_NOT_AGP,
239 DRM_IS_AGP,
240 DRM_MIGHT_BE_AGP
241};
242#define DRM_AGP_MEM struct agp_memory_info
243
244#define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1)

--- 5 unchanged lines hidden (view full) ---

250#define DRM_MTRR_WC MDF_WRITECOMBINE
251#define jiffies ticks
252#define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / hz)
253#define msecs_to_jiffies(x) (((int64_t)(x)) * hz / 1000)
254#define time_after(a,b) ((long)(b) - (long)(a) < 0)
255#define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0)
256#define drm_msleep(x, msg) pause((msg), ((int64_t)(x)) * hz / 1000)
257
243enum {
244 DRM_IS_NOT_AGP,
245 DRM_IS_AGP,
246 DRM_MIGHT_BE_AGP
247};
248#define DRM_AGP_MEM struct agp_memory_info
249
250#define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1)

--- 5 unchanged lines hidden (view full) ---

256#define DRM_MTRR_WC MDF_WRITECOMBINE
257#define jiffies ticks
258#define jiffies_to_msecs(x) (((int64_t)(x)) * 1000 / hz)
259#define msecs_to_jiffies(x) (((int64_t)(x)) * hz / 1000)
260#define time_after(a,b) ((long)(b) - (long)(a) < 0)
261#define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0)
262#define drm_msleep(x, msg) pause((msg), ((int64_t)(x)) * hz / 1000)
263
258typedef vm_paddr_t dma_addr_t;
259typedef uint64_t u64;
260typedef uint32_t u32;
261typedef uint16_t u16;
262typedef uint8_t u8;
263typedef int64_t s64;
264typedef int32_t s32;
265typedef int16_t s16;
266typedef int8_t s8;
267
268/* DRM_READMEMORYBARRIER() prevents reordering of reads.
269 * DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
270 * DRM_MEMORYBARRIER() prevents reordering of reads and writes.
271 */
272#define DRM_READMEMORYBARRIER() rmb()
273#define DRM_WRITEMEMORYBARRIER() wmb()
274#define DRM_MEMORYBARRIER() mb()
275

--- 31 unchanged lines hidden (view full) ---

307 copyin(user, kern, size)
308#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
309 copyin(arg2, arg1, arg3)
310#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \
311 copyout(arg2, arg1, arg3)
312#define DRM_GET_USER_UNCHECKED(val, uaddr) \
313 ((val) = fuword32(uaddr), 0)
314
264/* DRM_READMEMORYBARRIER() prevents reordering of reads.
265 * DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
266 * DRM_MEMORYBARRIER() prevents reordering of reads and writes.
267 */
268#define DRM_READMEMORYBARRIER() rmb()
269#define DRM_WRITEMEMORYBARRIER() wmb()
270#define DRM_MEMORYBARRIER() mb()
271

--- 31 unchanged lines hidden (view full) ---

303 copyin(user, kern, size)
304#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
305 copyin(arg2, arg1, arg3)
306#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \
307 copyout(arg2, arg1, arg3)
308#define DRM_GET_USER_UNCHECKED(val, uaddr) \
309 ((val) = fuword32(uaddr), 0)
310
315#define cpu_to_le32(x) htole32(x)
316#define le32_to_cpu(x) le32toh(x)
317
318#define DRM_HZ hz
319#define DRM_UDELAY(udelay) DELAY(udelay)
320#define DRM_MDELAY(msecs) do { int loops = (msecs); \
321 while (loops--) DELAY(1000); \
322 } while (0)
323#define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */
324
325#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
326 (_map) = (_dev)->context_sareas[_ctx]; \
327} while(0)
328
329#define LOCK_TEST_WITH_RETURN(dev, file_priv) \
330do { \
331 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
332 dev->lock.file_priv != file_priv) { \

--- 34 unchanged lines hidden (view full) ---

367} while (0)
368
369#define DRM_DEBUG_DRIVER(fmt, ...) do { \
370 if ((drm_debug_flag & DRM_DEBUGBITS_KMS) != 0) \
371 printf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID,\
372 __func__ , ##__VA_ARGS__); \
373} while (0)
374
311#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
312 (_map) = (_dev)->context_sareas[_ctx]; \
313} while(0)
314
315#define LOCK_TEST_WITH_RETURN(dev, file_priv) \
316do { \
317 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
318 dev->lock.file_priv != file_priv) { \

--- 34 unchanged lines hidden (view full) ---

353} while (0)
354
355#define DRM_DEBUG_DRIVER(fmt, ...) do { \
356 if ((drm_debug_flag & DRM_DEBUGBITS_KMS) != 0) \
357 printf("[" DRM_NAME ":KMS:pid%d:%s] " fmt, DRM_CURRENTPID,\
358 __func__ , ##__VA_ARGS__); \
359} while (0)
360
361#define dev_err(dev, fmt, ...) \
362 device_printf((dev), "error: " fmt, ## __VA_ARGS__)
363#define dev_warn(dev, fmt, ...) \
364 device_printf((dev), "warning: " fmt, ## __VA_ARGS__)
365#define dev_info(dev, fmt, ...) \
366 device_printf((dev), "info: " fmt, ## __VA_ARGS__)
367#define dev_dbg(dev, fmt, ...) do { \
368 if ((drm_debug_flag& DRM_DEBUGBITS_KMS) != 0) { \
369 device_printf((dev), "debug: " fmt, ## __VA_ARGS__); \
370 } \
371} while (0)
372
375typedef struct drm_pci_id_list
376{
377 int vendor;
378 int device;
379 long driver_private;
380 char *name;
381} drm_pci_id_list_t;
382
383struct drm_msi_blacklist_entry
384{
385 int vendor;
386 int device;
387};
388
389#define DRM_AUTH 0x1
373typedef struct drm_pci_id_list
374{
375 int vendor;
376 int device;
377 long driver_private;
378 char *name;
379} drm_pci_id_list_t;
380
381struct drm_msi_blacklist_entry
382{
383 int vendor;
384 int device;
385};
386
387#define DRM_AUTH 0x1
390#define DRM_MASTER 0x2
388#define DRM_MASTER 0x2
391#define DRM_ROOT_ONLY 0x4
392#define DRM_CONTROL_ALLOW 0x8
393#define DRM_UNLOCKED 0x10
394
395typedef struct drm_ioctl_desc {
396 unsigned long cmd;
397 int (*func)(struct drm_device *dev, void *data,
398 struct drm_file *file_priv);
399 int flags;
389#define DRM_ROOT_ONLY 0x4
390#define DRM_CONTROL_ALLOW 0x8
391#define DRM_UNLOCKED 0x10
392
393typedef struct drm_ioctl_desc {
394 unsigned long cmd;
395 int (*func)(struct drm_device *dev, void *data,
396 struct drm_file *file_priv);
397 int flags;
398 unsigned int cmd_drv;
400} drm_ioctl_desc_t;
399} drm_ioctl_desc_t;
400
401/**
402 * Creates a driver or general drm_ioctl_desc array entry for the given
403 * ioctl, for use by drm_ioctl().
404 */
405#define DRM_IOCTL_DEF(ioctl, func, flags) \
406 [DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags}
407
401/**
402 * Creates a driver or general drm_ioctl_desc array entry for the given
403 * ioctl, for use by drm_ioctl().
404 */
405#define DRM_IOCTL_DEF(ioctl, func, flags) \
406 [DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags}
407
408#define DRM_IOCTL_DEF_DRV(ioctl, _func, _flags) \
409 [DRM_IOCTL_NR(DRM_##ioctl)] = {.cmd = DRM_##ioctl, .func = _func, .flags = _flags, .cmd_drv = DRM_IOCTL_##ioctl}
410
408typedef struct drm_magic_entry {
409 drm_magic_t magic;
410 struct drm_file *priv;
411 struct drm_magic_entry *next;
412} drm_magic_entry_t;
413
414typedef struct drm_magic_head {
415 struct drm_magic_entry *head;
416 struct drm_magic_entry *tail;
417} drm_magic_head_t;
418
419typedef struct drm_buf {
411typedef struct drm_magic_entry {
412 drm_magic_t magic;
413 struct drm_file *priv;
414 struct drm_magic_entry *next;
415} drm_magic_entry_t;
416
417typedef struct drm_magic_head {
418 struct drm_magic_entry *head;
419 struct drm_magic_entry *tail;
420} drm_magic_head_t;
421
422typedef struct drm_buf {
420 int idx; /* Index into master buflist */
421 int total; /* Buffer size */
422 int order; /* log-base-2(total) */
423 int used; /* Amount of buffer in use (for DMA) */
424 unsigned long offset; /* Byte offset (used internally) */
425 void *address; /* Address of buffer */
426 unsigned long bus_address; /* Bus address of buffer */
427 struct drm_buf *next; /* Kernel-only: used for free list */
428 __volatile__ int pending; /* On hardware DMA queue */
429 struct drm_file *file_priv; /* Unique identifier of holding process */
430 int context; /* Kernel queue for this buffer */
423 int idx; /**< Index into master buflist */
424 int total; /**< Buffer size */
425 int order; /**< log-base-2(total) */
426 int used; /**< Amount of buffer in use (for DMA) */
427 unsigned long offset; /**< Byte offset (used internally) */
428 void *address; /**< Address of buffer */
429 unsigned long bus_address; /**< Bus address of buffer */
430 struct drm_buf *next; /**< Kernel-only: used for free list */
431 __volatile__ int waiting; /**< On kernel DMA queue */
432 __volatile__ int pending; /**< On hardware DMA queue */
433 struct drm_file *file_priv; /**< Private of holding file descr */
434 int context; /**< Kernel queue for this buffer */
435 int while_locked; /**< Dispatch this buffer while locked */
431 enum {
436 enum {
432 DRM_LIST_NONE = 0,
433 DRM_LIST_FREE = 1,
434 DRM_LIST_WAIT = 2,
435 DRM_LIST_PEND = 3,
436 DRM_LIST_PRIO = 4,
437 DRM_LIST_NONE = 0,
438 DRM_LIST_FREE = 1,
439 DRM_LIST_WAIT = 2,
440 DRM_LIST_PEND = 3,
441 DRM_LIST_PRIO = 4,
437 DRM_LIST_RECLAIM = 5
442 DRM_LIST_RECLAIM = 5
438 } list; /* Which list we're on */
443 } list; /**< Which list we're on */
439
444
440 int dev_priv_size; /* Size of buffer private stoarge */
441 void *dev_private; /* Per-buffer private storage */
445 int dev_priv_size; /**< Size of buffer private storage */
446 void *dev_private; /**< Per-buffer private storage */
442} drm_buf_t;
443
444typedef struct drm_freelist {
445 int initialized; /* Freelist in use */
446 atomic_t count; /* Number of free buffers */
447 drm_buf_t *next; /* End pointer */
448
449 int low_mark; /* Low water mark */

--- 23 unchanged lines hidden (view full) ---

473 struct drm_event *event;
474 struct list_head link;
475 struct drm_file *file_priv;
476 pid_t pid; /* pid of requester, no guarantee it's valid by the time
477 we deliver the event, for tracing only */
478 void (*destroy)(struct drm_pending_event *event);
479};
480
447} drm_buf_t;
448
449typedef struct drm_freelist {
450 int initialized; /* Freelist in use */
451 atomic_t count; /* Number of free buffers */
452 drm_buf_t *next; /* End pointer */
453
454 int low_mark; /* Low water mark */

--- 23 unchanged lines hidden (view full) ---

478 struct drm_event *event;
479 struct list_head link;
480 struct drm_file *file_priv;
481 pid_t pid; /* pid of requester, no guarantee it's valid by the time
482 we deliver the event, for tracing only */
483 void (*destroy)(struct drm_pending_event *event);
484};
485
486/* initial implementaton using a linked list - todo hashtab */
487struct drm_prime_file_private {
488 struct list_head head;
489#ifdef DUMBBELL_WIP
490 struct mutex lock;
491#endif /* DUMBBELL_WIP */
492};
493
481typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
482struct drm_file {
483 TAILQ_ENTRY(drm_file) link;
484 struct drm_device *dev;
485 int authenticated;
486 int master;
487 pid_t pid;
488 uid_t uid;

--- 6 unchanged lines hidden (view full) ---

495 int is_master;
496 struct drm_master *masterp;
497
498 struct list_head fbs;
499
500 struct list_head event_list;
501 int event_space;
502 struct selinfo event_poll;
494typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
495struct drm_file {
496 TAILQ_ENTRY(drm_file) link;
497 struct drm_device *dev;
498 int authenticated;
499 int master;
500 pid_t pid;
501 uid_t uid;

--- 6 unchanged lines hidden (view full) ---

508 int is_master;
509 struct drm_master *masterp;
510
511 struct list_head fbs;
512
513 struct list_head event_list;
514 int event_space;
515 struct selinfo event_poll;
516
517 struct drm_prime_file_private prime;
503};
504
505typedef struct drm_lock_data {
506 struct drm_hw_lock *hw_lock; /* Hardware lock */
507 struct drm_file *file_priv; /* Unique identifier of holding process (NULL is kernel)*/
508 int lock_queue; /* Queue of blocked processes */
509 unsigned long lock_time; /* Time of last lock in jiffies */
510} drm_lock_data_t;
511
512/* This structure, in the struct drm_device, is always initialized while the
513 * device
514 * is open. dev->dma_lock protects the incrementing of dev->buf_use, which
515 * when set marks that no further bufs may be allocated until device teardown
516 * occurs (when the last open of the device has closed). The high/low
517 * watermarks of bufs are only touched by the X Server, and thus not
518 * concurrently accessed, so no locking is needed.
519 */
520typedef struct drm_device_dma {
518};
519
520typedef struct drm_lock_data {
521 struct drm_hw_lock *hw_lock; /* Hardware lock */
522 struct drm_file *file_priv; /* Unique identifier of holding process (NULL is kernel)*/
523 int lock_queue; /* Queue of blocked processes */
524 unsigned long lock_time; /* Time of last lock in jiffies */
525} drm_lock_data_t;
526
527/* This structure, in the struct drm_device, is always initialized while the
528 * device
529 * is open. dev->dma_lock protects the incrementing of dev->buf_use, which
530 * when set marks that no further bufs may be allocated until device teardown
531 * occurs (when the last open of the device has closed). The high/low
532 * watermarks of bufs are only touched by the X Server, and thus not
533 * concurrently accessed, so no locking is needed.
534 */
535typedef struct drm_device_dma {
521 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
522 int buf_count;
523 drm_buf_t **buflist; /* Vector of pointers info bufs */
524 int seg_count;
525 int page_count;
526 unsigned long *pagelist;
527 unsigned long byte_count;
536
537 struct drm_buf_entry bufs[DRM_MAX_ORDER + 1]; /**< buffers, grouped by their size order */
538 int buf_count; /**< total number of buffers */
539 struct drm_buf **buflist; /**< Vector of pointers into drm_device_dma::bufs */
540 int seg_count;
541 int page_count; /**< number of pages */
542 unsigned long *pagelist; /**< page list */
543 unsigned long byte_count;
528 enum {
529 _DRM_DMA_USE_AGP = 0x01,
544 enum {
545 _DRM_DMA_USE_AGP = 0x01,
530 _DRM_DMA_USE_SG = 0x02
546 _DRM_DMA_USE_SG = 0x02,
547 _DRM_DMA_USE_FB = 0x04,
548 _DRM_DMA_USE_PCI_RO = 0x08
531 } flags;
549 } flags;
550
532} drm_device_dma_t;
533
534typedef struct drm_agp_mem {
535 void *handle;
536 unsigned long bound; /* address */
537 int pages;
538 struct drm_agp_mem *prev;
539 struct drm_agp_mem *next;

--- 48 unchanged lines hidden (view full) ---

588 atomic_t refcount; /* number of users of vblank interrupts */
589 u32 last; /* protected by dev->vbl_lock, used */
590 /* for wraparound handling */
591 int enabled; /* so we don't call enable more than */
592 /* once per disable */
593 int inmodeset; /* Display driver is setting mode */
594};
595
551} drm_device_dma_t;
552
553typedef struct drm_agp_mem {
554 void *handle;
555 unsigned long bound; /* address */
556 int pages;
557 struct drm_agp_mem *prev;
558 struct drm_agp_mem *next;

--- 48 unchanged lines hidden (view full) ---

607 atomic_t refcount; /* number of users of vblank interrupts */
608 u32 last; /* protected by dev->vbl_lock, used */
609 /* for wraparound handling */
610 int enabled; /* so we don't call enable more than */
611 /* once per disable */
612 int inmodeset; /* Display driver is setting mode */
613};
614
596/* Size of ringbuffer for vblank timestamps. Just double-buffer
597 * in initial implementation.
598 */
599#define DRM_VBLANKTIME_RBSIZE 2
600
601/* Flags and return codes for get_vblank_timestamp() driver function. */
602#define DRM_CALLED_FROM_VBLIRQ 1
603#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
604#define DRM_VBLANKTIME_INVBL (1 << 1)
605
606/* get_scanout_position() return flags */
607#define DRM_SCANOUTPOS_VALID (1 << 0)
608#define DRM_SCANOUTPOS_INVBL (1 << 1)
609#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
610
611/* location of GART table */
612#define DRM_ATI_GART_MAIN 1
613#define DRM_ATI_GART_FB 2
614
615/* location of GART table */
616#define DRM_ATI_GART_MAIN 1
617#define DRM_ATI_GART_FB 2
618
615#define DRM_ATI_GART_PCI 1
619#define DRM_ATI_GART_PCI 1
616#define DRM_ATI_GART_PCIE 2
620#define DRM_ATI_GART_PCIE 2
617#define DRM_ATI_GART_IGP 3
621#define DRM_ATI_GART_IGP 3
618
619struct drm_ati_pcigart_info {
620 int gart_table_location;
621 int gart_reg_if;
622 void *addr;
623 dma_addr_t bus_addr;
624 dma_addr_t table_mask;
625 dma_addr_t member_mask;

--- 55 unchanged lines hidden (view full) ---

681 * new read/write domain values are computed here.
682 * They will be transferred to the above values
683 * at the point that any cache flushing occurs
684 */
685 uint32_t pending_read_domains;
686 uint32_t pending_write_domain;
687
688 void *driver_private;
622
623struct drm_ati_pcigart_info {
624 int gart_table_location;
625 int gart_reg_if;
626 void *addr;
627 dma_addr_t bus_addr;
628 dma_addr_t table_mask;
629 dma_addr_t member_mask;

--- 55 unchanged lines hidden (view full) ---

685 * new read/write domain values are computed here.
686 * They will be transferred to the above values
687 * at the point that any cache flushing occurs
688 */
689 uint32_t pending_read_domains;
690 uint32_t pending_write_domain;
691
692 void *driver_private;
693
694#ifdef DUMBBELL_WIP
695 /* dma buf exported from this GEM object */
696 struct dma_buf *export_dma_buf;
697
698 /* dma buf attachment backing this object */
699 struct dma_buf_attachment *import_attach;
700#endif /* DUMBBELL_WIP */
689};
690
691#include "drm_crtc.h"
692
701};
702
703#include "drm_crtc.h"
704
705/* per-master structure */
706struct drm_master {
707
708 u_int refcount; /* refcount for this master */
709
710 struct list_head head; /**< each minor contains a list of masters */
711 struct drm_minor *minor; /**< link back to minor we are a master for */
712
713 char *unique; /**< Unique identifier: e.g., busid */
714 int unique_len; /**< Length of unique field */
715 int unique_size; /**< amount allocated */
716
717 int blocked; /**< Blocked due to VC switch? */
718
719 /** \name Authentication */
720 /*@{ */
721 struct drm_open_hash magiclist;
722 struct list_head magicfree;
723 /*@} */
724
725 struct drm_lock_data lock; /**< Information on hardware lock */
726
727 void *driver_priv; /**< Private structure for driver to use */
728};
729
730/* Size of ringbuffer for vblank timestamps. Just double-buffer
731 * in initial implementation.
732 */
733#define DRM_VBLANKTIME_RBSIZE 2
734
735/* Flags and return codes for get_vblank_timestamp() driver function. */
736#define DRM_CALLED_FROM_VBLIRQ 1
737#define DRM_VBLANKTIME_SCANOUTPOS_METHOD (1 << 0)
738#define DRM_VBLANKTIME_INVBL (1 << 1)
739
740/* get_scanout_position() return flags */
741#define DRM_SCANOUTPOS_VALID (1 << 0)
742#define DRM_SCANOUTPOS_INVBL (1 << 1)
743#define DRM_SCANOUTPOS_ACCURATE (1 << 2)
744
693#ifndef DMA_BIT_MASK
694#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1)
695#endif
696
697#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
698
699struct drm_driver_info {
700 int (*load)(struct drm_device *, unsigned long flags);

--- 55 unchanged lines hidden (view full) ---

756 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */
757
758 /**
759 * Called by \c drm_device_is_agp. Typically used to determine if a
760 * card is really attached to AGP or not.
761 *
762 * \param dev DRM device handle
763 *
745#ifndef DMA_BIT_MASK
746#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1)
747#endif
748
749#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
750
751struct drm_driver_info {
752 int (*load)(struct drm_device *, unsigned long flags);

--- 55 unchanged lines hidden (view full) ---

808 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */
809
810 /**
811 * Called by \c drm_device_is_agp. Typically used to determine if a
812 * card is really attached to AGP or not.
813 *
814 * \param dev DRM device handle
815 *
764 * \returns
816 * \returns
765 * One of three values is returned depending on whether or not the
766 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
767 * (return of 1), or may or may not be AGP (return of 2).
768 */
769 int (*device_is_agp) (struct drm_device * dev);
770
771 drm_ioctl_desc_t *ioctls;
772#ifdef COMPAT_FREEBSD32

--- 38 unchanged lines hidden (view full) ---

811 int refresh;
812 bool rb;
813 bool interlace;
814 bool cvt;
815 bool margins;
816 enum drm_connector_force force;
817};
818
817 * One of three values is returned depending on whether or not the
818 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
819 * (return of 1), or may or may not be AGP (return of 2).
820 */
821 int (*device_is_agp) (struct drm_device * dev);
822
823 drm_ioctl_desc_t *ioctls;
824#ifdef COMPAT_FREEBSD32

--- 38 unchanged lines hidden (view full) ---

863 int refresh;
864 bool rb;
865 bool interlace;
866 bool cvt;
867 bool margins;
868 enum drm_connector_force force;
869};
870
871
819struct drm_pending_vblank_event {
820 struct drm_pending_event base;
821 int pipe;
822 struct drm_event_vblank event;
823};
824
825/* Length for the array of resource pointers for drm_get_resource_*. */
826#define DRM_MAX_PCI_RESOURCE 6
827
872struct drm_pending_vblank_event {
873 struct drm_pending_event base;
874 int pipe;
875 struct drm_event_vblank event;
876};
877
878/* Length for the array of resource pointers for drm_get_resource_*. */
879#define DRM_MAX_PCI_RESOURCE 6
880
828/**
829 * DRM device functions structure
881/**
882 * DRM device structure. This structure represent a complete card that
883 * may contain multiple heads.
830 */
831struct drm_device {
832 struct drm_driver_info *driver;
833 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */
834
835 uint16_t pci_device; /* PCI device id */
836 uint16_t pci_vendor; /* PCI vendor id */
837 uint16_t pci_subdevice; /* PCI subsystem device id */

--- 107 unchanged lines hidden (view full) ---

945 /* GEM part */
946 struct sx object_name_lock;
947 struct drm_gem_names object_names;
948 void *mm_private;
949
950 void *sysctl_private;
951 char busid_str[128];
952 int modesetting;
884 */
885struct drm_device {
886 struct drm_driver_info *driver;
887 drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */
888
889 uint16_t pci_device; /* PCI device id */
890 uint16_t pci_vendor; /* PCI vendor id */
891 uint16_t pci_subdevice; /* PCI subsystem device id */

--- 107 unchanged lines hidden (view full) ---

999 /* GEM part */
1000 struct sx object_name_lock;
1001 struct drm_gem_names object_names;
1002 void *mm_private;
1003
1004 void *sysctl_private;
1005 char busid_str[128];
1006 int modesetting;
1007
1008 int switch_power_state;
953};
954
1009};
1010
1011#define DRM_SWITCH_POWER_ON 0
1012#define DRM_SWITCH_POWER_OFF 1
1013#define DRM_SWITCH_POWER_CHANGING 2
1014
955static __inline__ int drm_core_check_feature(struct drm_device *dev,
956 int feature)
957{
958 return ((dev->driver->driver_features & feature) ? 1 : 0);
959}
960
961#if __OS_HAS_AGP
962static inline int drm_core_has_AGP(struct drm_device *dev)

--- 63 unchanged lines hidden (view full) ---

1026int drm_add_busid_modesetting(struct drm_device *dev,
1027 struct sysctl_ctx_list *ctx, struct sysctl_oid *top);
1028
1029/* File operations helpers (drm_fops.c) */
1030extern int drm_open_helper(struct cdev *kdev, int flags, int fmt,
1031 DRM_STRUCTPROC *p,
1032 struct drm_device *dev);
1033
1015static __inline__ int drm_core_check_feature(struct drm_device *dev,
1016 int feature)
1017{
1018 return ((dev->driver->driver_features & feature) ? 1 : 0);
1019}
1020
1021#if __OS_HAS_AGP
1022static inline int drm_core_has_AGP(struct drm_device *dev)

--- 63 unchanged lines hidden (view full) ---

1086int drm_add_busid_modesetting(struct drm_device *dev,
1087 struct sysctl_ctx_list *ctx, struct sysctl_oid *top);
1088
1089/* File operations helpers (drm_fops.c) */
1090extern int drm_open_helper(struct cdev *kdev, int flags, int fmt,
1091 DRM_STRUCTPROC *p,
1092 struct drm_device *dev);
1093
1094#ifdef DUMBBELL_WIP
1095extern int drm_gem_prime_handle_to_fd(struct drm_device *dev,
1096 struct drm_file *file_priv, uint32_t handle, uint32_t flags,
1097 int *prime_fd);
1098extern int drm_gem_prime_fd_to_handle(struct drm_device *dev,
1099 struct drm_file *file_priv, int prime_fd, uint32_t *handle);
1100
1101extern int drm_prime_handle_to_fd_ioctl(struct drm_device *dev, void *data,
1102 struct drm_file *file_priv);
1103extern int drm_prime_fd_to_handle_ioctl(struct drm_device *dev, void *data,
1104 struct drm_file *file_priv);
1105
1106#ifdef DUMBBELL_WIP
1107/*
1108 * See drm_prime.c
1109 * -- dumbbell@
1110 */
1111extern int drm_prime_sg_to_page_addr_arrays(struct sg_table *sgt, vm_page_t *pages,
1112 dma_addr_t *addrs, int max_pages);
1113#endif /* DUMBBELL_WIP */
1114extern struct sg_table *drm_prime_pages_to_sg(vm_page_t *pages, int nr_pages);
1115extern void drm_prime_gem_destroy(struct drm_gem_object *obj, struct sg_table *sg);
1116
1117
1118void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv);
1119void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
1120int drm_prime_add_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t handle);
1121int drm_prime_lookup_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf, uint32_t *handle);
1122void drm_prime_remove_imported_buf_handle(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf);
1123
1124int drm_prime_add_dma_buf(struct drm_device *dev, struct drm_gem_object *obj);
1125int drm_prime_lookup_obj(struct drm_device *dev, struct dma_buf *buf,
1126 struct drm_gem_object **obj);
1127#endif /* DUMBBELL_WIP */
1128
1034/* Memory management support (drm_memory.c) */
1035void drm_mem_init(void);
1036void drm_mem_uninit(void);
1037void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map);
1038void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map);
1039void drm_ioremapfree(drm_local_map_t *map);
1040int drm_mtrr_add(unsigned long offset, size_t size, int flags);
1041int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);

--- 272 unchanged lines hidden (view full) ---

1314void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1315int drm_gem_mmap_single(struct drm_device *dev, vm_ooffset_t *offset,
1316 vm_size_t size, struct vm_object **obj_res, int nprot);
1317void drm_gem_pager_dtr(void *obj);
1318
1319struct ttm_bo_device;
1320int ttm_bo_mmap_single(struct ttm_bo_device *bdev, vm_ooffset_t *offset,
1321 vm_size_t size, struct vm_object **obj_res, int nprot);
1129/* Memory management support (drm_memory.c) */
1130void drm_mem_init(void);
1131void drm_mem_uninit(void);
1132void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map);
1133void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map);
1134void drm_ioremapfree(drm_local_map_t *map);
1135int drm_mtrr_add(unsigned long offset, size_t size, int flags);
1136int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);

--- 272 unchanged lines hidden (view full) ---

1409void drm_gem_free_mmap_offset(struct drm_gem_object *obj);
1410int drm_gem_mmap_single(struct drm_device *dev, vm_ooffset_t *offset,
1411 vm_size_t size, struct vm_object **obj_res, int nprot);
1412void drm_gem_pager_dtr(void *obj);
1413
1414struct ttm_bo_device;
1415int ttm_bo_mmap_single(struct ttm_bo_device *bdev, vm_ooffset_t *offset,
1416 vm_size_t size, struct vm_object **obj_res, int nprot);
1417struct ttm_buffer_object;
1418void ttm_bo_release_mmap(struct ttm_buffer_object *bo);
1322
1323void drm_device_lock_mtx(struct drm_device *dev);
1324void drm_device_unlock_mtx(struct drm_device *dev);
1325int drm_device_sleep_mtx(struct drm_device *dev, void *chan, int flags,
1326 const char *msg, int timeout);
1327void drm_device_assert_mtx_locked(struct drm_device *dev);
1328void drm_device_assert_mtx_unlocked(struct drm_device *dev);
1329

--- 72 unchanged lines hidden (view full) ---

1402 }
1403 return NULL;
1404}
1405
1406static __inline__ void drm_core_dropmap(struct drm_map *map)
1407{
1408}
1409
1419
1420void drm_device_lock_mtx(struct drm_device *dev);
1421void drm_device_unlock_mtx(struct drm_device *dev);
1422int drm_device_sleep_mtx(struct drm_device *dev, void *chan, int flags,
1423 const char *msg, int timeout);
1424void drm_device_assert_mtx_locked(struct drm_device *dev);
1425void drm_device_assert_mtx_unlocked(struct drm_device *dev);
1426

--- 72 unchanged lines hidden (view full) ---

1499 }
1500 return NULL;
1501}
1502
1503static __inline__ void drm_core_dropmap(struct drm_map *map)
1504{
1505}
1506
1410#define KIB_NOTYET() \
1411do { \
1412 if (drm_debug_flag && drm_notyet_flag) \
1413 printf("NOTYET: %s at %s:%d\n", __func__, __FILE__, __LINE__); \
1414} while (0)
1415
1416#define KTR_DRM KTR_DEV
1417#define KTR_DRM_REG KTR_SPARE3
1418
1419/* Error codes conversion from Linux to FreeBSD. */
1420/* XXXKIB what is the right code for EREMOTEIO on FreeBSD? */
1421#define EREMOTEIO ENXIO
1422#define ERESTARTSYS ERESTART
1423
1424#define PCI_VENDOR_ID_APPLE 0x106b
1425#define PCI_VENDOR_ID_ASUSTEK 0x1043
1426#define PCI_VENDOR_ID_ATI 0x1002
1427#define PCI_VENDOR_ID_DELL 0x1028
1428#define PCI_VENDOR_ID_HP 0x103c
1429#define PCI_VENDOR_ID_IBM 0x1014
1430#define PCI_VENDOR_ID_INTEL 0x8086
1431#define PCI_VENDOR_ID_SERVERWORKS 0x1166
1432#define PCI_VENDOR_ID_SONY 0x104d
1433#define PCI_VENDOR_ID_VIA 0x1106
1434
1435#define DRM_PCIE_SPEED_25 1
1436#define DRM_PCIE_SPEED_50 2
1437#define DRM_PCIE_SPEED_80 4
1438
1439extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1440
1507#define DRM_PCIE_SPEED_25 1
1508#define DRM_PCIE_SPEED_50 2
1509#define DRM_PCIE_SPEED_80 4
1510
1511extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
1512
1513#define drm_can_sleep() (DRM_HZ & 1)
1514
1441#endif /* __KERNEL__ */
1442#endif /* _DRM_P_H_ */
1515#endif /* __KERNEL__ */
1516#endif /* _DRM_P_H_ */