OSDN Git Service

android: set LOCAL_MODULE_TAGS to optional
[android-x86/external-libdrm.git] / nouveau / nvc0_pushbuf.h
1 /*
2  * Copyright 2010 Nouveau Project
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 __NVC0_PUSHBUF_H__
24 #define __NVC0_PUSHBUF_H__
25
26 #include "nouveau_pushbuf.h"
27
28 #define SUBC_BIND(chan, gr) do {                                               \
29         if (gr->bound == NOUVEAU_GROBJ_UNBOUND)                                \
30                 nouveau_grobj_autobind(gr);                                    \
31         chan->subc[gr->subc].sequence = chan->subc_sequence++;                 \
32 } while (0)
33
34 /* incremental methods */
35 static __inline__ void
36 BEGIN_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr,
37            unsigned mthd, unsigned size)
38 {
39         SUBC_BIND(chan, gr);
40         WAIT_RING(chan, size + 1);
41         OUT_RING (chan, (0x2 << 28) | (size << 16) | (gr->subc << 13) | (mthd >> 2));
42 }
43
44 /* non-incremental */
45 static __inline__ void
46 BEGIN_RING_NI(struct nouveau_channel *chan, struct nouveau_grobj *gr,
47               unsigned mthd, unsigned size)
48 {
49         SUBC_BIND(chan, gr);
50         WAIT_RING(chan, size + 1);
51         OUT_RING (chan, (0x6 << 28) | (size << 16) | (gr->subc << 13) | (mthd >> 2));
52 }
53
54 /* increment-once */
55 static __inline__ void
56 BEGIN_RING_1I(struct nouveau_channel *chan, struct nouveau_grobj *gr,
57               unsigned mthd, unsigned size)
58 {
59         SUBC_BIND(chan, gr);
60         WAIT_RING(chan, size + 1);
61         OUT_RING (chan, (0xa << 28) | (size << 16) | (gr->subc << 13) | (mthd >> 2));
62 }
63
64 /* inline-data */
65 static __inline__ void
66 IMMED_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr,
67            unsigned mthd, unsigned data)
68 {
69         SUBC_BIND(chan, gr);
70         WAIT_RING(chan, 1);
71         OUT_RING (chan, (0x8 << 28) | (data << 16) | (gr->subc << 13) | (mthd >> 2));
72 }
73
74 static __inline__ void
75 BIND_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr, unsigned sc)
76 {
77         struct nouveau_subchannel *subc = &gr->channel->subc[sc];
78
79         if (subc->gr) {
80                 if (subc->gr->bound == NOUVEAU_GROBJ_BOUND_EXPLICIT)
81                         assert(0);
82                 subc->gr->bound = NOUVEAU_GROBJ_UNBOUND;
83         }
84         subc->gr = gr;
85         subc->gr->subc = sc;
86         subc->gr->bound = NOUVEAU_GROBJ_BOUND_EXPLICIT;
87
88         BEGIN_RING(chan, gr, 0x0000, 1);
89         OUT_RING  (chan, gr->grclass);
90 }
91
92 #endif