2 * Copyright 2010 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
23 #ifndef __NVC0_PUSHBUF_H__
24 #define __NVC0_PUSHBUF_H__
26 #include "nouveau_pushbuf.h"
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++; \
34 /* incremental methods */
35 static __inline__ void
36 BEGIN_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr,
37 unsigned mthd, unsigned size)
40 WAIT_RING(chan, size + 1);
41 OUT_RING (chan, (0x2 << 28) | (size << 16) | (gr->subc << 13) | (mthd >> 2));
45 static __inline__ void
46 BEGIN_RING_NI(struct nouveau_channel *chan, struct nouveau_grobj *gr,
47 unsigned mthd, unsigned size)
50 WAIT_RING(chan, size + 1);
51 OUT_RING (chan, (0x6 << 28) | (size << 16) | (gr->subc << 13) | (mthd >> 2));
55 static __inline__ void
56 BEGIN_RING_1I(struct nouveau_channel *chan, struct nouveau_grobj *gr,
57 unsigned mthd, unsigned size)
60 WAIT_RING(chan, size + 1);
61 OUT_RING (chan, (0xa << 28) | (size << 16) | (gr->subc << 13) | (mthd >> 2));
65 static __inline__ void
66 IMMED_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr,
67 unsigned mthd, unsigned data)
71 OUT_RING (chan, (0x8 << 28) | (data << 16) | (gr->subc << 13) | (mthd >> 2));
74 static __inline__ void
75 BIND_RING(struct nouveau_channel *chan, struct nouveau_grobj *gr, unsigned sc)
77 struct nouveau_subchannel *subc = &gr->channel->subc[sc];
80 if (subc->gr->bound == NOUVEAU_GROBJ_BOUND_EXPLICIT)
82 subc->gr->bound = NOUVEAU_GROBJ_UNBOUND;
86 subc->gr->bound = NOUVEAU_GROBJ_BOUND_EXPLICIT;
88 BEGIN_RING(chan, gr, 0x0000, 1);
89 OUT_RING (chan, gr->grclass);