exa: FIRE_RING at the end of composite
[nouveau] / src / nv_local.h
1 /*
2  * Copyright 1993-2003 NVIDIA, Corporation
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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.
21  */
22
23 #ifndef __NV_LOCAL_H__
24 #define __NV_LOCAL_H__
25
26 /*
27  * This file includes any environment or machine specific values to access the
28  * HW.  Put all affected includes, typdefs, etc. here so the riva_hw.* files
29  * can stay generic in nature.
30  */ 
31 #include "compiler.h"
32 #include "xf86_OSproc.h"
33
34 //#define NOUVEAU_MODESET_TRACE
35 #ifdef NOUVEAU_MODESET_TRACE
36 #define DDXMMIOH(f, h, r, v)    ErrorF(f, h, r, v)
37 #define DDXMMIOW(f, r, w)       (ErrorF(f, r, w), w)
38 #else
39 #define DDXMMIOH(f, h, r, v)
40 #define DDXMMIOW(f, r, w)       w
41 #endif
42
43 /*
44  * HW access macros.  These assume memory-mapped I/O, and not normal I/O space.
45  */
46 #define NV_WR08(p,i,d)  MMIO_OUT8((pointer)(p), (i), (d))
47 #define NV_RD08(p,i)    MMIO_IN8((pointer)(p), (i))
48 #define NV_WR16(p,i,d)  MMIO_OUT16((pointer)(p), (i), (d))
49 #define NV_RD16(p,i)    MMIO_IN16((pointer)(p), (i))
50 #define NV_WR32(p,i,d)  MMIO_OUT32((pointer)(p), (i), (d))
51 #define NV_RD32(p,i)    MMIO_IN32((pointer)(p), (i))
52
53 /* VGA I/O is now always done through MMIO */
54 #define VGA_WR08(p,i,d) NV_WR08(p, i, DDXMMIOW("VGA_WR08 port 0x%04x val 0x%02x\n", i, d))
55 #define VGA_RD08(p,i)   DDXMMIOW("VGA_RD08 port 0x%04x val 0x%02x\n", i, NV_RD08(p,i))
56
57 static inline int log2i(int i)
58 {
59         int r = 0;
60
61         if (i & 0xffff0000) {
62                 i >>= 16;
63                 r += 16;
64         }
65         if (i & 0x0000ff00) {
66                 i >>= 8;
67                 r += 8;
68         }
69         if (i & 0x000000f0) {
70                 i >>= 4;
71                 r += 4;
72         }
73         if (i & 0x0000000c) {
74                 i >>= 2;
75                 r += 2;
76         }
77         if (i & 0x00000002) {
78                 r += 1;
79         }
80         return r;
81 }
82
83 #endif /* __NV_LOCAL_H__ */