Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / hidds / nouveau / xf86-video-nouveau / nouveau_local.h
blob6bb045bb4ee9a3ce0f805fa46350c4c99c6f11b3
1 /*
2 * Copyright 2007 Nouveau Project
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
23 #ifndef __NOUVEAU_LOCAL_H__
24 #define __NOUVEAU_LOCAL_H__
26 #if !defined(__AROS__)
27 #include "compiler.h"
28 #include "xf86_OSproc.h"
29 #endif
31 /* Debug output */
32 #define NOUVEAU_MSG(fmt,args...) ErrorF(fmt, ##args)
33 #define NOUVEAU_ERR(fmt,args...) \
34 ErrorF("%s:%d - "fmt, __func__, __LINE__, ##args)
35 #if 0
36 #define NOUVEAU_FALLBACK(fmt,args...) do { \
37 NOUVEAU_ERR("FALLBACK: "fmt, ##args); \
38 return FALSE; \
39 } while(0)
40 #else
41 #define NOUVEAU_FALLBACK(fmt,args...) do { \
42 return FALSE; \
43 } while(0)
44 #endif
46 #define NOUVEAU_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1))
48 #define NVC0_TILE_PITCH(m) (64 << ((m) & 0xf))
49 #define NVC0_TILE_HEIGHT(m) (8 << ((m) >> 4))
51 static inline int log2i(int i)
53 int r = 0;
55 if (i & 0xffff0000) {
56 i >>= 16;
57 r += 16;
59 if (i & 0x0000ff00) {
60 i >>= 8;
61 r += 8;
63 if (i & 0x000000f0) {
64 i >>= 4;
65 r += 4;
67 if (i & 0x0000000c) {
68 i >>= 2;
69 r += 2;
71 if (i & 0x00000002) {
72 r += 1;
74 return r;
77 static inline int round_down_pow2(int x)
79 return 1 << log2i(x);
82 #define SWAP(x, y) do { \
83 typeof(x) __z = (x); \
84 (x) = (y); \
85 (y) = __z; \
86 } while (0)
88 #endif