1 /*
2 * Copyright 2007 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 */
23 #ifndef __NV04_PUSHBUF_H__
24 #define __NV04_PUSHBUF_H__
26 #include "nouveau_pushbuf.h"
28 static __inline__ void
29 BEGIN_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr,
30 unsigned mthd, unsigned size)
31 {
32 if (gr->bound == NOUVEAU_GROBJ_UNBOUND)
33 nouveau_grobj_autobind(gr);
34 chan->subc[gr->subc].sequence = chan->subc_sequence++;
36 WAIT_RING(chan, size + 1);
37 OUT_RING(chan, (gr->subc << 13) | (size << 18) | mthd);
38 }
40 /* non-incrementing BEGIN_RING */
41 static __inline__ void
42 BEGIN_RING_NI(struct nouveau_channel *chan, struct nouveau_grobj *gr,
43 unsigned mthd, unsigned size)
44 {
45 BEGIN_RING(chan, gr, mthd | 0x40000000, size);
46 }
48 static __inline__ void
49 BIND_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr, unsigned sc)
50 {
51 struct nouveau_subchannel *subc = &gr->channel->subc[sc];
53 if (subc->gr) {
54 if (subc->gr->bound == NOUVEAU_GROBJ_BOUND_EXPLICIT)
55 assert(0);
56 subc->gr->bound = NOUVEAU_GROBJ_UNBOUND;
57 }
58 subc->gr = gr;
59 subc->gr->subc = sc;
60 subc->gr->bound = NOUVEAU_GROBJ_BOUND_EXPLICIT;
62 BEGIN_RING(chan, gr, 0x0000, 1);
63 OUT_RING (chan, gr->handle);
64 }
66 #endif