Small optimization for big-endian (e.g., PowerPC) systems.
[mesa.git] / src / mesa / drivers / dri / savage / savageioctl.h
1 /*
2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25
26 #ifndef SAVAGE_IOCTL_H
27 #define SAVAGE_IOCTL_H
28
29 #include "savagecontext.h"
30 #include "savagedma.h"
31
32 void savageGetGeneralDmaBufferLocked( savageContextPtr mmesa );
33
34 void savageFlushVertices( savageContextPtr mmesa );
35 void savageFlushVerticesLocked( savageContextPtr mmesa );
36
37 void savageFlushGeneralLocked( savageContextPtr imesa );
38 void savageWaitAgeLocked( savageContextPtr imesa, int age );
39 void savageWaitAge( savageContextPtr imesa, int age );
40
41 void savageDmaFinish( savageContextPtr imesa );
42
43 void savageRegetLockQuiescent( savageContextPtr imesa );
44
45 void savageDDInitIoctlFuncs( GLcontext *ctx );
46
47 void savageSwapBuffers( __DRIdrawablePrivate *dPriv );
48
49 int savage_check_copy(int fd);
50
51 extern GLboolean (*savagePagePending)( savageContextPtr imesa );
52 extern void (*savageWaitForFIFO)( savageContextPtr imesa, unsigned count );
53 extern void (*savageWaitIdleEmpty)( savageContextPtr imesa );
54
55 #define PAGE_PENDING(result) do { \
56 result = savagePagePending(imesa); \
57 } while (0)
58 #define WAIT_FOR_FIFO(count) do { \
59 savageWaitForFIFO(imesa, count); \
60 } while (0)
61 #define WAIT_IDLE_EMPTY do { \
62 savageWaitIdleEmpty(imesa); \
63 } while (0)
64
65 #if SAVAGE_CMD_DMA
66 int savageAllocDMABuffer(savageContextPtr imesa, drm_savage_alloc_cont_mem_t *req);
67 GLuint savageGetPhyAddress(savageContextPtr imesa,void * pointer);
68 int savageFreeDMABuffer(savageContextPtr, drm_savage_alloc_cont_mem_t*);
69 #endif
70
71 #define FLUSH_BATCH(imesa) do { \
72 if (imesa->vertex_dma_buffer) savageFlushVertices(imesa); \
73 } while (0)
74
75 static __inline
76 uint32_t *savageAllocDmaLow( savageContextPtr imesa, GLuint bytes )
77 {
78 uint32_t *head;
79
80 if (!imesa->vertex_dma_buffer) {
81 LOCK_HARDWARE(imesa);
82 imesa->vertex_dma_buffer = savageFakeGetBuffer (imesa);
83 UNLOCK_HARDWARE(imesa);
84 } else if (imesa->vertex_dma_buffer->used + bytes >
85 imesa->vertex_dma_buffer->total) {
86 LOCK_HARDWARE(imesa);
87 savageFlushVerticesLocked( imesa );
88 imesa->vertex_dma_buffer = savageFakeGetBuffer (imesa);
89 UNLOCK_HARDWARE(imesa);
90 }
91
92 head = (uint32_t *)((uint8_t *)imesa->vertex_dma_buffer->address +
93 imesa->vertex_dma_buffer->used);
94
95 imesa->vertex_dma_buffer->used += bytes;
96 return head;
97 }
98
99 #endif