summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/r128/r128_ioctl.h
blob: 0f9d11fe699857b48c33cab6b4a2ae7b012b3151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h,v 1.6 2002/12/16 16:18:53 dawes Exp $ */
/**************************************************************************

Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
                                               Cedar Park, Texas.
All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
on the rights to use, copy, modify, merge, publish, distribute, sub
license, and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR 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>
 *
 */

#ifndef __R128_IOCTL_H__
#define __R128_IOCTL_H__

#include "r128_dri.h"
#include "r128_reg.h"
#include "r128_lock.h"

#define R128_BUFFER_MAX_DWORDS	(R128_BUFFER_SIZE / sizeof(u_int32_t))


extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa );
extern void r128FlushVerticesLocked( r128ContextPtr rmesa );

static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int count,
				       int vert_size )
{
   u_int32_t *head;
   int bytes = count * vert_size;

   if ( !rmesa->vert_buf ) {
      LOCK_HARDWARE( rmesa );
      rmesa->vert_buf = r128GetBufferLocked( rmesa );
      UNLOCK_HARDWARE( rmesa );
   } else if ( rmesa->vert_buf->used + bytes > rmesa->vert_buf->total ) {
      LOCK_HARDWARE( rmesa );
      r128FlushVerticesLocked( rmesa );
      rmesa->vert_buf = r128GetBufferLocked( rmesa );
      UNLOCK_HARDWARE( rmesa );
   }

   head = (u_int32_t *)((char *)rmesa->vert_buf->address + rmesa->vert_buf->used);
   rmesa->vert_buf->used += bytes;
   rmesa->num_verts += count;
   
   return head;
}

extern void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer,
				GLint offset, GLint pitch, GLint format,
				GLint x, GLint y, GLint width, GLint height );

extern void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
				      GLuint n, GLint x, GLint y,
				      const GLuint depth[],
				      const GLubyte mask[] );
extern void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
					const GLint x[], const GLint y[],
					const GLuint depth[],
					const GLubyte mask[] );
extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
				     GLuint n, GLint x, GLint y );
extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
				       const GLint x[], const GLint y[] );

extern void r128CopyBuffer( __DRIdrawablePrivate *dPriv );
extern void r128PageFlip( __DRIdrawablePrivate *dPriv );
void r128WaitForVBlank( r128ContextPtr rmesa );

extern void r128WaitForIdleLocked( r128ContextPtr rmesa );


extern void r128InitIoctlFuncs( struct dd_function_table *functions );


/* ================================================================
 * Helper macros:
 */

#define FLUSH_BATCH( rmesa )						\
do {									\
   if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL )				\
      fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ );		\
   if ( rmesa->vert_buf ) {						\
      r128FlushVertices( rmesa );					\
   }									\
} while (0)

/* 64-bit align the next element address, and then make room for the
 * next indexed prim packet header.
 */
#define ALIGN_NEXT_ELT( rmesa )						\
do {									\
   rmesa->next_elt = (GLushort *)					\
      (((GLuint)rmesa->next_elt + 7) & ~0x7);				\
   rmesa->next_elt = (GLushort *)					\
      ((GLubyte *)rmesa->next_elt + R128_INDEX_PRIM_OFFSET);		\
} while (0)

#define r128FlushVertices( rmesa )					\
do {									\
   LOCK_HARDWARE( rmesa );						\
   r128FlushVerticesLocked( rmesa );					\
   UNLOCK_HARDWARE( rmesa );						\
} while (0)

#define r128FlushElts( rmesa )						\
do {									\
   LOCK_HARDWARE( rmesa );						\
   r128FlushEltsLocked( rmesa );					\
   UNLOCK_HARDWARE( rmesa );						\
} while (0)

#define r128WaitForIdle( rmesa )					\
   do {									\
      LOCK_HARDWARE( rmesa );						\
      r128WaitForIdleLocked( rmesa );					\
      UNLOCK_HARDWARE( rmesa );						\
   } while (0)

#endif /* __R128_IOCTL_H__ */