Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
fd80ab16
Commit
fd80ab16
authored
Jul 10, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge comment updates from DRI CVS tree.
parent
2850310b
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1999 additions
and
515 deletions
+1999
-515
drivers/char/drm/ati_pcigart.h
drivers/char/drm/ati_pcigart.h
+10
-6
drivers/char/drm/drm.h
drivers/char/drm/drm.h
+315
-137
drivers/char/drm/drmP.h
drivers/char/drm/drmP.h
+318
-173
drivers/char/drm/drm_agpsupport.h
drivers/char/drm/drm_agpsupport.h
+144
-8
drivers/char/drm/drm_auth.h
drivers/char/drm/drm_auth.h
+73
-5
drivers/char/drm/drm_bufs.h
drivers/char/drm/drm_bufs.h
+136
-10
drivers/char/drm/drm_context.h
drivers/char/drm/drm_context.h
+169
-14
drivers/char/drm/drm_dma.h
drivers/char/drm/drm_dma.h
+96
-6
drivers/char/drm/drm_drawable.h
drivers/char/drm/drm_drawable.h
+11
-5
drivers/char/drm/drm_drv.h
drivers/char/drm/drm_drv.h
+136
-36
drivers/char/drm/drm_fops.h
drivers/char/drm/drm_fops.h
+25
-7
drivers/char/drm/drm_init.h
drivers/char/drm/drm_init.h
+37
-19
drivers/char/drm/drm_ioctl.h
drivers/char/drm/drm_ioctl.h
+79
-5
drivers/char/drm/drm_lock.h
drivers/char/drm/drm_lock.h
+53
-20
drivers/char/drm/drm_memory.h
drivers/char/drm/drm_memory.h
+54
-7
drivers/char/drm/drm_memory_debug.h
drivers/char/drm/drm_memory_debug.h
+8
-6
drivers/char/drm/drm_os_linux.h
drivers/char/drm/drm_os_linux.h
+30
-4
drivers/char/drm/drm_proc.h
drivers/char/drm/drm_proc.h
+113
-17
drivers/char/drm/drm_sarea.h
drivers/char/drm/drm_sarea.h
+18
-11
drivers/char/drm/drm_scatter.h
drivers/char/drm/drm_scatter.h
+8
-4
drivers/char/drm/drm_stub.h
drivers/char/drm/drm_stub.h
+65
-8
drivers/char/drm/drm_vm.h
drivers/char/drm/drm_vm.h
+101
-7
No files found.
drivers/char/drm/ati_pcigart.h
View file @
fd80ab16
/* ati_pcigart.h -- ATI PCI GART support -*- linux-c -*-
/**
* \file ati_pcigart.h
* ATI PCI GART support
*
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Wed Dec 13 21:52:19 2000 by gareth@valinux.com
*
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
...
...
@@ -22,9 +29,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
...
...
@@ -45,8 +49,8 @@
# error - PAGE_SIZE not 64K, 16K, 8K or 4K
#endif
# define ATI_MAX_PCIGART_PAGES 8192
/* 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096
/* PCI GART page size */
# define ATI_MAX_PCIGART_PAGES 8192
/*
*<
32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096
/*
*<
PCI GART page size */
static
unsigned
long
DRM
(
ati_alloc_pcigart_table
)(
void
)
{
...
...
drivers/char/drm/drm.h
View file @
fd80ab16
/* drm.h -- Header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
/**
* \file drm.h
* Header for the Direct Rendering Manager
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
*
* \par Acknowledgments:
* Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic \c cmpxchg.
*/
/*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
...
...
@@ -23,15 +31,9 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
*
* Acknowledgements:
* Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
*
*/
#ifndef _DRM_H_
#define _DRM_H_
...
...
@@ -82,29 +84,33 @@
#define DRM_MAJOR 226
#define DRM_MAX_MINOR 15
#endif
#define DRM_NAME "drm"
/*
Name in kernel, /dev, and /proc
*/
#define DRM_MIN_ORDER 5
/*
At least 2^5 bytes = 32 bytes
*/
#define DRM_MAX_ORDER 22
/*
Up to 2^22 bytes = 4MB
*/
#define DRM_RAM_PERCENT 10
/*
How much system ram can we lock?
*/
#define DRM_NAME "drm"
/*
*< Name in kernel, /dev, and /proc
*/
#define DRM_MIN_ORDER 5
/*
*< At least 2^5 bytes = 32 bytes
*/
#define DRM_MAX_ORDER 22
/*
*< Up to 2^22 bytes = 4MB
*/
#define DRM_RAM_PERCENT 10
/*
*< How much system ram can we lock?
*/
#define _DRM_LOCK_HELD 0x80000000
/*
Hardware lock is held
*/
#define _DRM_LOCK_CONT 0x40000000
/*
Hardware lock is contended
*/
#define _DRM_LOCK_HELD 0x80000000
/*
*< Hardware lock is held
*/
#define _DRM_LOCK_CONT 0x40000000
/*
*< Hardware lock is contended
*/
#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
typedef
unsigned
long
drm_handle_t
;
typedef
unsigned
int
drm_context_t
;
typedef
unsigned
int
drm_drawable_t
;
typedef
unsigned
int
drm_magic_t
;
/* Warning: If you change this structure, make sure you change
* XF86DRIClipRectRec in the server as well */
/* KW: Actually it's illegal to change either for
/**
* Cliprect.
*
* \warning: If you change this structure, make sure you change
* XF86DRIClipRectRec in the server as well
*
* \note KW: Actually it's illegal to change either for
* backwards-compatibility reasons.
*/
typedef
struct
drm_clip_rect
{
unsigned
short
x1
;
unsigned
short
y1
;
...
...
@@ -112,6 +118,10 @@ typedef struct drm_clip_rect {
unsigned
short
y2
;
}
drm_clip_rect_t
;
/**
* Texture region,
*/
typedef
struct
drm_tex_region
{
unsigned
char
next
;
unsigned
char
prev
;
...
...
@@ -120,32 +130,52 @@ typedef struct drm_tex_region {
unsigned
int
age
;
}
drm_tex_region_t
;
/**
* DRM_IOCTL_VERSION ioctl argument type.
*
* \sa drmGetVersion().
*/
typedef
struct
drm_version
{
int
version_major
;
/*
Major version
*/
int
version_minor
;
/*
Minor version
*/
int
version_patchlevel
;
/*
Patch level
*/
size_t
name_len
;
/*
Length of name buffer
*/
char
*
name
;
/*
Name of driver
*/
size_t
date_len
;
/*
Length of date buffer
*/
char
*
date
;
/*
User-space buffer to hold date
*/
size_t
desc_len
;
/*
Length of desc buffer
*/
char
*
desc
;
/*
User-space buffer to hold desc
*/
int
version_major
;
/*
*< Major version
*/
int
version_minor
;
/*
*< Minor version
*/
int
version_patchlevel
;
/*
*< Patch level
*/
size_t
name_len
;
/*
*< Length of name buffer
*/
char
*
name
;
/*
*< Name of driver
*/
size_t
date_len
;
/*
*< Length of date buffer
*/
char
*
date
;
/*
*< User-space buffer to hold date
*/
size_t
desc_len
;
/*
*< Length of desc buffer
*/
char
*
desc
;
/*
*< User-space buffer to hold desc
*/
}
drm_version_t
;
/**
* DRM_IOCTL_GET_UNIQUE ioctl argument type.
*
* \sa drmGetBusid() and drmSetBusId().
*/
typedef
struct
drm_unique
{
size_t
unique_len
;
/*
Length of unique
*/
char
*
unique
;
/*
Unique name for driver instantiation
*/
size_t
unique_len
;
/*
*< Length of unique
*/
char
*
unique
;
/*
*< Unique name for driver instantiation
*/
}
drm_unique_t
;
typedef
struct
drm_list
{
int
count
;
/*
Length of user-space structures
*/
int
count
;
/*
*< Length of user-space structures
*/
drm_version_t
*
version
;
}
drm_list_t
;
typedef
struct
drm_block
{
int
unused
;
}
drm_block_t
;
/**
* DRM_IOCTL_CONTROL ioctl argument type.
*
* \sa drmCtlInstHandler() and drmCtlUninstHandler().
*/
typedef
struct
drm_control
{
enum
{
DRM_ADD_COMMAND
,
...
...
@@ -156,49 +186,70 @@ typedef struct drm_control {
int
irq
;
}
drm_control_t
;
/**
* Type of memory to map.
*/
typedef
enum
drm_map_type
{
_DRM_FRAME_BUFFER
=
0
,
/*
WC (no caching), no core dump
*/
_DRM_REGISTERS
=
1
,
/*
no caching, no core dump
*/
_DRM_SHM
=
2
,
/*
shared, cached
*/
_DRM_AGP
=
3
,
/*
AGP/GART
*/
_DRM_SCATTER_GATHER
=
4
/*
Scatter/gather memory for PCI DMA
*/
_DRM_FRAME_BUFFER
=
0
,
/*
*< WC (no caching), no core dump
*/
_DRM_REGISTERS
=
1
,
/*
*< no caching, no core dump
*/
_DRM_SHM
=
2
,
/*
*< shared, cached
*/
_DRM_AGP
=
3
,
/*
*< AGP/GART
*/
_DRM_SCATTER_GATHER
=
4
/*
*< Scatter/gather memory for PCI DMA
*/
}
drm_map_type_t
;
/**
* Memory mapping flags.
*/
typedef
enum
drm_map_flags
{
_DRM_RESTRICTED
=
0x01
,
/*
Cannot be mapped to user-virtual
*/
_DRM_RESTRICTED
=
0x01
,
/*
*< Cannot be mapped to user-virtual
*/
_DRM_READ_ONLY
=
0x02
,
_DRM_LOCKED
=
0x04
,
/*
shared, cached, locked
*/
_DRM_KERNEL
=
0x08
,
/*
kernel requires access
*/
_DRM_WRITE_COMBINING
=
0x10
,
/*
use write-combining if available
*/
_DRM_CONTAINS_LOCK
=
0x20
,
/*
SHM page that contains lock
*/
_DRM_REMOVABLE
=
0x40
/*
Removable mapping
*/
_DRM_LOCKED
=
0x04
,
/*
*< shared, cached, locked
*/
_DRM_KERNEL
=
0x08
,
/*
*< kernel requires access
*/
_DRM_WRITE_COMBINING
=
0x10
,
/*
*< use write-combining if available
*/
_DRM_CONTAINS_LOCK
=
0x20
,
/*
*< SHM page that contains lock
*/
_DRM_REMOVABLE
=
0x40
/*
*< Removable mapping
*/
}
drm_map_flags_t
;
typedef
struct
drm_ctx_priv_map
{
unsigned
int
ctx_id
;
/* Context requesting private mapping */
void
*
handle
;
/* Handle of map */
unsigned
int
ctx_id
;
/*
*<
Context requesting private mapping */
void
*
handle
;
/*
*<
Handle of map */
}
drm_ctx_priv_map_t
;
/**
* DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls
* argument type.
*
* \sa drmAddMap().
*/
typedef
struct
drm_map
{
unsigned
long
offset
;
/* Requested physical address (0 for SAREA)*/
unsigned
long
size
;
/*
Requested physical size (bytes)
*/
drm_map_type_t
type
;
/*
Type of memory to map
*/
drm_map_flags_t
flags
;
/*
Flags
*/
void
*
handle
;
/*
User-space: "Handle" to pass to mmap
*/
/*
Kernel-space: kernel-virtual address
*/
int
mtrr
;
/*
MTRR slot used
*/
unsigned
long
offset
;
/*
*<
Requested physical address (0 for SAREA)*/
unsigned
long
size
;
/*
*< Requested physical size (bytes)
*/
drm_map_type_t
type
;
/*
*< Type of memory to map
*/
drm_map_flags_t
flags
;
/*
*< Flags
*/
void
*
handle
;
/*
*< User-space: "Handle" to pass to mmap()
*/
/*
*< Kernel-space: kernel-virtual address
*/
int
mtrr
;
/*
*< MTRR slot used
*/
/* Private data */
}
drm_map_t
;
/**
* DRM_IOCTL_GET_CLIENT ioctl argument type.
*/
typedef
struct
drm_client
{
int
idx
;
/*
Which client desired?
*/
int
auth
;
/*
Is client authenticated?
*/
unsigned
long
pid
;
/*
Process id
*/
unsigned
long
uid
;
/*
User id
*/
unsigned
long
magic
;
/*
Magic
*/
unsigned
long
iocs
;
/*
Ioctl count
*/
int
idx
;
/*
*< Which client desired?
*/
int
auth
;
/*
*< Is client authenticated?
*/
unsigned
long
pid
;
/*
*< Process ID
*/
unsigned
long
uid
;
/*
*< User ID
*/
unsigned
long
magic
;
/*
*< Magic
*/
unsigned
long
iocs
;
/*
*< Ioctl count
*/
}
drm_client_t
;
typedef
enum
{
_DRM_STAT_LOCK
,
_DRM_STAT_OPENS
,
...
...
@@ -206,20 +257,24 @@ typedef enum {
_DRM_STAT_IOCTLS
,
_DRM_STAT_LOCKS
,
_DRM_STAT_UNLOCKS
,
_DRM_STAT_VALUE
,
/*
Generic value
*/
_DRM_STAT_BYTE
,
/* Generic byte counter (1024bytes/K) */
_DRM_STAT_COUNT
,
/*
Generic non-byte counter (1000/k)
*/
_DRM_STAT_VALUE
,
/*
*< Generic value
*/
_DRM_STAT_BYTE
,
/*
*<
Generic byte counter (1024bytes/K) */
_DRM_STAT_COUNT
,
/*
*< Generic non-byte counter (1000/k)
*/
_DRM_STAT_IRQ
,
/* IRQ */
_DRM_STAT_PRIMARY
,
/* Primary DMA bytes */
_DRM_STAT_SECONDARY
,
/* Secondary DMA bytes */
_DRM_STAT_DMA
,
/* DMA */
_DRM_STAT_SPECIAL
,
/* Special DMA (e.g., priority or polled) */
_DRM_STAT_MISSED
/* Missed DMA opportunity */
_DRM_STAT_IRQ
,
/*
*<
IRQ */
_DRM_STAT_PRIMARY
,
/*
*<
Primary DMA bytes */
_DRM_STAT_SECONDARY
,
/*
*<
Secondary DMA bytes */
_DRM_STAT_DMA
,
/*
*<
DMA */
_DRM_STAT_SPECIAL
,
/*
*<
Special DMA (e.g., priority or polled) */
_DRM_STAT_MISSED
/*
*<
Missed DMA opportunity */
/* Add to the *END* of the list */
}
drm_stat_type_t
;
/**
* DRM_IOCTL_GET_STATS ioctl argument type.
*/
typedef
struct
drm_stats
{
unsigned
long
count
;
struct
{
...
...
@@ -228,137 +283,220 @@ typedef struct drm_stats {
}
data
[
15
];
}
drm_stats_t
;
/**
* Hardware locking flags.
*/
typedef
enum
drm_lock_flags
{
_DRM_LOCK_READY
=
0x01
,
/* Wait until hardware is ready for DMA */
_DRM_LOCK_QUIESCENT
=
0x02
,
/*
Wait until hardware quiescent
*/
_DRM_LOCK_FLUSH
=
0x04
,
/* Flush this context's DMA queue first */
_DRM_LOCK_FLUSH_ALL
=
0x08
,
/*
Flush all DMA queues first
*/
_DRM_LOCK_READY
=
0x01
,
/*
*<
Wait until hardware is ready for DMA */
_DRM_LOCK_QUIESCENT
=
0x02
,
/*
*< Wait until hardware quiescent
*/
_DRM_LOCK_FLUSH
=
0x04
,
/*
*<
Flush this context's DMA queue first */
_DRM_LOCK_FLUSH_ALL
=
0x08
,
/*
*< Flush all DMA queues first
*/
/* These *HALT* flags aren't supported yet
-- they will be used to support the
full-screen DGA-like mode. */
_DRM_HALT_ALL_QUEUES
=
0x10
,
/*
Halt all current and future queues
*/
_DRM_HALT_CUR_QUEUES
=
0x20
/*
Halt all current queues
*/
_DRM_HALT_ALL_QUEUES
=
0x10
,
/*
*< Halt all current and future queues
*/
_DRM_HALT_CUR_QUEUES
=
0x20
/*
*< Halt all current queues
*/
}
drm_lock_flags_t
;
/**
* DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type.
*
* \sa drmGetLock() and drmUnlock().
*/
typedef
struct
drm_lock
{
int
context
;
drm_lock_flags_t
flags
;
}
drm_lock_t
;
typedef
enum
drm_dma_flags
{
/* These values *MUST* match xf86drm.h */
/**
* DMA flags
*
* \warning
* These values \e must match xf86drm.h.
*
* \sa drm_dma.
*/
typedef
enum
drm_dma_flags
{
/* Flags for DMA buffer dispatch */
_DRM_DMA_BLOCK
=
0x01
,
/* Block until buffer dispatched.
Note, the buffer may not yet have
been processed by the hardware --
getting a hardware lock with the
hardware quiescent will ensure
that the buffer has been
processed. */
_DRM_DMA_WHILE_LOCKED
=
0x02
,
/* Dispatch while lock held */
_DRM_DMA_PRIORITY
=
0x04
,
/* High priority dispatch */
_DRM_DMA_BLOCK
=
0x01
,
/**<
* Block until buffer dispatched.
*
* \note The buffer may not yet have
* been processed by the hardware --
* getting a hardware lock with the
* hardware quiescent will ensure
* that the buffer has been
* processed.
*/
_DRM_DMA_WHILE_LOCKED
=
0x02
,
/**< Dispatch while lock held */
_DRM_DMA_PRIORITY
=
0x04
,
/**< High priority dispatch */
/* Flags for DMA buffer request */
_DRM_DMA_WAIT
=
0x10
,
/*
Wait for free buffers
*/
_DRM_DMA_SMALLER_OK
=
0x20
,
/*
Smaller-than-requested buffers ok
*/
_DRM_DMA_LARGER_OK
=
0x40
/*
Larger-than-requested buffers ok
*/
_DRM_DMA_WAIT
=
0x10
,
/*
*< Wait for free buffers
*/
_DRM_DMA_SMALLER_OK
=
0x20
,
/*
*< Smaller-than-requested buffers OK
*/
_DRM_DMA_LARGER_OK
=
0x40
/*
*< Larger-than-requested buffers OK
*/
}
drm_dma_flags_t
;
/**
* DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type.
*
* \sa drmAddBufs().
*/
typedef
struct
drm_buf_desc
{
int
count
;
/*
Number of buffers of this size
*/
int
size
;
/*
Size in bytes
*/
int
low_mark
;
/*
Low water mark
*/
int
high_mark
;
/*
High water mark
*/
int
count
;
/*
*< Number of buffers of this size
*/
int
size
;
/*
*< Size in bytes
*/
int
low_mark
;
/*
*< Low water mark
*/
int
high_mark
;
/*
*< High water mark
*/
enum
{
_DRM_PAGE_ALIGN
=
0x01
,
/*
Align on page boundaries for DMA
*/
_DRM_AGP_BUFFER
=
0x02
,
/*
Buffer is in agp space
*/
_DRM_SG_BUFFER
=
0x04
/*
Scatter/gather memory buffer
*/
_DRM_PAGE_ALIGN
=
0x01
,
/*
*< Align on page boundaries for DMA
*/
_DRM_AGP_BUFFER
=
0x02
,
/*
*< Buffer is in AGP space
*/
_DRM_SG_BUFFER
=
0x04
/*
*< Scatter/gather memory buffer
*/
}
flags
;
unsigned
long
agp_start
;
/* Start address of where the agp buffers
* are in the agp aperture */
unsigned
long
agp_start
;
/**<
* Start address of where the AGP buffers are
* in the AGP aperture
*/
}
drm_buf_desc_t
;
/**
* DRM_IOCTL_INFO_BUFS ioctl argument type.
*/
typedef
struct
drm_buf_info
{
int
count
;
/*
Entries in list
*/
int
count
;
/*
*< Entries in list
*/
drm_buf_desc_t
*
list
;
}
drm_buf_info_t
;
/**
* DRM_IOCTL_FREE_BUFS ioctl argument type.
*/
typedef
struct
drm_buf_free
{
int
count
;
int
*
list
;
}
drm_buf_free_t
;
/**
* Buffer information
*
* \sa drm_buf_map.
*/
typedef
struct
drm_buf_pub
{
int
idx
;
/*
Index into master buflist
*/
int
total
;
/*
Buffer size
*/
int
used
;
/*
Amount of buffer in use (for DMA)
*/
void
*
address
;
/*
Address of buffer
*/
int
idx
;
/*
*< Index into the master buffer list
*/
int
total
;
/*
*< Buffer size
*/
int
used
;
/*
*< Amount of buffer in use (for DMA)
*/
void
*
address
;
/*
*< Address of buffer
*/
}
drm_buf_pub_t
;
/**
* DRM_IOCTL_MAP_BUFS ioctl argument type.
*/
typedef
struct
drm_buf_map
{
int
count
;
/*
Length of buflist
*/
void
*
virtual
;
/*
Mmaped area in user-virtual
*/
drm_buf_pub_t
*
list
;
/*
Buffer information
*/
int
count
;
/*
*< Length of the buffer list
*/
void
*
virtual
;
/*
*< Mmap'd area in user-virtual
*/
drm_buf_pub_t
*
list
;
/*
*< Buffer information
*/
}
drm_buf_map_t
;
/**
* DRM_IOCTL_DMA ioctl argument type.
*
* Indices here refer to the offset into the buffer list in drm_buf_get.
*
* \sa drmDMA().
*/
typedef
struct
drm_dma
{
/* Indices here refer to the offset into
buflist in drm_buf_get_t. */
int
context
;
/* Context handle */
int
send_count
;
/* Number of buffers to send */
int
*
send_indices
;
/* List of handles to buffers */
int
*
send_sizes
;
/* Lengths of data to send */
drm_dma_flags_t
flags
;
/* Flags */
int
request_count
;
/* Number of buffers requested */
int
request_size
;
/* Desired size for buffers */
int
*
request_indices
;
/* Buffer information */
int
context
;
/**< Context handle */
int
send_count
;
/**< Number of buffers to send */
int
*
send_indices
;
/**< List of handles to buffers */
int
*
send_sizes
;
/**< Lengths of data to send */
drm_dma_flags_t
flags
;
/**< Flags */
int
request_count
;
/**< Number of buffers requested */
int
request_size
;
/**< Desired size for buffers */
int
*
request_indices
;
/**< Buffer information */
int
*
request_sizes
;
int
granted_count
;
/*
Number of buffers granted
*/
int
granted_count
;
/*
*< Number of buffers granted
*/
}
drm_dma_t
;
typedef
enum
{
_DRM_CONTEXT_PRESERVED
=
0x01
,
_DRM_CONTEXT_2DONLY
=
0x02
}
drm_ctx_flags_t
;
/**
* DRM_IOCTL_ADD_CTX ioctl argument type.
*
* \sa drmCreateContext() and drmDestroyContext().
*/
typedef
struct
drm_ctx
{
drm_context_t
handle
;
drm_ctx_flags_t
flags
;
}
drm_ctx_t
;
/**
* DRM_IOCTL_RES_CTX ioctl argument type.
*/
typedef
struct
drm_ctx_res
{
int
count
;
drm_ctx_t
*
contexts
;
}
drm_ctx_res_t
;
/**
* DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type.
*/
typedef
struct
drm_draw
{
drm_drawable_t
handle
;
}
drm_draw_t
;
/**
* DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type.
*/
typedef
struct
drm_auth
{
drm_magic_t
magic
;
}
drm_auth_t
;
/**
* DRM_IOCTL_IRQ_BUSID ioctl argument type.
*
* \sa drmGetInterruptFromBusID().
*/
typedef
struct
drm_irq_busid
{
int
irq
;
int
busnum
;
int
devnum
;
int
funcnum
;
int
irq
;
/**< IRQ number */
int
busnum
;
/**< bus number */
int
devnum
;
/**< device number */
int
funcnum
;
/**< function number */
}
drm_irq_busid_t
;
typedef
enum
{
_DRM_VBLANK_ABSOLUTE
=
0x0
,
/* Wait for specific vblank sequence number */
_DRM_VBLANK_RELATIVE
=
0x1
,
/* Wait for given number of vblanks */
_DRM_VBLANK_SIGNAL
=
0x40000000
/* Send signal instead of blocking */
_DRM_VBLANK_ABSOLUTE
=
0x0
,
/*
*<
Wait for specific vblank sequence number */
_DRM_VBLANK_RELATIVE
=
0x1
,
/*
*<
Wait for given number of vblanks */
_DRM_VBLANK_SIGNAL
=
0x40000000
/*
*<
Send signal instead of blocking */
}
drm_vblank_seq_type_t
;
#define _DRM_VBLANK_FLAGS_MASK _DRM_VBLANK_SIGNAL
struct
drm_wait_vblank_request
{
drm_vblank_seq_type_t
type
;
unsigned
int
sequence
;
unsigned
long
signal
;
};
struct
drm_wait_vblank_reply
{
drm_vblank_seq_type_t
type
;
unsigned
int
sequence
;
...
...
@@ -366,29 +504,59 @@ struct drm_wait_vblank_reply {
long
tval_usec
;
};
/**
* DRM_IOCTL_WAIT_VBLANK ioctl argument type.
*
* \sa drmWaitVBlank().
*/
typedef
union
drm_wait_vblank
{
struct
drm_wait_vblank_request
request
;
struct
drm_wait_vblank_reply
reply
;
}
drm_wait_vblank_t
;
/**
* DRM_IOCTL_AGP_ENABLE ioctl argument type.
*
* \sa drmAgpEnable().
*/
typedef
struct
drm_agp_mode
{
unsigned
long
mode
;
unsigned
long
mode
;
/**< AGP mode */
}
drm_agp_mode_t
;
/* For drm_agp_alloc -- allocated a buffer */
/**
* DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type.
*
* \sa drmAgpAlloc() and drmAgpFree().
*/
typedef
struct
drm_agp_buffer
{
unsigned
long
size
;
/* In bytes -- will round to page boundary */
unsigned
long
handle
;
/*
Used for BIND/UNBIND ioctls
*/
unsigned
long
type
;
/*
Type of memory to allocate
*/
unsigned
long
physical
;
/*
Physical used by i810
*/
unsigned
long
size
;
/*
*<
In bytes -- will round to page boundary */
unsigned
long
handle
;
/*
*< Used for binding / unbinding
*/
unsigned
long
type
;
/*
*< Type of memory to allocate
*/
unsigned
long
physical
;
/*
*< Physical used by i810
*/
}
drm_agp_buffer_t
;
/* For drm_agp_bind */
/**
* DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type.
*
* \sa drmAgpBind() and drmAgpUnbind().
*/
typedef
struct
drm_agp_binding
{
unsigned
long
handle
;
/* From drm_agp_buffer */
unsigned
long
offset
;
/* In bytes -- will round to page boundary */
unsigned
long
handle
;
/*
*<
From drm_agp_buffer */
unsigned
long
offset
;
/*
*<
In bytes -- will round to page boundary */
}
drm_agp_binding_t
;
/**
* DRM_IOCTL_AGP_INFO ioctl argument type.
*
* \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(),
* drmAgpBase(), drmAgpSize(), drmAgpMemoryUsed(), drmAgpMemoryAvail(),
* drmAgpVendorId() and drmAgpDeviceId().
*/
typedef
struct
drm_agp_info
{
int
agp_version_major
;
int
agp_version_minor
;
...
...
@@ -403,11 +571,16 @@ typedef struct drm_agp_info {
unsigned
short
id_device
;
}
drm_agp_info_t
;
/**
* DRM_IOCTL_SG_ALLOC ioctl argument type.
*/
typedef
struct
drm_scatter_gather
{
unsigned
long
size
;
/* In bytes -- will round to page boundary */
unsigned
long
handle
;
/* Used for mapping / unmapping */
unsigned
long
size
;
/*
*<
In bytes -- will round to page boundary */
unsigned
long
handle
;
/*
*<
Used for mapping / unmapping */
}
drm_scatter_gather_t
;
#define DRM_IOCTL_BASE 'd'
#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type)
...
...
@@ -467,8 +640,13 @@ typedef struct drm_scatter_gather {
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t)
/* Device specfic ioctls should only be in their respective headers
* The device specific ioctl range is 0x40 to 0x79. */
/**
* Device specific ioctls should only be in their respective headers
* The device specific ioctl range is from 0x40 to 0x79.
*
* \sa drmCommandNone(), drmCommandRead(), drmCommandWrite(), and
* drmCommandReadWrite().
*/
#define DRM_COMMAND_BASE 0x40
#endif
drivers/char/drm/drmP.h
View file @
fd80ab16
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
/**
* \file drmP.h
* Private header for Direct Rendering Manager
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
...
...
@@ -23,15 +29,12 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#ifndef _DRM_P_H_
#define _DRM_P_H_
#ifdef __KERNEL__
#ifdef __alpha__
/* add include of current.h so that "current" is defined
...
...
@@ -72,8 +75,11 @@
#include "drm_os_linux.h"
/* DRM template customization defaults
*/
/***********************************************************************/
/** \name DRM template customization defaults */
/*@{*/
#ifndef __HAVE_AGP
#define __HAVE_AGP 0
#endif
...
...
@@ -101,19 +107,23 @@
#define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
#define __REALLY_HAVE_SG (__HAVE_SG)
/* Begin the DRM...
*/
/*@}*/
#define DRM_DEBUG_CODE 2
/* Include debugging code (if > 1, then
/***********************************************************************/
/** \name Begin the DRM... */
/*@{*/
#define DRM_DEBUG_CODE 2
/**< Include debugging code if > 1, then
also include looping detection. */
#define DRM_HASH_SIZE 16
/*
Size of key hash table
*/
#define DRM_KERNEL_CONTEXT 0
/*
Change drm_resctx if changed
*/
#define DRM_RESERVED_CONTEXTS 1
/*
Change drm_resctx if changed
*/
#define DRM_HASH_SIZE 16
/*
*< Size of key hash table. Must be power of 2.
*/
#define DRM_KERNEL_CONTEXT 0
/*
*< Change drm_resctx if changed
*/
#define DRM_RESERVED_CONTEXTS 1
/*
*< Change drm_resctx if changed
*/
#define DRM_LOOPING_LIMIT 5000000
#define DRM_BSZ 1024
/*
Buffer size for /dev/drm? output
*/
#define DRM_TIME_SLICE (HZ/20)
/*
Time slice for GLXContexts
*/
#define DRM_LOCK_SLICE 1
/*
Time slice for lock, in jiffies
*/
#define DRM_BSZ 1024
/*
*< Buffer size for /dev/drm? output
*/
#define DRM_TIME_SLICE (HZ/20)
/*
*< Time slice for GLXContexts
*/
#define DRM_LOCK_SLICE 1
/*
*< Time slice for lock, in jiffies
*/
#define DRM_FLAG_DEBUG 0x01
...
...
@@ -141,7 +151,13 @@
#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
/* Backward compatibility section */
/*@}*/
/***********************************************************************/
/** \name Backward compatibility section */
/*@{*/
#ifndef minor
#define minor(x) MINOR((x))
#endif
...
...
@@ -191,17 +207,42 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
#define DRM_RPR_ARG(vma) vma,
#endif
#define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
/* Macros to make printk easier */
/*@}*/
/***********************************************************************/
/** \name Macros to make printk easier */
/*@{*/
/**
* Error output.
*
* \param fmt printf() like format string.
* \param arg arguments
*/
#define DRM_ERROR(fmt, arg...) \
printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
/**
* Memory error output.
*
* \param area memory area where the error occurred.
* \param fmt printf() like format string.
* \param arg arguments
*/
#define DRM_MEM_ERROR(area, fmt, arg...) \
printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
DRM(mem_stats)[area].name , ##arg)
#define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
/**
* Debug output.
*
* \param fmt printf() like format string.
* \param arg arguments
*/
#if DRM_DEBUG_CODE
#define DRM_DEBUG(fmt, arg...) \
do { \
...
...
@@ -224,7 +265,13 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
len += sprintf(&buf[len], fmt , ##arg); \
if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
/* Mapping helper macros */
/*@}*/
/***********************************************************************/
/** \name Mapping helper macros */
/*@{*/
#define DRM_IOREMAP(map, dev) \
(map)->handle = DRM(ioremap)( (map)->offset, (map)->size, (dev) )
...
...
@@ -237,6 +284,15 @@ static inline struct page * vmalloc_to_page(void * vmalloc_addr)
DRM(ioremapfree)( (map)->handle, (map)->size, (dev) ); \
} while (0)
/**
* Find mapping.
*
* \param _map matching mapping if found, untouched otherwise.
* \param _o offset.
*
* Expects the existence of a local variable named \p dev pointing to the
* drm_device structure.
*/
#define DRM_FIND_MAP(_map, _o) \
do { \
struct list_head *_list; \
...
...
@@ -249,9 +305,21 @@ do { \
} \
} \
} while(0)
/**
* Drop mapping.
*
* \sa #DRM_FIND_MAP.
*/
#define DRM_DROP_MAP(_map)
/* Internal types and structures */
/*@}*/
/***********************************************************************/
/** \name Internal types and structures */
/*@{*/
#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
#define DRM_MAX(a,b) ((a)>(b)?(a):(b))
...
...
@@ -260,10 +328,23 @@ do { \
#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
#define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
/**
* Get the private SAREA mapping.
*
* \param _dev DRM device.
* \param _ctx context number.
* \param _map output mapping.
*/
#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
(_map) = (_dev)->context_sareas[_ctx]; \
} while(0)
/**
* Test that the hardware lock is held by the caller, returning otherwise.
*
* \param dev DRM device.
* \param filp file pointer of the caller.
*/
#define LOCK_TEST_WITH_RETURN( dev, filp ) \
do { \
if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
...
...
@@ -274,7 +355,14 @@ do { \
} \
} while (0)
/**
* Ioctl function type.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg argument.
*/
typedef
int
drm_ioctl_t
(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
);
...
...
@@ -290,8 +378,7 @@ typedef struct drm_ioctl_desc {
}
drm_ioctl_desc_t
;
typedef
struct
drm_devstate
{
pid_t
owner
;
/* X server pid holding x_lock */
pid_t
owner
;
/**< X server pid holding x_lock */
}
drm_devstate_t
;
typedef
struct
drm_magic_entry
{
...
...
@@ -311,21 +398,24 @@ typedef struct drm_vma_entry {
pid_t
pid
;
}
drm_vma_entry_t
;
/**
* DMA buffer.
*/
typedef
struct
drm_buf
{
int
idx
;
/*
Index into master buflist
*/
int
total
;
/*
Buffer size
*/
int
order
;
/*
log-base-2(total)
*/
int
used
;
/*
Amount of buffer in use (for DMA)
*/
unsigned
long
offset
;
/*
Byte offset (used internally)
*/
void
*
address
;
/*
Address of buffer
*/
unsigned
long
bus_address
;
/*
Bus address of buffer
*/
struct
drm_buf
*
next
;
/*
Kernel-only: used for free list
*/
__volatile__
int
waiting
;
/*
On kernel DMA queue
*/
__volatile__
int
pending
;
/*
On hardware DMA queue
*/
wait_queue_head_t
dma_wait
;
/*
Processes waiting
*/
struct
file
*
filp
;
/*
Pointer to holding file descr
*/
int
context
;
/*
Kernel queue for this buffer
*/
int
while_locked
;
/*
Dispatch this buffer while locked
*/
int
idx
;
/*
*< Index into master buflist
*/
int
total
;
/*
*< Buffer size
*/
int
order
;
/*
*< log-base-2(total)
*/
int
used
;
/*
*< Amount of buffer in use (for DMA)
*/
unsigned
long
offset
;
/*
*< Byte offset (used internally)
*/
void
*
address
;
/*
*< Address of buffer
*/
unsigned
long
bus_address
;
/*
*< Bus address of buffer
*/
struct
drm_buf
*
next
;
/*
*< Kernel-only: used for free list
*/
__volatile__
int
waiting
;
/*
*< On kernel DMA queue
*/
__volatile__
int
pending
;
/*
*< On hardware DMA queue
*/
wait_queue_head_t
dma_wait
;
/*
*< Processes waiting
*/
struct
file
*
filp
;
/*
*< Pointer to holding file descr
*/
int
context
;
/*
*< Kernel queue for this buffer
*/
int
while_locked
;
/*
*< Dispatch this buffer while locked
*/
enum
{
DRM_LIST_NONE
=
0
,
DRM_LIST_FREE
=
1
,
...
...
@@ -333,41 +423,43 @@ typedef struct drm_buf {
DRM_LIST_PEND
=
3
,
DRM_LIST_PRIO
=
4
,
DRM_LIST_RECLAIM
=
5
}
list
;
/* Which list we're on */
}
list
;
/**< Which list we're on */
int
dev_priv_size
;
/*
Size of buffer private stoarge
*/
void
*
dev_private
;
/*
Per-buffer private storage
*/
int
dev_priv_size
;
/*
*< Size of buffer private storage
*/
void
*
dev_private
;
/*
*< Per-buffer private storage
*/
}
drm_buf_t
;
/
* bufs is one longer than it has to be */
/*
* bufs is one longer than it has to be */
typedef
struct
drm_waitlist
{
int
count
;
/*
Number of possible buffers
*/
drm_buf_t
**
bufs
;
/*
List of pointers to buffers
*/
drm_buf_t
**
rp
;
/*
Read pointer
*/
drm_buf_t
**
wp
;
/*
Write pointer
*/
drm_buf_t
**
end
;
/*
End pointer
*/
int
count
;
/*
*< Number of possible buffers
*/
drm_buf_t
**
bufs
;
/*
*< List of pointers to buffers
*/
drm_buf_t
**
rp
;
/*
*< Read pointer
*/
drm_buf_t
**
wp
;
/*
*< Write pointer
*/
drm_buf_t
**
end
;
/*
*< End pointer
*/
spinlock_t
read_lock
;
spinlock_t
write_lock
;
}
drm_waitlist_t
;
typedef
struct
drm_freelist
{
int
initialized
;
/*
Freelist in use
*/
atomic_t
count
;
/*
Number of free buffers
*/
drm_buf_t
*
next
;
/*
End pointer
*/
wait_queue_head_t
waiting
;
/*
Processes waiting on free bufs
*/
int
low_mark
;
/*
Low water mark
*/
int
high_mark
;
/*
High water mark
*/
atomic_t
wfh
;
/*
If waiting for high mark
*/
int
initialized
;
/*
*< Freelist in use
*/
atomic_t
count
;
/*
*< Number of free buffers
*/
drm_buf_t
*
next
;
/*
*< End pointer
*/
wait_queue_head_t
waiting
;
/*
*< Processes waiting on free bufs
*/
int
low_mark
;
/*
*< Low water mark
*/
int
high_mark
;
/*
*< High water mark
*/
atomic_t
wfh
;
/*
*< If waiting for high mark
*/
spinlock_t
lock
;
}
drm_freelist_t
;
/**
* Buffer entry. There is one of this for each buffer size order.
*/
typedef
struct
drm_buf_entry
{
int
buf_size
;
int
buf_count
;
drm_buf_t
*
buflist
;
int
buf_size
;
/**< size */
int
buf_count
;
/**< number of buffers */
drm_buf_t
*
buflist
;
/**< buffer list */
int
seg_count
;
int
page_order
;
unsigned
long
*
seglist
;
...
...
@@ -375,11 +467,19 @@ typedef struct drm_buf_entry {
drm_freelist_t
freelist
;
}
drm_buf_entry_t
;
/**
* Hardware lock.
*
* The lock structure is a simple cache-line aligned integer. To avoid
* processor bus contention on a multiprocessor system, there should not be any
* other data stored in the same cache line.
*/
typedef
struct
drm_hw_lock
{
__volatile__
unsigned
int
lock
;
char
padding
[
60
];
/*
Pad to cache line */
__volatile__
unsigned
int
lock
;
/**< lock variable */
char
padding
[
60
];
/**<
Pad to cache line */
}
drm_hw_lock_t
;
/** File private data */
typedef
struct
drm_file
{
int
authenticated
;
int
minor
;
...
...
@@ -394,69 +494,85 @@ typedef struct drm_file {
unsigned
long
lock_count
;
}
drm_file_t
;
/** Wait queue */
typedef
struct
drm_queue
{
atomic_t
use_count
;
/*
Outstanding uses (+1)
*/
atomic_t
finalization
;
/*
Finalization in progress
*/
atomic_t
block_count
;
/*
Count of processes waiting
*/
atomic_t
block_read
;
/*
Queue blocked for reads
*/
wait_queue_head_t
read_queue
;
/*
Processes waiting on block_read
*/
atomic_t
block_write
;
/*
Queue blocked for writes
*/
wait_queue_head_t
write_queue
;
/* Processes waiting on block_write */
atomic_t
use_count
;
/*
*< Outstanding uses (+1)
*/
atomic_t
finalization
;
/*
*< Finalization in progress
*/
atomic_t
block_count
;
/*
*< Count of processes waiting
*/
atomic_t
block_read
;
/*
*< Queue blocked for reads
*/
wait_queue_head_t
read_queue
;
/*
*< Processes waiting on block_read
*/
atomic_t
block_write
;
/*
*< Queue blocked for writes
*/
wait_queue_head_t
write_queue
;
/*
*<
Processes waiting on block_write */
#if 1
atomic_t
total_queued
;
/*
Total queued statistic
*/
atomic_t
total_flushed
;
/*
Total flushes statistic
*/
atomic_t
total_locks
;
/*
Total locks statistics
*/
atomic_t
total_queued
;
/*
*< Total queued statistic
*/
atomic_t
total_flushed
;
/*
*< Total flushes statistic
*/
atomic_t
total_locks
;
/*
*< Total locks statistics
*/
#endif
drm_ctx_flags_t
flags
;
/*
Context preserving and 2D-only
*/
drm_waitlist_t
waitlist
;
/*
Pending buffers
*/
wait_queue_head_t
flush_queue
;
/*
Processes waiting until flush
*/
drm_ctx_flags_t
flags
;
/*
*< Context preserving and 2D-only
*/
drm_waitlist_t
waitlist
;
/*
*< Pending buffers
*/
wait_queue_head_t
flush_queue
;
/*
*< Processes waiting until flush
*/
}
drm_queue_t
;
/**
* Lock data.
*/
typedef
struct
drm_lock_data
{
drm_hw_lock_t
*
hw_lock
;
/*
Hardware lock
*/
struct
file
*
filp
;
/*
File descr of lock holder (0=kernel)
*/
wait_queue_head_t
lock_queue
;
/*
Queue of blocked processes
*/
unsigned
long
lock_time
;
/*
Time of last lock in jiffies
*/
drm_hw_lock_t
*
hw_lock
;
/*
*< Hardware lock
*/
struct
file
*
filp
;
/*
*< File descr of lock holder (0=kernel)
*/
wait_queue_head_t
lock_queue
;
/*
*< Queue of blocked processes
*/
unsigned
long
lock_time
;
/*
*< Time of last lock in jiffies
*/
}
drm_lock_data_t
;
/**
* DMA data.
*/
typedef
struct
drm_device_dma
{
drm_buf_entry_t
bufs
[
DRM_MAX_ORDER
+
1
];
int
buf_count
;
drm_buf_t
**
buflist
;
/*
Vector of pointers info bufs
*/
drm_buf_entry_t
bufs
[
DRM_MAX_ORDER
+
1
];
/**< buffers, grouped by their size order */
int
buf_count
;
/**< total number of buffers */
drm_buf_t
**
buflist
;
/*
*< Vector of pointers into drm_device_dma::bufs
*/
int
seg_count
;
int
page_count
;
unsigned
long
*
pagelist
;
int
page_count
;
/**< number of pages */
unsigned
long
*
pagelist
;
/**< page list */
unsigned
long
byte_count
;
enum
{
_DRM_DMA_USE_AGP
=
0x01
,
_DRM_DMA_USE_SG
=
0x02
}
flags
;
/* DMA support */
drm_buf_t
*
this_buffer
;
/* Buffer being sent */
drm_buf_t
*
next_buffer
;
/* Selected buffer to send */
drm_queue_t
*
next_queue
;
/* Queue from which buffer selected*/
wait_queue_head_t
waiting
;
/* Processes waiting on free bufs */
/** \name DMA support */
/*@{*/
drm_buf_t
*
this_buffer
;
/**< Buffer being sent */
drm_buf_t
*
next_buffer
;
/**< Selected buffer to send */
drm_queue_t
*
next_queue
;
/**< Queue from which buffer selected*/
wait_queue_head_t
waiting
;
/**< Processes waiting on free bufs */
/*@}*/
}
drm_device_dma_t
;
#if __REALLY_HAVE_AGP
/**
* AGP memory entry. Stored as a doubly linked list.
*/
typedef
struct
drm_agp_mem
{
unsigned
long
handle
;
unsigned
long
handle
;
/**< handle */
struct
agp_memory
*
memory
;
unsigned
long
bound
;
/*
address */
unsigned
long
bound
;
/**<
address */
int
pages
;
struct
drm_agp_mem
*
prev
;
struct
drm_agp_mem
*
next
;
struct
drm_agp_mem
*
prev
;
/**< previous entry */
struct
drm_agp_mem
*
next
;
/**< next entry */
}
drm_agp_mem_t
;
/**
* AGP data.
*
* \sa DRM(agp_init)() and drm_device::agp.
*/
typedef
struct
drm_agp_head
{
struct
agp_kern_info
agp_info
;
drm_agp_mem_t
*
memory
;
unsigned
long
mode
;
int
enabled
;
int
acquired
;
struct
agp_kern_info
agp_info
;
/**< AGP device information */
drm_agp_mem_t
*
memory
;
/**< memory entries */
unsigned
long
mode
;
/**< AGP mode */
int
enabled
;
/**< whether the AGP bus as been enabled */
int
acquired
;
/**< whether the AGP device has been acquired */
unsigned
long
base
;
int
agp_mtrr
;
int
cant_use_aperture
;
...
...
@@ -464,6 +580,9 @@ typedef struct drm_agp_head {
}
drm_agp_head_t
;
#endif
/**
* Scatter-gather memory.
*/
typedef
struct
drm_sg_mem
{
unsigned
long
handle
;
void
*
virtual
;
...
...
@@ -477,9 +596,12 @@ typedef struct drm_sigdata {
drm_hw_lock_t
*
lock
;
}
drm_sigdata_t
;
/**
* Mappings list
*/
typedef
struct
drm_map_list
{
struct
list_head
head
;
drm_map_t
*
map
;
struct
list_head
head
;
/**< list head */
drm_map_t
*
map
;
/**< mapping */
}
drm_map_list_t
;
typedef
drm_map_t
drm_local_map_t
;
...
...
@@ -495,88 +617,108 @@ typedef struct drm_vbl_sig {
#endif
/**
* DRM device structure.
*/
typedef
struct
drm_device
{
const
char
*
name
;
/* Simple driver name */
char
*
unique
;
/* Unique identifier: e.g., busid */
int
unique_len
;
/* Length of unique field */
dev_t
device
;
/* Device number for mknod */
char
*
devname
;
/* For /proc/interrupts */
int
blocked
;
/* Blocked due to VC switch? */
struct
proc_dir_entry
*
root
;
/* Root for this device's entries */
/* Locks */
spinlock_t
count_lock
;
/* For inuse, open_count, buf_use */
struct
semaphore
struct_sem
;
/* For others */
/* Usage Counters */
int
open_count
;
/* Outstanding files open */
atomic_t
ioctl_count
;
/* Outstanding IOCTLs pending */
atomic_t
vma_count
;
/* Outstanding vma areas open */
int
buf_use
;
/* Buffers in use -- cannot alloc */
atomic_t
buf_alloc
;
/* Buffer allocation in progress */
/* Performance counters */
const
char
*
name
;
/**< Simple driver name */
char
*
unique
;
/**< Unique identifier: e.g., busid */
int
unique_len
;
/**< Length of unique field */
dev_t
device
;
/**< Device number for mknod */
char
*
devname
;
/**< For /proc/interrupts */
int
blocked
;
/**< Blocked due to VC switch? */
struct
proc_dir_entry
*
root
;
/**< Root for this device's entries */
/** \name Locks */
/*@{*/
spinlock_t
count_lock
;
/**< For inuse, drm_device::open_count, drm_device::buf_use */
struct
semaphore
struct_sem
;
/**< For others */
/*@}*/
/** \name Usage Counters */
/*@{*/
int
open_count
;
/**< Outstanding files open */
atomic_t
ioctl_count
;
/**< Outstanding IOCTLs pending */
atomic_t
vma_count
;
/**< Outstanding vma areas open */
int
buf_use
;
/**< Buffers in use -- cannot alloc */
atomic_t
buf_alloc
;
/**< Buffer allocation in progress */
/*@}*/
/** \name Performance counters */
/*@{*/
unsigned
long
counters
;
drm_stat_type_t
types
[
15
];
atomic_t
counts
[
15
];
/*@}*/
/* Authentication */
drm_file_t
*
file_first
;
drm_file_t
*
file_last
;
drm_magic_head_t
magiclist
[
DRM_HASH_SIZE
];
/** \name Authentication */
/*@{*/
drm_file_t
*
file_first
;
/**< file list head */
drm_file_t
*
file_last
;
/**< file list tail */
drm_magic_head_t
magiclist
[
DRM_HASH_SIZE
];
/**< magic hash table */
/*@}*/
/* Memory management */
drm_map_list_t
*
maplist
;
/* Linked list of regions */
/** \name Memory management */
/*@{*/
drm_map_list_t
*
maplist
;
/**< Linked list of regions */
int
map_count
;
/**< Number of mappable regions */
drm_map_t
**
context_sareas
;
drm_map_t
**
context_sareas
;
/**< per-context SAREA's */
int
max_context
;
drm_vma_entry_t
*
vmalist
;
/* List of vmas (for debugging) */
drm_lock_data_t
lock
;
/* Information on hardware lock */
/* DMA queues (contexts) */
int
queue_count
;
/* Number of active DMA queues */
int
queue_reserved
;
/* Number of reserved DMA queues */
int
queue_slots
;
/* Actual length of queuelist */
drm_queue_t
**
queuelist
;
/* Vector of pointers to DMA queues */
drm_device_dma_t
*
dma
;
/* Optional pointer for DMA support */
/* Context support */
int
irq
;
/* Interrupt used by board */
__volatile__
long
context_flag
;
/* Context swapping flag */
__volatile__
long
interrupt_flag
;
/* Interruption handler flag */
__volatile__
long
dma_flag
;
/* DMA dispatch flag */
struct
timer_list
timer
;
/* Timer for delaying ctx switch */
wait_queue_head_t
context_wait
;
/* Processes waiting on ctx switch */
int
last_checked
;
/* Last context checked for DMA */
int
last_context
;
/* Last current context */
unsigned
long
last_switch
;
/* jiffies at last context switch */
drm_vma_entry_t
*
vmalist
;
/**< List of vmas (for debugging) */
drm_lock_data_t
lock
;
/**< Information on hardware lock */
/*@}*/
/** \name DMA queues (contexts) */
/*@{*/
int
queue_count
;
/**< Number of active DMA queues */
int
queue_reserved
;
/**< Number of reserved DMA queues */
int
queue_slots
;
/**< Actual length of queuelist */
drm_queue_t
**
queuelist
;
/**< Vector of pointers to DMA queues */
drm_device_dma_t
*
dma
;
/**< Optional pointer for DMA support */
/*@}*/
/** \name Context support */
/*@{*/
int
irq
;
/**< Interrupt used by board */
__volatile__
long
context_flag
;
/**< Context swapping flag */
__volatile__
long
interrupt_flag
;
/**< Interruption handler flag */
__volatile__
long
dma_flag
;
/**< DMA dispatch flag */
struct
timer_list
timer
;
/**< Timer for delaying ctx switch */
wait_queue_head_t
context_wait
;
/**< Processes waiting on ctx switch */
int
last_checked
;
/**< Last context checked for DMA */
int
last_context
;
/**< Last current context */
unsigned
long
last_switch
;
/**< jiffies at last context switch */
/*@}*/
struct
work_struct
work
;
/** \name VBLANK IRQ support */
/*@{*/
#if __HAVE_VBL_IRQ
wait_queue_head_t
vbl_queue
;
wait_queue_head_t
vbl_queue
;
/**< VBLANK wait queue */
atomic_t
vbl_received
;
spinlock_t
vbl_lock
;
drm_vbl_sig_t
vbl_sigs
;
drm_vbl_sig_t
vbl_sigs
;
/**< signal list to send on VBLANK */
unsigned
int
vbl_pending
;
#endif
/*@}*/
cycles_t
ctx_start
;
cycles_t
lck_start
;
/* Callback to X server for context switch
and for heavy-handed reset. */
char
buf
[
DRM_BSZ
];
/* Output buffer */
char
*
buf_rp
;
/* Read pointer */
char
*
buf_wp
;
/* Write pointer */
char
*
buf_end
;
/* End pointer */
struct
fasync_struct
*
buf_async
;
/* Processes waiting for SIGIO */
wait_queue_head_t
buf_readers
;
/* Processes waiting to read */
wait_queue_head_t
buf_writers
;
/* Processes waiting to ctx switch */
char
buf
[
DRM_BSZ
];
/**< Output buffer */
char
*
buf_rp
;
/**< Read pointer */
char
*
buf_wp
;
/**< Write pointer */
char
*
buf_end
;
/**< End pointer */
struct
fasync_struct
*
buf_async
;
/**< Processes waiting for SIGIO */
wait_queue_head_t
buf_readers
;
/**< Processes waiting to read */
wait_queue_head_t
buf_writers
;
/**< Processes waiting to ctx switch */
#if __REALLY_HAVE_AGP
drm_agp_head_t
*
agp
;
drm_agp_head_t
*
agp
;
/**< AGP data */
#endif
struct
pci_dev
*
pdev
;
struct
pci_dev
*
pdev
;
/**< PCI device structure */
#ifdef __alpha__
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
struct
pci_controler
*
hose
;
...
...
@@ -584,17 +726,17 @@ typedef struct drm_device {
struct
pci_controller
*
hose
;
#endif
#endif
drm_sg_mem_t
*
sg
;
/* Scatter gather memory */
unsigned
long
*
ctx_bitmap
;
void
*
dev_private
;
drm_sigdata_t
sigdata
;
/* For block_all_signals */
drm_sg_mem_t
*
sg
;
/*
*<
Scatter gather memory */
unsigned
long
*
ctx_bitmap
;
/**< context bitmap */
void
*
dev_private
;
/**< device private data */
drm_sigdata_t
sigdata
;
/*
*<
For block_all_signals */
sigset_t
sigmask
;
}
drm_device_t
;
/*
================================================================
* Internal function definitions
*/
/*
*****************************************************************/
/** \name Internal function definitions */
/*@{
*/
/* Misc. support (drm_init.h) */
extern
int
DRM
(
flags
);
...
...
@@ -653,7 +795,8 @@ extern unsigned long DRM(alloc_pages)(int order, int area);
extern
void
DRM
(
free_pages
)(
unsigned
long
address
,
int
order
,
int
area
);
extern
void
*
DRM
(
ioremap
)(
unsigned
long
offset
,
unsigned
long
size
,
drm_device_t
*
dev
);
extern
void
*
DRM
(
ioremap_nocache
)(
unsigned
long
offset
,
unsigned
long
size
,
drm_device_t
*
dev
);
extern
void
*
DRM
(
ioremap_nocache
)(
unsigned
long
offset
,
unsigned
long
size
,
drm_device_t
*
dev
);
extern
void
DRM
(
ioremapfree
)(
void
*
pt
,
unsigned
long
size
,
drm_device_t
*
dev
);
#if __REALLY_HAVE_AGP
...
...
@@ -842,5 +985,7 @@ extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
unsigned
long
addr
,
dma_addr_t
bus_addr
);
/*@}*/
#endif
/* __KERNEL__ */
#endif
drivers/char/drm/drm_agpsupport.h
View file @
fd80ab16
/* drm_agpsupport.h -- DRM support for AGP/GART backend -*- linux-c -*-
* Created: Mon Dec 13 09:56:45 1999 by faith@precisioninsight.com
/**
* \file drm_agpsupport.h
* DRM support for AGP/GART backend
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
...
...
@@ -23,10 +29,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Author:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
...
...
@@ -34,11 +36,27 @@
#if __REALLY_HAVE_AGP
#define DRM_AGP_GET (drm_agp_t *)inter_module_get("drm_agp")
#define DRM_AGP_PUT inter_module_put("drm_agp")
/**
* Pointer to the drm_agp_t structure made available by the agpgart module.
*/
static
const
drm_agp_t
*
drm_agp
=
NULL
;
/**
* AGP information ioctl.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a (output) drm_agp_info structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device has been initialized and acquired and fills in the
* drm_agp_info structure with the information in drm_agp_head::agp_info.
*/
int
DRM
(
agp_info
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -66,6 +84,18 @@ int DRM(agp_info)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Acquire the AGP device (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device hasn't been acquired before and calls
* drm_agp->acquire().
*/
int
DRM
(
agp_acquire
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -80,6 +110,17 @@ int DRM(agp_acquire)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Release the AGP device (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device has been acquired and calls drm_agp->release().
*/
int
DRM
(
agp_release
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -94,11 +135,28 @@ int DRM(agp_release)(struct inode *inode, struct file *filp,
}
/**
* Release the AGP device.
*
* Calls drm_agp->release().
*/
void
DRM
(
agp_do_release
)(
void
)
{
if
(
drm_agp
->
release
)
drm_agp
->
release
();
}
/**
* Enable the AGP bus.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_agp_mode structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device has been acquired but not enabled, and calls
* drm_agp->enable().
*/
int
DRM
(
agp_enable
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -119,6 +177,18 @@ int DRM(agp_enable)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Allocate AGP memory.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_agp_buffer structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and has been acquired, allocates the
* memory via alloc_agp() and creates a drm_agp_mem entry for it.
*/
int
DRM
(
agp_alloc
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -168,6 +238,15 @@ int DRM(agp_alloc)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Search for the AGP memory entry associated with a handle.
*
* \param dev DRM device structure.
* \param handle AGP memory handle.
* \return pointer to the drm_agp_mem structure associated with \p handle.
*
* Walks through drm_agp_head::memory until finding a matching handle.
*/
static
drm_agp_mem_t
*
DRM
(
agp_lookup_entry
)(
drm_device_t
*
dev
,
unsigned
long
handle
)
{
...
...
@@ -179,6 +258,18 @@ static drm_agp_mem_t *DRM(agp_lookup_entry)(drm_device_t *dev,
return
NULL
;
}
/**
* Unbind AGP memory from the GATT (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_agp_binding structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and acquired, looks-up the AGP memory
* entry and passes it to the unbind_agp() function.
*/
int
DRM
(
agp_unbind
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -200,6 +291,19 @@ int DRM(agp_unbind)(struct inode *inode, struct file *filp,
return
ret
;
}
/**
* Bind AGP memory into the GATT (ioctl)
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_agp_binding structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and has been acquired and that no memory
* is currently bound into the GATT. Looks-up the AGP memory entry and passes
* it to bind_agp() function.
*/
int
DRM
(
agp_bind
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -225,6 +329,20 @@ int DRM(agp_bind)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Free AGP memory (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_agp_buffer structure.
* \return zero on success or a negative number on failure.
*
* Verifies the AGP device is present and has been acquired and looks up the
* AGP memory entry. If the memory it's currently bound, unbind it via
* unbind_agp(). Frees it via free_agp() as well as the entry itself
* and unlinks from the doubly linked list it's inserted in.
*/
int
DRM
(
agp_free
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -248,6 +366,15 @@ int DRM(agp_free)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Initialize the AGP resources.
*
* \return pointer to a drm_agp_head structure.
*
* Gets the drm_agp_t structure which is made available by the agpgart module
* via the inter_module_* functions. Creates and initializes a drm_agp_head
* structure.
*/
drm_agp_head_t
*
DRM
(
agp_init
)(
void
)
{
drm_agp_head_t
*
head
=
NULL
;
...
...
@@ -274,18 +401,25 @@ drm_agp_head_t *DRM(agp_init)(void)
return
head
;
}
/**
* Free the AGP resources.
*
* Releases the pointer in ::drm_agp.
*/
void
DRM
(
agp_uninit
)(
void
)
{
DRM_AGP_PUT
;
drm_agp
=
NULL
;
}
/** Calls drm_agp->allocate_memory() */
struct
agp_memory
*
DRM
(
agp_allocate_memory
)(
size_t
pages
,
u32
type
)
{
if
(
!
drm_agp
->
allocate_memory
)
return
NULL
;
return
drm_agp
->
allocate_memory
(
pages
,
type
);
}
/** Calls drm_agp->free_memory() */
int
DRM
(
agp_free_memory
)(
struct
agp_memory
*
handle
)
{
if
(
!
handle
||
!
drm_agp
->
free_memory
)
return
0
;
...
...
@@ -293,12 +427,14 @@ int DRM(agp_free_memory)(struct agp_memory *handle)
return
1
;
}
/** Calls drm_agp->bind_memory() */
int
DRM
(
agp_bind_memory
)(
struct
agp_memory
*
handle
,
off_t
start
)
{
if
(
!
handle
||
!
drm_agp
->
bind_memory
)
return
-
EINVAL
;
return
drm_agp
->
bind_memory
(
handle
,
start
);
}
/** Calls drm_agp->unbind_memory() */
int
DRM
(
agp_unbind_memory
)(
struct
agp_memory
*
handle
)
{
if
(
!
handle
||
!
drm_agp
->
unbind_memory
)
return
-
EINVAL
;
...
...
drivers/char/drm/drm_auth.h
View file @
fd80ab16
/* drm_auth.h -- IOCTLs for authentication -*- linux-c -*-
/**
* \file drm_auth.h
* IOCTLs for authentication
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,19 +31,34 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
/**
* Generate a hash key from a magic.
*
* \param magic magic.
* \return hash key.
*
* The key is the modulus of the hash table size, #DRM_HASH_SIZE, which must be
* a power of 2.
*/
static
int
DRM
(
hash_magic
)(
drm_magic_t
magic
)
{
return
magic
&
(
DRM_HASH_SIZE
-
1
);
}
/**
* Find the file with the given magic number.
*
* \param dev DRM device.
* \param magic magic number.
*
* Searches in drm_device::magiclist within all files with the same hash key
* the one with matching magic number, while holding the drm_device::struct_sem
* lock.
*/
static
drm_file_t
*
DRM
(
find_file
)(
drm_device_t
*
dev
,
drm_magic_t
magic
)
{
drm_file_t
*
retval
=
NULL
;
...
...
@@ -53,6 +76,17 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic)
return
retval
;
}
/**
* Adds a magic number.
*
* \param dev DRM device.
* \param priv file private data.
* \param magic magic number.
*
* Creates a drm_magic_entry structure and appends to the linked list
* associated the magic number hash key in drm_device::magiclist, while holding
* the drm_device::struct_sem lock.
*/
int
DRM
(
add_magic
)(
drm_device_t
*
dev
,
drm_file_t
*
priv
,
drm_magic_t
magic
)
{
int
hash
;
...
...
@@ -81,12 +115,22 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
return
0
;
}
/**
* Remove a magic number.
*
* \param dev DRM device.
* \param magic magic number.
*
* Searches and unlinks the entry in drm_device::magiclist with the magic
* number hash key, while holding the drm_device::struct_sem lock.
*/
int
DRM
(
remove_magic
)(
drm_device_t
*
dev
,
drm_magic_t
magic
)
{
drm_magic_entry_t
*
prev
=
NULL
;
drm_magic_entry_t
*
pt
;
int
hash
;
DRM_DEBUG
(
"%d
\n
"
,
magic
);
hash
=
DRM
(
hash_magic
)(
magic
);
...
...
@@ -113,6 +157,19 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
return
-
EINVAL
;
}
/**
* Get a unique magic number (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a resulting drm_auth structure.
* \return zero on success, or a negative number on failure.
*
* If there is a magic number in drm_file::magic then use it, otherwise
* searches an unique non-zero magic number and add it associating it with \p
* filp.
*/
int
DRM
(
getmagic
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -142,6 +199,17 @@ int DRM(getmagic)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Authenticate with a magic.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_auth structure.
* \return zero if authentication successed, or a negative number otherwise.
*
* Checks if \p filp is associated with the magic number passed in \arg.
*/
int
DRM
(
authmagic
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
drivers/char/drm/drm_bufs.h
View file @
fd80ab16
/* drm_bufs.h -- Generic buffer template -*- linux-c -*-
/**
* \file drm_bufs.h
* Generic buffer template
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,10 +31,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include <linux/vmalloc.h>
...
...
@@ -51,8 +55,15 @@
#endif
#endif
/*
* Compute order. Can be made faster.
/**
* Compute size order. Returns the exponent of the smaller power of two which
* is greater or equal to given number.
*
* \param size size.
* \return order.
*
* \todo Can be made faster.
*/
int
DRM
(
order
)(
unsigned
long
size
)
{
...
...
@@ -67,6 +78,19 @@ int DRM(order)( unsigned long size )
return
order
;
}
/**
* Ioctl to specify a range of memory that is available for mapping by a non-root process.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_map structure.
* \return zero on success or a negative value on error.
*
* Adjusts the memory offset to its absolute value according to the mapping
* type. Adds the map to the map list drm_device::maplist. Adds MTRR's where
* applicable and if supported by the kernel.
*/
int
DRM
(
addmap
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -186,10 +210,22 @@ int DRM(addmap)( struct inode *inode, struct file *filp,
}
/* Remove a map private from list and deallocate resources if the mapping
/**
* Remove a map private from list and deallocate resources if the mapping
* isn't in use.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_map_t structure.
* \return zero on success or a negative value on error.
*
* Searches the map on drm_device::maplist, removes it from the list, see if
* its being used, and free any associate resource (such as MTRR's) if it's not
* being on use.
*
* \sa addmap().
*/
int
DRM
(
rmmap
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -262,7 +298,13 @@ int DRM(rmmap)(struct inode *inode, struct file *filp,
#if __HAVE_DMA
/**
* Cleanup after an error on one of the addbufs() functions.
*
* \param entry buffer entry where the error occurred.
*
* Frees any pages and buffers associated with the given entry.
*/
static
void
DRM
(
cleanup_buf_error
)(
drm_buf_entry_t
*
entry
)
{
int
i
;
...
...
@@ -305,6 +347,19 @@ static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry)
}
#if __REALLY_HAVE_AGP
/**
* Add AGP buffers for DMA transfers (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_buf_desc_t request.
* \return zero on success or a negative number on failure.
*
* After some sanity checks creates a drm_buf structure for each buffer and
* reallocates the buffer list of the same size order to accommodate the new
* buffers.
*/
int
DRM
(
addbufs_agp
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -884,6 +939,20 @@ int DRM(addbufs_sg)( struct inode *inode, struct file *filp,
}
#endif
/* __HAVE_SG */
/**
* Add buffers for DMA transfers (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_buf_desc_t request.
* \return zero on success or a negative number on failure.
*
* According with the memory type specified in drm_buf_desc::flags and the
* build options, it dispatches the call either to addbufs_agp(),
* addbufs_sg() or addbufs_pci() for AGP, scatter-gather or consistent
* PCI memory respectively.
*/
int
DRM
(
addbufs
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -910,6 +979,24 @@ int DRM(addbufs)( struct inode *inode, struct file *filp,
#endif
}
/**
* Get information about the buffer mappings.
*
* This was originally mean for debugging purposes, or by a sophisticated
* client library to determine how best to use the available buffers (e.g.,
* large buffers can be used for image transfer).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_buf_info structure.
* \return zero on success or a negative number on failure.
*
* Increments drm_device::buf_use while holding the drm_device::count_lock
* lock, preventing of allocating more buffers after this call. Information
* about each requested buffer is then copied into user space.
*/
int
DRM
(
infobufs
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -981,6 +1068,20 @@ int DRM(infobufs)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Specifies a low and high water mark for buffer allocation
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg a pointer to a drm_buf_desc structure.
* \return zero on success or a negative number on failure.
*
* Verifies that the size order is bounded between the admissible orders and
* updates the respective drm_device_dma::bufs entry low and high water mark.
*
* \note This ioctl is deprecated and mostly never used.
*/
int
DRM
(
markbufs
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -1015,6 +1116,18 @@ int DRM(markbufs)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Unreserve the buffers in list, previously reserved using drmDMA.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_buf_free structure.
* \return zero on success or a negative number on failure.
*
* Calls free_buffer() for each used buffer.
* This function is primarily used for debugging.
*/
int
DRM
(
freebufs
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -1056,6 +1169,19 @@ int DRM(freebufs)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Maps all of the DMA buffers into client-virtual space (ioctl).
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg pointer to a drm_buf_map structure.
* \return zero on success or a negative number on failure.
*
* Maps the AGP or SG buffer region with do_mmap(), and copies information
* about each buffer into user space. The PCI buffers are already mapped on the
* addbufs_pci() call.
*/
int
DRM
(
mapbufs
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
drivers/char/drm/drm_context.h
View file @
fd80ab16
/* drm_context.h -- IOCTLs for generic contexts -*- linux-c -*-
/**
* \file drm_context.h
* IOCTLs for generic contexts
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Fri Nov 24 18:31:37 2000 by gareth@valinux.com
*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,10 +31,9 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
/*
* ChangeLog:
* 2001-11-16 Torsten Duwe <duwe@caldera.de>
* added context constructor/destructor hooks,
...
...
@@ -40,10 +47,20 @@
#endif
/*
================================================================
* Context bitmap support
*/
/*
*****************************************************************/
/** \name Context bitmap support */
/*@{
*/
/**
* Free a handle from the context bitmap.
*
* \param dev DRM device.
* \param ctx_handle context handle.
*
* Clears the bit specified by \p ctx_handle in drm_device::ctx_bitmap and the entry
* in drm_device::context_sareas, while holding the drm_device::struct_sem
* lock.
*/
void
DRM
(
ctxbitmap_free
)(
drm_device_t
*
dev
,
int
ctx_handle
)
{
if
(
ctx_handle
<
0
)
goto
failed
;
...
...
@@ -62,6 +79,16 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
return
;
}
/**
* Context bitmap allocation.
*
* \param dev DRM device.
* \return (non-negative) context handle on success or a negative number on failure.
*
* Find the first zero bit in drm_device::ctx_bitmap and (re)allocates
* drm_device::context_sareas to accommodate the new entry while holding the
* drm_device::struct_sem lock.
*/
int
DRM
(
ctxbitmap_next
)(
drm_device_t
*
dev
)
{
int
bit
;
...
...
@@ -112,6 +139,14 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
return
-
1
;
}
/**
* Context bitmap initialization.
*
* \param dev DRM device.
*
* Allocates and initialize drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock.
*/
int
DRM
(
ctxbitmap_init
)(
drm_device_t
*
dev
)
{
int
i
;
...
...
@@ -137,6 +172,14 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
return
0
;
}
/**
* Context bitmap cleanup.
*
* \param dev DRM device.
*
* Frees drm_device::ctx_bitmap and drm_device::context_sareas, while holding
* the drm_device::struct_sem lock.
*/
void
DRM
(
ctxbitmap_cleanup
)(
drm_device_t
*
dev
)
{
down
(
&
dev
->
struct_sem
);
...
...
@@ -148,10 +191,24 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
up
(
&
dev
->
struct_sem
);
}
/* ================================================================
* Per Context SAREA Support
*/
/*@}*/
/******************************************************************/
/** \name Per Context SAREA Support */
/*@{*/
/**
* Get per-context SAREA.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx_priv_map structure.
* \return zero on success or a negative number on failure.
*
* Gets the map from drm_device::context_sareas with the handle specified and
* returns its handle.
*/
int
DRM
(
getsareactx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -180,6 +237,18 @@ int DRM(getsareactx)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Set per-context SAREA.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx_priv_map structure.
* \return zero on success or a negative number on failure.
*
* Searches the mapping specified in \p arg and update the entry in
* drm_device::context_sareas with it.
*/
int
DRM
(
setsareactx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -218,10 +287,22 @@ int DRM(setsareactx)(struct inode *inode, struct file *filp,
return
0
;
}
/* ================================================================
* The actual DRM context handling routines
*/
/*@}*/
/******************************************************************/
/** \name The actual DRM context handling routines */
/*@{*/
/**
* Switch context.
*
* \param dev DRM device.
* \param old old context handle.
* \param new new context handle.
* \return zero on success or a negative number on failure.
*
* Attempt to set drm_device::context_flag.
*/
int
DRM
(
context_switch
)(
drm_device_t
*
dev
,
int
old
,
int
new
)
{
if
(
test_and_set_bit
(
0
,
&
dev
->
context_flag
)
)
{
...
...
@@ -240,6 +321,17 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new )
return
0
;
}
/**
* Complete context switch.
*
* \param dev DRM device.
* \param new new context handle.
* \return zero on success or a negative number on failure.
*
* Updates drm_device::last_context and drm_device::last_switch. Verifies the
* hardware lock is held, clears the drm_device::context_flag and wakes up
* drm_device::context_wait.
*/
int
DRM
(
context_switch_complete
)(
drm_device_t
*
dev
,
int
new
)
{
dev
->
last_context
=
new
;
/* PRE/POST: This is the _only_ writer. */
...
...
@@ -258,6 +350,15 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new )
return
0
;
}
/**
* Reserve contexts.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx_res structure.
* \return zero on success or a negative number on failure.
*/
int
DRM
(
resctx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -284,6 +385,17 @@ int DRM(resctx)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Add context.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure.
*
* Get a new handle for the context and copy to userspace.
*/
int
DRM
(
addctx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -322,6 +434,15 @@ int DRM(modctx)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Get context.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure.
*/
int
DRM
(
getctx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -338,6 +459,17 @@ int DRM(getctx)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Switch context.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure.
*
* Calls context_switch().
*/
int
DRM
(
switchctx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -352,6 +484,17 @@ int DRM(switchctx)( struct inode *inode, struct file *filp,
return
DRM
(
context_switch
)(
dev
,
dev
->
last_context
,
ctx
.
handle
);
}
/**
* New context.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure.
*
* Calls context_switch_complete().
*/
int
DRM
(
newctx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -368,6 +511,17 @@ int DRM(newctx)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Remove context.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument pointing to a drm_ctx structure.
* \return zero on success or a negative number on failure.
*
* If not the special kernel context, calls ctxbitmap_free() to free the specified context.
*/
int
DRM
(
rmctx
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -392,3 +546,4 @@ int DRM(rmctx)( struct inode *inode, struct file *filp,
return
0
;
}
/*@}*/
drivers/char/drm/drm_dma.h
View file @
fd80ab16
/* drm_dma.c -- DMA IOCTL and function support -*- linux-c -*-
/**
* \file drm_dma.h
* DMA IOCTL and function support
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,10 +31,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
...
...
@@ -51,6 +55,14 @@
#if __HAVE_DMA
/**
* Initialize the DMA data.
*
* \param dev DRM device.
* \return zero on success or a negative value on failure.
*
* Allocate and initialize a drm_device_dma structure.
*/
int
DRM
(
dma_setup
)(
drm_device_t
*
dev
)
{
int
i
;
...
...
@@ -67,6 +79,14 @@ int DRM(dma_setup)( drm_device_t *dev )
return
0
;
}
/**
* Cleanup the DMA resources.
*
* \param dev DRM device.
*
* Free all pages associated with DMA buffers, the buffers and pages lists, and
* finally the the drm_device::dma structure itself.
*/
void
DRM
(
dma_takedown
)(
drm_device_t
*
dev
)
{
drm_device_dma_t
*
dma
=
dev
->
dma
;
...
...
@@ -128,7 +148,14 @@ void DRM(dma_takedown)(drm_device_t *dev)
}
/**
* Free a buffer.
*
* \param dev DRM device.
* \param buf buffer to free.
*
* Resets the fields of \p buf.
*/
void
DRM
(
free_buffer
)(
drm_device_t
*
dev
,
drm_buf_t
*
buf
)
{
if
(
!
buf
)
return
;
...
...
@@ -154,6 +181,13 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
}
#if !__HAVE_DMA_RECLAIM
/**
* Reclaim the buffers.
*
* \param filp file pointer.
*
* Frees each buffer associated with \p filp not already on the hardware.
*/
void
DRM
(
reclaim_buffers
)(
struct
file
*
filp
)
{
drm_file_t
*
priv
=
filp
->
private_data
;
...
...
@@ -185,6 +219,16 @@ void DRM(reclaim_buffers)( struct file *filp )
#if __HAVE_DMA_IRQ
/**
* Install IRQ handler.
*
* \param dev DRM device.
* \param irq IRQ number.
*
* Initializes the IRQ related data, and setups drm_device::vbl_queue. Installs the handler, calling the driver
* \c DRM(driver_irq_preinstall)() and \c DRM(driver_irq_postinstall)() functions
* before and after the installation.
*/
int
DRM
(
irq_install
)(
drm_device_t
*
dev
,
int
irq
)
{
int
ret
;
...
...
@@ -250,6 +294,13 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
return
0
;
}
/**
* Uninstall the IRQ handler.
*
* \param dev DRM device.
*
* Calls the driver's \c DRM(driver_irq_uninstall)() function, and stops the irq.
*/
int
DRM
(
irq_uninstall
)(
drm_device_t
*
dev
)
{
int
irq
;
...
...
@@ -271,6 +322,17 @@ int DRM(irq_uninstall)( drm_device_t *dev )
return
0
;
}
/**
* IRQ control ioctl.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_control structure.
* \return zero on success or a negative number on failure.
*
* Calls irq_install() or irq_uninstall() according to \p arg.
*/
int
DRM
(
control
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -293,6 +355,25 @@ int DRM(control)( struct inode *inode, struct file *filp,
#if __HAVE_VBL_IRQ
/**
* Wait for VBLANK.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param data user argument, pointing to a drm_wait_vblank structure.
* \return zero on success or a negative number on failure.
*
* Verifies the IRQ is installed.
*
* If a signal is requested checks if this task has already scheduled the same signal
* for the same vblank sequence number - nothing to be done in
* that case. If the number of tasks waiting for the interrupt exceeds 100 the
* function fails. Otherwise adds a new entry to drm_device::vbl_sigs for this
* task.
*
* If a signal is not requested, then calls vblank_wait().
*/
int
DRM
(
wait_vblank
)(
DRM_IOCTL_ARGS
)
{
drm_file_t
*
priv
=
filp
->
private_data
;
...
...
@@ -381,6 +462,15 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
return
ret
;
}
/**
* Send the VBLANK signals.
*
* \param dev DRM device.
*
* Sends a signal for each task in drm_device::vbl_sigs and empties the list.
*
* If a signal is not requested, then calls vblank_wait().
*/
void
DRM
(
vbl_send_signals
)(
drm_device_t
*
dev
)
{
struct
list_head
*
list
,
*
tmp
;
...
...
drivers/char/drm/drm_drawable.h
View file @
fd80ab16
/* drm_drawable.h -- IOCTLs for drawables -*- linux-c -*-
/**
* \file drm_drawable.h
* IOCTLs for drawables
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,14 +31,11 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
/** No-op. */
int
DRM
(
adddraw
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -43,6 +48,7 @@ int DRM(adddraw)(struct inode *inode, struct file *filp,
return
0
;
}
/** No-op. */
int
DRM
(
rmdraw
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
drivers/char/drm/drm_drv.h
View file @
fd80ab16
/* drm_drv.h -- Generic driver template -*- linux-c -*-
/**
* \file drm_drv.h
* Generic driver template
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*
* To use this template, you must at least define the following (samples
* given for the MGA driver):
*
* \code
* #define DRIVER_AUTHOR "VA Linux Systems, Inc."
*
* #define DRIVER_NAME "mga"
* #define DRIVER_DESC "Matrox G200/G400"
* #define DRIVER_DATE "20001127"
*
* #define DRIVER_MAJOR 2
* #define DRIVER_MINOR 0
* #define DRIVER_PATCHLEVEL 2
*
* #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mga_ioctls )
*
* #define DRM(x) mga_##x
* \endcode
*/
/*
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,29 +50,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
/*
* To use this template, you must at least define the following (samples
* given for the MGA driver):
*
* #define DRIVER_AUTHOR "VA Linux Systems, Inc."
*
* #define DRIVER_NAME "mga"
* #define DRIVER_DESC "Matrox G200/G400"
* #define DRIVER_DATE "20001127"
*
* #define DRIVER_MAJOR 2
* #define DRIVER_MINOR 0
* #define DRIVER_PATCHLEVEL 2
*
* #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mga_ioctls )
*
* #define DRM(x) mga_##x
*/
#ifndef __MUST_HAVE_AGP
...
...
@@ -134,12 +138,13 @@ static struct file_operations DRM(fops) = { \
#endif
#ifndef MODULE
/* DRM(options) is called by the kernel to parse command-line options
* passed via the boot-loader (e.g., LILO). It calls the insmod option
* routine, drm_parse_drm.
*/
/* Use an additional macro to avoid preprocessor troubles */
/** Use an additional macro to avoid preprocessor troubles */
#define DRM_OPTIONS_FUNC DRM(options)
/**
* Called by the kernel to parse command-line options passed via the
* boot-loader (e.g., LILO). It calls the insmod option routine,
* parse_options().
*/
static
int
__init
DRM
(
options
)(
char
*
str
)
{
DRM
(
parse_options
)(
str
);
...
...
@@ -150,7 +155,7 @@ __setup( DRIVER_NAME "=", DRM_OPTIONS_FUNC );
#undef DRM_OPTIONS_FUNC
#endif
/*
/*
*
* The default number of instances (minor numbers) to initialize.
*/
#ifndef DRIVER_NUM_CARDS
...
...
@@ -163,6 +168,7 @@ static int DRM(numdevs) = 0;
DRIVER_FOPS
;
/** Ioctl table */
static
drm_ioctl_desc_t
DRM
(
ioctls
)[]
=
{
[
DRM_IOCTL_NR
(
DRM_IOCTL_VERSION
)]
=
{
DRM
(
version
),
0
,
0
},
[
DRM_IOCTL_NR
(
DRM_IOCTL_GET_UNIQUE
)]
=
{
DRM
(
getunique
),
0
,
0
},
...
...
@@ -348,7 +354,8 @@ static int DRM(setup)( drm_device_t *dev )
DRM_DEBUG
(
"
\n
"
);
/* The kernel's context could be created here, but is now created
/*
* The kernel's context could be created here, but is now created
* in drm_dma_enqueue. This is more resource-efficient for
* hardware that does not do DMA, but may mean that
* drm_select_queue fails between the time the interrupt is
...
...
@@ -359,6 +366,15 @@ static int DRM(setup)( drm_device_t *dev )
}
/**
* Take down the DRM device.
*
* \param dev DRM device structure.
*
* Frees every resource in \p dev.
*
* \sa drm_device and setup().
*/
static
int
DRM
(
takedown
)(
drm_device_t
*
dev
)
{
drm_magic_entry_t
*
pt
,
*
next
;
...
...
@@ -516,8 +532,12 @@ static int DRM(takedown)( drm_device_t *dev )
return
0
;
}
/*
/*
*
* Figure out how many instances to initialize.
*
* \return number of cards found.
*
* Searches for every PCI card in \c DRIVER_CARD_LIST with matching vendor and device ids.
*/
static
int
drm_count_cards
(
void
)
{
...
...
@@ -551,8 +571,18 @@ static int drm_count_cards(void)
return
num
;
}
/* drm_init is called via init_module at module load time, or via
/**
* Module initialization. Called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported).
*
* \return zero on success or a negative number on failure.
*
* Allocates and initialize an array of drm_device structures, and attempts to
* initialize all available devices, using consecutive minors, registering the
* stubs and initializing the AGP device.
*
* Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
* after the initialization for driver customization.
*/
static
int
__init
drm_init
(
void
)
{
...
...
@@ -641,7 +671,12 @@ static int __init drm_init( void )
return
0
;
}
/* drm_cleanup is called via cleanup_module at module unload time.
/**
* Called via cleanup_module() at module unload time.
*
* Cleans up all DRM device, calling takedown().
*
* \sa drm_init().
*/
static
void
__exit
drm_cleanup
(
void
)
{
...
...
@@ -694,6 +729,17 @@ module_init( drm_init );
module_exit
(
drm_cleanup
);
/**
* Get version information
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_version structure.
* \return zero on success or negative number on failure.
*
* Fills in the version information in \p arg.
*/
int
DRM
(
version
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -729,6 +775,17 @@ int DRM(version)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Open file.
*
* \param inode device inode
* \param filp file pointer.
* \return zero on success or a negative number on failure.
*
* Searches the DRM device with the same minor number, calls open_helper(), and
* increments the device open count. If the open count was previous at zero,
* i.e., it's the first that the device is open, then calls setup().
*/
int
DRM
(
open
)(
struct
inode
*
inode
,
struct
file
*
filp
)
{
drm_device_t
*
dev
=
NULL
;
...
...
@@ -759,6 +816,18 @@ int DRM(open)( struct inode *inode, struct file *filp )
return
retcode
;
}
/**
* Release file.
*
* \param inode device inode
* \param filp file pointer.
* \return zero on success or a negative number on failure.
*
* If the hardware lock is held then free it, and take it again for the kernel
* context since it's necessary to reclaim buffers. Unlink the file private
* data from its list and free it. Decreases the open count and if it reaches
* zero calls takedown().
*/
int
DRM
(
release
)(
struct
inode
*
inode
,
struct
file
*
filp
)
{
drm_file_t
*
priv
=
filp
->
private_data
;
...
...
@@ -885,7 +954,17 @@ int DRM(release)( struct inode *inode, struct file *filp )
return
retcode
;
}
/* DRM(ioctl) is called whenever a process performs an ioctl on /dev/drm.
/**
* Called whenever a process performs an ioctl on /dev/drm.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument.
* \return zero on success or negative number on failure.
*
* Looks up the ioctl function in the ::ioctls table, checking for root
* previleges if so required, and dispatches to the respective function.
*/
int
DRM
(
ioctl
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
...
...
@@ -926,6 +1005,17 @@ int DRM(ioctl)( struct inode *inode, struct file *filp,
return
retcode
;
}
/**
* Lock ioctl.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_lock structure.
* \return zero on success or negative number on failure.
*
* Add the current task to the lock wait queue, and attempt to take to lock.
*/
int
DRM
(
lock
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -1031,7 +1121,17 @@ int DRM(lock)( struct inode *inode, struct file *filp,
return
ret
;
}
/**
* Unlock ioctl.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_lock structure.
* \return zero on success or negative number on failure.
*
* Transfer and free the lock.
*/
int
DRM
(
unlock
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
drivers/char/drm/drm_fops.h
View file @
fd80ab16
/* drm_fops.h -- File operations for DRM -*- linux-c -*-
/**
* \file drm_fops.h
* File operations for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Daryll Strauss <daryll@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,18 +32,23 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Daryll Strauss <daryll@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
#include <linux/poll.h>
/* drm_open is called whenever a process opens /dev/drm. */
/**
* Called whenever a process opens /dev/drm.
*
* \param inode device inode.
* \param filp file pointer.
* \param dev device.
* \return zero on success or a negative number on failure.
*
* Creates and initializes a drm_file structure for the file private data in \p
* filp and add it into the double linked list in \p dev.
*/
int
DRM
(
open_helper
)(
struct
inode
*
inode
,
struct
file
*
filp
,
drm_device_t
*
dev
)
{
int
minor
=
minor
(
inode
->
i_rdev
);
...
...
@@ -90,6 +104,7 @@ int DRM(open_helper)(struct inode *inode, struct file *filp, drm_device_t *dev)
return
0
;
}
/** No-op. */
int
DRM
(
flush
)(
struct
file
*
filp
)
{
drm_file_t
*
priv
=
filp
->
private_data
;
...
...
@@ -100,6 +115,7 @@ int DRM(flush)(struct file *filp)
return
0
;
}
/** No-op. */
int
DRM
(
fasync
)(
int
fd
,
struct
file
*
filp
,
int
on
)
{
drm_file_t
*
priv
=
filp
->
private_data
;
...
...
@@ -113,6 +129,7 @@ int DRM(fasync)(int fd, struct file *filp, int on)
}
#if !__HAVE_DRIVER_FOPS_POLL
/** No-op. */
unsigned
int
DRM
(
poll
)(
struct
file
*
filp
,
struct
poll_table_struct
*
wait
)
{
return
0
;
...
...
@@ -121,6 +138,7 @@ unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait)
#if !__HAVE_DRIVER_FOPS_READ
/** No-op. */
ssize_t
DRM
(
read
)(
struct
file
*
filp
,
char
*
buf
,
size_t
count
,
loff_t
*
off
)
{
return
0
;
...
...
drivers/char/drm/drm_init.h
View file @
fd80ab16
/* drm_init.h -- Setup/Cleanup for DRM -*- linux-c -*-
/**
* \file drm_init.h
* Setup/Cleanup for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,22 +31,23 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
/** Debug flags. Set by parse_option(). */
#if 0
int DRM(flags) = DRM_FLAG_DEBUG;
#else
int
DRM
(
flags
)
=
0
;
#endif
/* drm_parse_option parses a single option. See description for
* drm_parse_options for details.
/**
* Parse a single option.
*
* \param s option string.
*
* \sa See parse_options() for details.
*/
static
void
DRM
(
parse_option
)(
char
*
s
)
{
...
...
@@ -58,26 +67,33 @@ static void DRM(parse_option)(char *s)
return
;
}
/* drm_parse_options parse the insmod "drm_opts=" options, or the command-line
* options passed to the kernel via LILO. The grammar of the format is as
/**
* Parse the insmod "drm_opts=" options, or the command-line
* options passed to the kernel via LILO.
*
* \param s contains option_list without the 'drm_opts=' part.
*
* The grammar of the format is as
* follows:
*
* \code
* drm ::= 'drm_opts=' option_list
* option_list ::= option [ ';' option_list ]
* option ::= 'device:' major
* | 'debug'
* | 'noctx'
* major ::= INTEGER
* \endcode
*
* Note that 's' contains option_list without the 'drm_opts=' part.
*
* device=major,minor specifies the device number used for /dev/drm
* if major == 0 then the misc device is used
* if major == 0 and minor == 0 then dynamic misc allocation is used
* debug=on specifies that debugging messages will be printk'd
* debug=trace specifies that each function call will be logged via printk
* debug=off turns off all debugging options
* - device=major,minor specifies the device number used for /dev/drm
* - if major == 0 then the misc device is used
* - if major == 0 and minor == 0 then dynamic misc allocation is used
* - debug=on specifies that debugging messages will be printk'd
* - debug=trace specifies that each function call will be logged via printk
* - debug=off turns off all debugging options
*
* \todo Actually only the \e presence of the 'debug' option is currently
* checked.
*/
void
DRM
(
parse_options
)(
char
*
s
)
...
...
@@ -95,8 +111,10 @@ void DRM(parse_options)(char *s)
}
}
/* drm_cpu_valid returns non-zero if the DRI will run on this CPU, and 0
* otherwise.
/**
* Check whether DRI will run on this CPU.
*
* \return non-zero if the DRI will run on this CPU, or zero otherwise.
*/
int
DRM
(
cpu_valid
)(
void
)
{
...
...
drivers/char/drm/drm_ioctl.h
View file @
fd80ab16
/* drm_ioctl.h -- IOCTL processing for DRM -*- linux-c -*-
/**
* \file drm_ioctl.h
* IOCTL processing for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Fri Jan 8 09:01:26 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,15 +31,22 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
/**
* Get interrupt from bus id.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_irq_busid structure.
* \return zero on success or a negative number on failure.
*
* Finds the PCI device with the specified bus id and gets its IRQ number.
*/
int
DRM
(
irq_busid
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -84,6 +99,17 @@ int DRM(irq_busid)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Get the bus id.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_unique structure.
* \return zero on success or a negative number on failure.
*
* Copies the bus id from drm_device::unique into user space.
*/
int
DRM
(
getunique
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -103,6 +129,18 @@ int DRM(getunique)(struct inode *inode, struct file *filp,
return
0
;
}
/**
* Set the bus id.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_unique structure.
* \return zero on success or a negative number on failure.
*
* Copies the bus id from userspace into drm_device::unique, and searches for
* the respective PCI device, updating drm_device::pdev.
*/
int
DRM
(
setunique
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -180,6 +218,19 @@ int DRM(setunique)(struct inode *inode, struct file *filp,
}
/**
* Get a mapping information.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_map structure.
*
* \return zero on success or a negative number on failure.
*
* Searches for the mapping with the specified offset and copies its information
* into userspace
*/
int
DRM
(
getmap
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -226,6 +277,19 @@ int DRM(getmap)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Get client information.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_client structure.
*
* \return zero on success or a negative number on failure.
*
* Searches for the client with the specified index and copies its information
* into userspace
*/
int
DRM
(
getclient
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -259,6 +323,16 @@ int DRM(getclient)( struct inode *inode, struct file *filp,
return
0
;
}
/**
* Get statistics information.
*
* \param inode device inode.
* \param filp file pointer.
* \param cmd command.
* \param arg user argument, pointing to a drm_stats structure.
*
* \return zero on success or a negative number on failure.
*/
int
DRM
(
getstats
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
drivers/char/drm/drm_lock.h
View file @
fd80ab16
/* lock.c -- IOCTLs for locking -*- linux-c -*-
/**
* \file drm_lock.h
* IOCTLs for locking
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,14 +31,11 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
/** No-op ioctl. */
int
DRM
(
noop
)(
struct
inode
*
inode
,
struct
file
*
filp
,
unsigned
int
cmd
,
unsigned
long
arg
)
{
...
...
@@ -38,7 +43,15 @@ int DRM(noop)(struct inode *inode, struct file *filp, unsigned int cmd,
return
0
;
}
/**
* Take the heavyweight lock.
*
* \param lock lock pointer.
* \param context locking context.
* \return one if the lock is held, or zero otherwise.
*
* Attempt to mark the lock as held by the given context, via the \p cmpxchg instruction.
*/
int
DRM
(
lock_take
)(
__volatile__
unsigned
int
*
lock
,
unsigned
int
context
)
{
unsigned
int
old
,
new
,
prev
;
...
...
@@ -65,8 +78,18 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
return
0
;
}
/* This takes a lock forcibly and hands it to context. Should ONLY be used
inside *_unlock to give lock to kernel before calling *_dma_schedule. */
/**
* This takes a lock forcibly and hands it to context. Should ONLY be used
* inside *_unlock to give lock to kernel before calling *_dma_schedule.
*
* \param dev DRM device.
* \param lock lock pointer.
* \param context locking context.
* \return always one.
*
* Resets the lock file pointer.
* Marks the lock as held by the given context, via the \p cmpxchg instruction.
*/
int
DRM
(
lock_transfer
)(
drm_device_t
*
dev
,
__volatile__
unsigned
int
*
lock
,
unsigned
int
context
)
{
...
...
@@ -81,6 +104,17 @@ int DRM(lock_transfer)(drm_device_t *dev,
return
1
;
}
/**
* Free lock.
*
* \param dev DRM device.
* \param lock lock.
* \param context context.
*
* Resets the lock file pointer.
* Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task
* waiting on the lock queue.
*/
int
DRM
(
lock_free
)(
drm_device_t
*
dev
,
__volatile__
unsigned
int
*
lock
,
unsigned
int
context
)
{
...
...
@@ -102,18 +136,17 @@ int DRM(lock_free)(drm_device_t *dev,
return
0
;
}
/* If we get here, it means that the process has called DRM_IOCTL_LOCK
without calling DRM_IOCTL_UNLOCK.
If the lock is not held, then let the signal proceed as usual.
If the lock is held, then set the contended flag and keep the signal
blocked.
Return 1 if the signal should be delivered normally.
Return 0 if the signal should be blocked. */
/**
* If we get here, it means that the process has called DRM_IOCTL_LOCK
* without calling DRM_IOCTL_UNLOCK.
*
* If the lock is not held, then let the signal proceed as usual. If the lock
* is held, then set the contended flag and keep the signal blocked.
*
* \param priv pointer to a drm_sigdata structure.
* \return one if the signal should be delivered normally, or zero if the
* signal should be blocked.
*/
int
DRM
(
notifier
)(
void
*
priv
)
{
drm_sigdata_t
*
s
=
(
drm_sigdata_t
*
)
priv
;
...
...
drivers/char/drm/drm_memory.h
View file @
fd80ab16
/* drm_memory.h -- Memory management wrappers for DRM -*- linux-c -*-
/**
* \file drm_memory.h
* Memory management wrappers for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,17 +31,14 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include <linux/config.h>
#include <linux/highmem.h>
#include "drmP.h"
/* Cut down version of drm_memory_debug.h, which used to be called
/**
* Cut down version of drm_memory_debug.h, which used to be called
* drm_memory.h. If you want the debug functionality, change 0 to 1
* below.
*/
...
...
@@ -188,22 +193,38 @@ static inline void drm_ioremapfree(void *pt, unsigned long size, drm_device_t *d
#if DEBUG_MEMORY
#include "drm_memory_debug.h"
#else
/** No-op. */
void
DRM
(
mem_init
)(
void
)
{
}
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
/**
* Called when "/proc/dri/%dev%/mem" is read.
*
* \param buf output buffer.
* \param start start of output data.
* \param offset requested start offset.
* \param len requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
*
* No-op.
*/
int
DRM
(
mem_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
len
,
int
*
eof
,
void
*
data
)
{
return
0
;
}
/** Wrapper around kmalloc() */
void
*
DRM
(
alloc
)(
size_t
size
,
int
area
)
{
return
kmalloc
(
size
,
GFP_KERNEL
);
}
/** Wrapper around kmalloc() and kfree() */
void
*
DRM
(
realloc
)(
void
*
oldpt
,
size_t
oldsize
,
size_t
size
,
int
area
)
{
void
*
pt
;
...
...
@@ -216,11 +237,21 @@ void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
return
pt
;
}
/** Wrapper around kfree() */
void
DRM
(
free
)(
void
*
pt
,
size_t
size
,
int
area
)
{
kfree
(
pt
);
}
/**
* Allocate pages.
*
* \param order size order.
* \param area memory area. (Not used.)
* \return page address on success, or zero on failure.
*
* Allocate and reserve free pages.
*/
unsigned
long
DRM
(
alloc_pages
)(
int
order
,
int
area
)
{
unsigned
long
address
;
...
...
@@ -245,6 +276,15 @@ unsigned long DRM(alloc_pages)(int order, int area)
return
address
;
}
/**
* Free pages.
*
* \param address address of the pages to free.
* \param order size order.
* \param area memory area. (Not used.)
*
* Unreserve and free pages allocated by alloc_pages().
*/
void
DRM
(
free_pages
)(
unsigned
long
address
,
int
order
,
int
area
)
{
unsigned
long
bytes
=
PAGE_SIZE
<<
order
;
...
...
@@ -264,37 +304,44 @@ void DRM(free_pages)(unsigned long address, int order, int area)
free_pages
(
address
,
order
);
}
/** Wrapper around drm_ioremap() */
void
*
DRM
(
ioremap
)(
unsigned
long
offset
,
unsigned
long
size
,
drm_device_t
*
dev
)
{
return
drm_ioremap
(
offset
,
size
,
dev
);
}
/** Wrapper around drm_ioremap_nocache() */
void
*
DRM
(
ioremap_nocache
)(
unsigned
long
offset
,
unsigned
long
size
,
drm_device_t
*
dev
)
{
return
drm_ioremap_nocache
(
offset
,
size
,
dev
);
}
/** Wrapper around drm_iounmap() */
void
DRM
(
ioremapfree
)(
void
*
pt
,
unsigned
long
size
,
drm_device_t
*
dev
)
{
drm_ioremapfree
(
pt
,
size
,
dev
);
}
#if __REALLY_HAVE_AGP
/** Wrapper around agp_allocate_memory() */
struct
agp_memory
*
DRM
(
alloc_agp
)(
int
pages
,
u32
type
)
{
return
DRM
(
agp_allocate_memory
)(
pages
,
type
);
}
/** Wrapper around agp_free_memory() */
int
DRM
(
free_agp
)(
struct
agp_memory
*
handle
,
int
pages
)
{
return
DRM
(
agp_free_memory
)(
handle
)
?
0
:
-
EINVAL
;
}
/** Wrapper around agp_bind_memory() */
int
DRM
(
bind_agp
)(
struct
agp_memory
*
handle
,
unsigned
int
start
)
{
return
DRM
(
agp_bind_memory
)(
handle
,
start
);
}
/** Wrapper around agp_unbind_memory() */
int
DRM
(
unbind_agp
)(
struct
agp_memory
*
handle
)
{
return
DRM
(
agp_unbind_memory
)(
handle
);
...
...
drivers/char/drm/drm_memory_debug.h
View file @
fd80ab16
/* drm_memory.h -- Memory management wrappers for DRM -*- linux-c -*-
* Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com
/**
* \file drm_memory.h
* Memory management wrappers for DRM.
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
...
...
@@ -23,10 +29,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include <linux/config.h>
...
...
drivers/char/drm/drm_os_linux.h
View file @
fd80ab16
/**
* \file drm_os_linux.h
* OS abstraction macros.
*/
#include <linux/interrupt.h>
/* For task queue support */
#include <linux/delay.h>
/** File pointer type */
#define DRMFILE struct file *
/** Ioctl arguments */
#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
#define DRM_ERR(d) -(d)
/** Current process ID */
#define DRM_CURRENTPID current->pid
#define DRM_UDELAY(d) udelay(d)
/** Read a byte from a MMIO region */
#define DRM_READ8(map, offset) readb(((unsigned long)(map)->handle) + (offset))
/** Read a dword from a MMIO region */
#define DRM_READ32(map, offset) readl(((unsigned long)(map)->handle) + (offset))
/** Write a byte into a MMIO region */
#define DRM_WRITE8(map, offset, val) writeb(val, ((unsigned long)(map)->handle) + (offset))
/** Write a dword into a MMIO region */
#define DRM_WRITE32(map, offset, val) writel(val, ((unsigned long)(map)->handle) + (offset))
/** Read memory barrier */
#define DRM_READMEMORYBARRIER() rmb()
/** Write memory barrier */
#define DRM_WRITEMEMORYBARRIER() wmb()
/** Read/write memory barrier */
#define DRM_MEMORYBARRIER() mb()
/** DRM device local declaration */
#define DRM_DEVICE drm_file_t *priv = filp->private_data; \
drm_device_t *dev = priv->dev
/** IRQ handler arguments */
#define DRM_IRQ_ARGS int irq, void *arg, struct pt_regs *regs
/** Task queue handler arguments */
#define DRM_TASKQUEUE_ARGS void *arg
/*
For data going from/
to the kernel through the ioctl argument */
/*
* For data going in
to the kernel through the ioctl argument */
#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
if ( copy_from_user(&arg1, arg2, arg3) ) \
return -EFAULT
/** For data going from the kernel through the ioctl argument */
#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
if ( copy_to_user(arg1, &arg2, arg3) ) \
return -EFAULT
/*
Other copying of data from/
to kernel space */
/*
* Other copying of data
to kernel space */
#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
copy_from_user(arg1, arg2, arg3)
/** Other copying of data from kernel space */
#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
copy_to_user(arg1, arg2, arg3)
/* Macros for copyfrom user, but checking readability only once */
...
...
@@ -41,10 +61,16 @@
__get_user(val, uaddr)
/*
malloc/free without the overhead of DRM(alloc
) */
/*
* 'malloc' without the overhead of DRM(alloc)(
) */
#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
/** 'free' without the overhead of DRM(free)() */
#define DRM_FREE(x,size) kfree(x)
/**
* Get the pointer to the SAREA.
*
* Searches the SAREA on the mapping lists and points drm_device::sarea to it.
*/
#define DRM_GETSAREA() \
do { \
drm_map_list_t *entry; \
...
...
drivers/char/drm/drm_proc.h
View file @
fd80ab16
/* drm_proc.h -- /proc support for DRM -*- linux-c -*-
/**
* \file drm_proc.h
* /proc support for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*
* \par Acknowledgements:
* Matthew J Sottek <matthew.j.sottek@intel.com> sent in a patch to fix
* the problem with the proc files not outputting all their information.
*/
/*
* Created: Mon Jan 11 09:48:47 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,14 +35,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*
* Acknowledgements:
* Matthew J Sottek <matthew.j.sottek@intel.com> sent in a patch to fix
* the problem with the proc files not outputting all their information.
*/
#include "drmP.h"
...
...
@@ -50,9 +54,12 @@ static int DRM(vma_info)(char *buf, char **start, off_t offset,
int
request
,
int
*
eof
,
void
*
data
);
#endif
/**
* Proc file list.
*/
struct
drm_proc_list
{
const
char
*
name
;
int
(
*
f
)(
char
*
,
char
**
,
off_t
,
int
,
int
*
,
void
*
);
const
char
*
name
;
/**< file name */
int
(
*
f
)(
char
*
,
char
**
,
off_t
,
int
,
int
*
,
void
*
);
/**< proc callback*/
}
DRM
(
proc_list
)[]
=
{
{
"name"
,
DRM
(
name_info
)
},
{
"mem"
,
DRM
(
mem_info
)
},
...
...
@@ -66,6 +73,19 @@ struct drm_proc_list {
};
#define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
/**
* Initialize the DRI proc filesystem for a device.
*
* \param dev DRM device.
* \param minor device minor number.
* \param root DRI proc dir entry.
* \param dev_root resulting DRI device proc dir entry.
* \return root entry pointer on success, or NULL on failure.
*
* Create the DRI proc root entry "/proc/dri", the device proc root entry
* "/proc/dri/%minor%/", and each entry in proc_list as
* "/proc/dri/%minor%/%name%".
*/
struct
proc_dir_entry
*
DRM
(
proc_init
)(
drm_device_t
*
dev
,
int
minor
,
struct
proc_dir_entry
*
root
,
struct
proc_dir_entry
**
dev_root
)
...
...
@@ -83,7 +103,7 @@ struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
sprintf
(
name
,
"%d"
,
minor
);
*
dev_root
=
create_proc_entry
(
name
,
S_IFDIR
,
root
);
if
(
!*
dev_root
)
{
DRM_ERROR
(
"Cannot create /proc/%s
\n
"
,
name
);
DRM_ERROR
(
"Cannot create /proc/
dri/
%s
\n
"
,
name
);
return
NULL
;
}
...
...
@@ -108,6 +128,16 @@ struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
}
/**
* Cleanup the proc filesystem resources.
*
* \param minor device minor number.
* \param root DRI proc dir entry.
* \param dev_root DRI device proc dir entry.
* \return always zero.
*
* Remove all proc entries created by proc_init().
*/
int
DRM
(
proc_cleanup
)(
int
minor
,
struct
proc_dir_entry
*
root
,
struct
proc_dir_entry
*
dev_root
)
{
...
...
@@ -125,6 +155,19 @@ int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
return
0
;
}
/**
* Called when "/proc/dri/.../name" is read.
*
* \param buf output buffer.
* \param start start of output data.
* \param offset requested start offset.
* \param request requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
*
* Prints the device name together with the bus id if available.
*/
static
int
DRM
(
name_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -151,6 +194,19 @@ static int DRM(name_info)(char *buf, char **start, off_t offset, int request,
return
len
-
offset
;
}
/**
* Called when "/proc/dri/.../vm" is read.
*
* \param buf output buffer.
* \param start start of output data.
* \param offset requested start offset.
* \param request requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
*
* Prints information about all mappings in drm_device::maplist.
*/
static
int
DRM
(
_vm_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -204,6 +260,9 @@ static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
return
len
-
offset
;
}
/**
* Simply calls _vm_info() while holding the drm_device::struct_sem lock.
*/
static
int
DRM
(
vm_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -216,7 +275,17 @@ static int DRM(vm_info)(char *buf, char **start, off_t offset, int request,
return
ret
;
}
/**
* Called when "/proc/dri/.../queues" is read.
*
* \param buf output buffer.
* \param start start of output data.
* \param offset requested start offset.
* \param request requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
*/
static
int
DRM
(
_queues_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -261,6 +330,9 @@ static int DRM(_queues_info)(char *buf, char **start, off_t offset,
return
len
-
offset
;
}
/**
* Simply calls _queues_info() while holding the drm_device::struct_sem lock.
*/
static
int
DRM
(
queues_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -273,9 +345,17 @@ static int DRM(queues_info)(char *buf, char **start, off_t offset, int request,
return
ret
;
}
/* drm_bufs_info is called whenever a process reads
/dev/dri/<dev>/bufs. */
/**
* Called when "/proc/dri/.../bufs" is read.
*
* \param buf output buffer.
* \param start start of output data.
* \param offset requested start offset.
* \param request requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
*/
static
int
DRM
(
_bufs_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -320,6 +400,9 @@ static int DRM(_bufs_info)(char *buf, char **start, off_t offset, int request,
return
len
-
offset
;
}
/**
* Simply calls _bufs_info() while holding the drm_device::struct_sem lock.
*/
static
int
DRM
(
bufs_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -332,7 +415,17 @@ static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request,
return
ret
;
}
/**
* Called when "/proc/dri/.../clients" is read.
*
* \param buf output buffer.
* \param start start of output data.
* \param offset requested start offset.
* \param request requested number of bytes.
* \param eof whether there is no more data to return.
* \param data private data.
* \return number of written bytes.
*/
static
int
DRM
(
_clients_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
@@ -364,6 +457,9 @@ static int DRM(_clients_info)(char *buf, char **start, off_t offset,
return
len
-
offset
;
}
/**
* Simply calls _clients_info() while holding the drm_device::struct_sem lock.
*/
static
int
DRM
(
clients_info
)(
char
*
buf
,
char
**
start
,
off_t
offset
,
int
request
,
int
*
eof
,
void
*
data
)
{
...
...
drivers/char/drm/drm_sarea.h
View file @
fd80ab16
/* sarea.h -- SAREA definitions -*- linux-c -*-
/**
* \file drm_sarea.h
* \brief SAREA definitions
*
* \author Michel Dänzer <michel@daenzer.net>
*/
/*
* Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
...
...
@@ -21,22 +27,22 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Michel Dänzer <michel@daenzer.net>
*/
#ifndef _DRM_SAREA_H_
#define _DRM_SAREA_H_
/** Maximum number of drawables in the SAREA */
#define SAREA_MAX_DRAWABLES 256
typedef
struct
_drm_sarea_drawable_t
{
/** SAREA drawable */
typedef
struct
drm_sarea_drawable
{
unsigned
int
stamp
;
unsigned
int
flags
;
}
drm_sarea_drawable_t
;
typedef
struct
_dri_sarea_frame_t
{
/** SAREA frame */
typedef
struct
drm_sarea_frame
{
unsigned
int
x
;
unsigned
int
y
;
unsigned
int
width
;
...
...
@@ -44,13 +50,14 @@ typedef struct _dri_sarea_frame_t {
unsigned
int
fullscreen
;
}
drm_sarea_frame_t
;
typedef
struct
_drm_sarea_t
{
/* first thing is always the drm locking structure */
/** SAREA */
typedef
struct
drm_sarea
{
/** first thing is always the DRM locking structure */
drm_hw_lock_t
lock
;
/* NOT_DONE: Use readers/writer lock for
drawable_lock */
/** \todo Use readers/writer lock for drm_sarea::
drawable_lock */
drm_hw_lock_t
drawable_lock
;
drm_sarea_drawable_t
drawableTable
[
SAREA_MAX_DRAWABLES
];
drm_sarea_frame_t
frame
;
drm_sarea_drawable_t
drawableTable
[
SAREA_MAX_DRAWABLES
];
/**< drawables */
drm_sarea_frame_t
frame
;
/**< frame */
drm_context_t
dummy_context
;
}
drm_sarea_t
;
...
...
drivers/char/drm/drm_scatter.h
View file @
fd80ab16
/* drm_scatter.h -- IOCTLs to manage scatter/gather memory -*- linux-c -*-
/**
* \file drm_scatter.h
* IOCTLs to manage scatter/gather memory
*
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Mon Dec 18 23:20:54 2000 by gareth@valinux.com
*
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
...
...
@@ -22,9 +29,6 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Gareth Hughes <gareth@valinux.com>
*/
#include <linux/config.h>
...
...
drivers/char/drm/drm_stub.h
View file @
fd80ab16
/* drm_stub.h -- -*- linux-c -*-
/**
* \file drm_stub.h
* Stub support
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
*/
/*
* Created: Fri Jan 19 10:48:35 2001 by faith@acm.org
*
* Copyright 2001 VA Linux Systems, Inc., Sunnyvale, California.
...
...
@@ -22,30 +29,37 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
#include "drmP.h"
#define DRM_STUB_MAXCARDS 16
/* Enough for one machine */
/** Stub list. One for each minor. */
static
struct
drm_stub_list
{
const
char
*
name
;
struct
file_operations
*
fops
;
struct
proc_dir_entry
*
dev_root
;
struct
file_operations
*
fops
;
/**< file operations */
struct
proc_dir_entry
*
dev_root
;
/**< proc directory entry */
}
*
DRM
(
stub_list
);
static
struct
proc_dir_entry
*
DRM
(
stub_root
);
/** Stub information */
static
struct
drm_stub_info
{
int
(
*
info_register
)(
const
char
*
name
,
struct
file_operations
*
fops
,
drm_device_t
*
dev
);
int
(
*
info_unregister
)(
int
minor
);
}
DRM
(
stub_info
);
/**
* File \c open operation.
*
* \param inode device inode.
* \param filp file pointer.
*
* Puts the drm_stub_list::fops corresponding to the device minor number into
* \p filp, call the \c open method, and restore the file operations.
*/
static
int
DRM
(
stub_open
)(
struct
inode
*
inode
,
struct
file
*
filp
)
{
int
minor
=
minor
(
inode
->
i_rdev
);
...
...
@@ -64,11 +78,24 @@ static int DRM(stub_open)(struct inode *inode, struct file *filp)
return
err
;
}
/** File operations structure */
static
struct
file_operations
DRM
(
stub_fops
)
=
{
.
owner
=
THIS_MODULE
,
.
open
=
DRM
(
stub_open
)
};
/**
* Get a device minor number.
*
* \param name driver name.
* \param fops file operations.
* \param dev DRM device.
* \return minor number on success, or a negative number on failure.
*
* Allocate and initialize ::stub_list if one doesn't exist already. Search an
* empty entry and initialize it to the given parameters, and create the proc
* init entry via proc_init().
*/
static
int
DRM
(
stub_getminor
)(
const
char
*
name
,
struct
file_operations
*
fops
,
drm_device_t
*
dev
)
{
...
...
@@ -96,6 +123,16 @@ static int DRM(stub_getminor)(const char *name, struct file_operations *fops,
return
-
1
;
}
/**
* Put a device minor number.
*
* \param minor minor number.
* \return always zero.
*
* Cleans up the proc resources. If a minor is zero then release the foreign
* "drm" data, otherwise unregisters the "drm" data, frees the stub list and
* unregisters the character device.
*/
static
int
DRM
(
stub_putminor
)(
int
minor
)
{
if
(
minor
<
0
||
minor
>=
DRM_STUB_MAXCARDS
)
return
-
1
;
...
...
@@ -115,7 +152,20 @@ static int DRM(stub_putminor)(int minor)
return
0
;
}
/**
* Register.
*
* \param name driver name.
* \param fops file operations
* \param dev DRM device.
* \return zero on success or a negative number on failure.
*
* Attempt to register the char device and get the foreign "drm" data. If
* successful then another module already registered so gets the stub info,
* otherwise use this module stub info and make it available for other modules.
*
* Finally calls stub_info::info_register.
*/
int
DRM
(
stub_register
)(
const
char
*
name
,
struct
file_operations
*
fops
,
drm_device_t
*
dev
)
{
...
...
@@ -141,6 +191,13 @@ int DRM(stub_register)(const char *name, struct file_operations *fops,
return
-
1
;
}
/**
* Unregister.
*
* \param minor
*
* Calls drm_stub_info::unregister.
*/
int
DRM
(
stub_unregister
)(
int
minor
)
{
DRM_DEBUG
(
"%d
\n
"
,
minor
);
...
...
drivers/char/drm/drm_vm.h
View file @
fd80ab16
/* drm_vm.h -- Memory mapping for DRM -*- linux-c -*-
/**
* \file drm_vm.h
* Memory mapping for DRM
*
* \author Rickard E. (Rik) Faith <faith@valinux.com>
* \author Gareth Hughes <gareth@valinux.com>
*/
/*
* Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
...
...
@@ -23,38 +31,49 @@
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
#include "drmP.h"
/** AGP virtual memory operations */
struct
vm_operations_struct
DRM
(
vm_ops
)
=
{
.
nopage
=
DRM
(
vm_nopage
),
.
open
=
DRM
(
vm_open
),
.
close
=
DRM
(
vm_close
),
};
/** Shared virtual memory operations */
struct
vm_operations_struct
DRM
(
vm_shm_ops
)
=
{
.
nopage
=
DRM
(
vm_shm_nopage
),
.
open
=
DRM
(
vm_open
),
.
close
=
DRM
(
vm_shm_close
),
};
/** DMA virtual memory operations */
struct
vm_operations_struct
DRM
(
vm_dma_ops
)
=
{
.
nopage
=
DRM
(
vm_dma_nopage
),
.
open
=
DRM
(
vm_open
),
.
close
=
DRM
(
vm_close
),
};
/** Scatter-gather virtual memory operations */
struct
vm_operations_struct
DRM
(
vm_sg_ops
)
=
{
.
nopage
=
DRM
(
vm_sg_nopage
),
.
open
=
DRM
(
vm_open
),
.
close
=
DRM
(
vm_close
),
};
/**
* \c nopage method for AGP virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \param write_access sharing.
* \return pointer to the page structure.
*
* Find the right map and if it's AGP memory find the real physical page to
* map, get the page, increment the use count and return it.
*/
struct
page
*
DRM
(
vm_nopage
)(
struct
vm_area_struct
*
vma
,
unsigned
long
address
,
int
write_access
)
...
...
@@ -122,6 +141,17 @@ struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
return
NOPAGE_SIGBUS
;
/* Disallow mremap */
}
/**
* \c nopage method for shared virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \param write_access sharing.
* \return pointer to the page structure.
*
* Get the the mapping, find the real physical page to map, get the page, and
* return it.
*/
struct
page
*
DRM
(
vm_shm_nopage
)(
struct
vm_area_struct
*
vma
,
unsigned
long
address
,
int
write_access
)
...
...
@@ -145,10 +175,15 @@ struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
return
page
;
}
/* Special close routine which deletes map information if we are the last
/**
* \c close method for shared virtual memory.
*
* \param vma virtual memory area.
*
* Deletes map information if we are the last
* person to close a mapping and it's not in the global maplist.
*/
void
DRM
(
vm_shm_close
)(
struct
vm_area_struct
*
vma
)
{
drm_file_t
*
priv
=
vma
->
vm_file
->
private_data
;
...
...
@@ -221,6 +256,16 @@ void DRM(vm_shm_close)(struct vm_area_struct *vma)
up
(
&
dev
->
struct_sem
);
}
/**
* \c nopage method for DMA virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \param write_access sharing.
* \return pointer to the page structure.
*
* Determine the page number from the page offset and get it from drm_device_dma::pagelist.
*/
struct
page
*
DRM
(
vm_dma_nopage
)(
struct
vm_area_struct
*
vma
,
unsigned
long
address
,
int
write_access
)
...
...
@@ -247,6 +292,16 @@ struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
return
page
;
}
/**
* \c nopage method for scatter-gather virtual memory.
*
* \param vma virtual memory area.
* \param address access address.
* \param write_access sharing.
* \return pointer to the page structure.
*
* Determine the map offset from the page offset and get it from drm_sg_mem::pagelist.
*/
struct
page
*
DRM
(
vm_sg_nopage
)(
struct
vm_area_struct
*
vma
,
unsigned
long
address
,
int
write_access
)
...
...
@@ -274,6 +329,14 @@ struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
return
page
;
}
/**
* \c open method for shared virtual memory.
*
* \param vma virtual memory area.
*
* Create a new drm_vma_entry structure as the \p vma private data entry and
* add it to drm_device::vmalist.
*/
void
DRM
(
vm_open
)(
struct
vm_area_struct
*
vma
)
{
drm_file_t
*
priv
=
vma
->
vm_file
->
private_data
;
...
...
@@ -295,6 +358,14 @@ void DRM(vm_open)(struct vm_area_struct *vma)
}
}
/**
* \c close method for all virtual memory types.
*
* \param vma virtual memory area.
*
* Search the \p vma private data entry in drm_device::vmalist, unlink it, and
* free it.
*/
void
DRM
(
vm_close
)(
struct
vm_area_struct
*
vma
)
{
drm_file_t
*
priv
=
vma
->
vm_file
->
private_data
;
...
...
@@ -320,6 +391,16 @@ void DRM(vm_close)(struct vm_area_struct *vma)
up
(
&
dev
->
struct_sem
);
}
/**
* mmap DMA memory.
*
* \param filp file pointer.
* \param vma virtual memory area.
* \return zero on success or a negative number on failure.
*
* Sets the virtual memory area operations structure to vm_dma_ops, the file
* pointer, and calls vm_open().
*/
int
DRM
(
mmap_dma
)(
struct
file
*
filp
,
struct
vm_area_struct
*
vma
)
{
drm_file_t
*
priv
=
filp
->
private_data
;
...
...
@@ -366,6 +447,19 @@ int DRM(mmap_dma)(struct file *filp, struct vm_area_struct *vma)
#endif
#endif
/**
* mmap DMA memory.
*
* \param filp file pointer.
* \param vma virtual memory area.
* \return zero on success or a negative number on failure.
*
* If the virtual memory area has no offset associated with it then it's a DMA
* area, so calls mmap_dma(). Otherwise searches the map in drm_device::maplist,
* checks that the restricted flag is not set, sets the virtual memory operations
* according to the mapping type and remaps the pages. Finally sets the file
* pointer and calls vm_open().
*/
int
DRM
(
mmap
)(
struct
file
*
filp
,
struct
vm_area_struct
*
vma
)
{
drm_file_t
*
priv
=
filp
->
private_data
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment