2 * Copyright 2012 Red Hat Inc.
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 COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <core/gpuobj.h>
26 #include <core/class.h>
28 #include <subdev/fb.h>
29 #include <engine/dmaobj.h>
31 struct nv50_dmaeng_priv {
32 struct nouveau_dmaeng base;
36 nv50_dmaobj_bind(struct nouveau_dmaeng *dmaeng,
37 struct nouveau_object *parent,
38 struct nouveau_dmaobj *dmaobj,
39 struct nouveau_gpuobj **pgpuobj)
41 u32 flags0 = nv_mclass(dmaobj);
42 u32 flags5 = 0x00000000;
45 if (!nv_iclass(parent, NV_ENGCTX_CLASS)) {
46 switch (nv_mclass(parent->parent)) {
47 case NV50_CHANNEL_DMA_CLASS:
48 case NV84_CHANNEL_DMA_CLASS:
49 case NV50_CHANNEL_IND_CLASS:
50 case NV84_CHANNEL_IND_CLASS:
51 case NV50_DISP_MAST_CLASS:
52 case NV84_DISP_MAST_CLASS:
53 case NV94_DISP_MAST_CLASS:
54 case NVA0_DISP_MAST_CLASS:
55 case NVA3_DISP_MAST_CLASS:
56 case NV50_DISP_SYNC_CLASS:
57 case NV84_DISP_SYNC_CLASS:
58 case NV94_DISP_SYNC_CLASS:
59 case NVA0_DISP_SYNC_CLASS:
60 case NVA3_DISP_SYNC_CLASS:
61 case NV50_DISP_OVLY_CLASS:
62 case NV84_DISP_OVLY_CLASS:
63 case NV94_DISP_OVLY_CLASS:
64 case NVA0_DISP_OVLY_CLASS:
65 case NVA3_DISP_OVLY_CLASS:
72 if (!(dmaobj->conf0 & NV50_DMA_CONF0_ENABLE)) {
73 if (dmaobj->target == NV_MEM_TARGET_VM) {
74 dmaobj->conf0 = NV50_DMA_CONF0_PRIV_VM;
75 dmaobj->conf0 |= NV50_DMA_CONF0_PART_VM;
76 dmaobj->conf0 |= NV50_DMA_CONF0_COMP_VM;
77 dmaobj->conf0 |= NV50_DMA_CONF0_TYPE_VM;
79 dmaobj->conf0 = NV50_DMA_CONF0_PRIV_US;
80 dmaobj->conf0 |= NV50_DMA_CONF0_PART_256;
81 dmaobj->conf0 |= NV50_DMA_CONF0_COMP_NONE;
82 dmaobj->conf0 |= NV50_DMA_CONF0_TYPE_LINEAR;
86 flags0 |= (dmaobj->conf0 & NV50_DMA_CONF0_COMP) << 22;
87 flags0 |= (dmaobj->conf0 & NV50_DMA_CONF0_TYPE) << 22;
88 flags0 |= (dmaobj->conf0 & NV50_DMA_CONF0_PRIV);
89 flags5 |= (dmaobj->conf0 & NV50_DMA_CONF0_PART);
91 switch (dmaobj->target) {
92 case NV_MEM_TARGET_VM:
95 case NV_MEM_TARGET_VRAM:
98 case NV_MEM_TARGET_PCI:
101 case NV_MEM_TARGET_PCI_NOSNOOP:
102 flags0 |= 0x00030000;
108 switch (dmaobj->access) {
109 case NV_MEM_ACCESS_VM:
111 case NV_MEM_ACCESS_RO:
112 flags0 |= 0x00040000;
114 case NV_MEM_ACCESS_WO:
115 case NV_MEM_ACCESS_RW:
116 flags0 |= 0x00080000;
120 ret = nouveau_gpuobj_new(parent, parent, 24, 32, 0, pgpuobj);
122 nv_wo32(*pgpuobj, 0x00, flags0);
123 nv_wo32(*pgpuobj, 0x04, lower_32_bits(dmaobj->limit));
124 nv_wo32(*pgpuobj, 0x08, lower_32_bits(dmaobj->start));
125 nv_wo32(*pgpuobj, 0x0c, upper_32_bits(dmaobj->limit) << 24 |
126 upper_32_bits(dmaobj->start));
127 nv_wo32(*pgpuobj, 0x10, 0x00000000);
128 nv_wo32(*pgpuobj, 0x14, flags5);
135 nv50_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
136 struct nouveau_oclass *oclass, void *data, u32 size,
137 struct nouveau_object **pobject)
139 struct nv50_dmaeng_priv *priv;
142 ret = nouveau_dmaeng_create(parent, engine, oclass, &priv);
143 *pobject = nv_object(priv);
147 nv_engine(priv)->sclass = nouveau_dmaobj_sclass;
148 priv->base.bind = nv50_dmaobj_bind;
152 struct nouveau_oclass
153 nv50_dmaeng_oclass = {
154 .handle = NV_ENGINE(DMAOBJ, 0x50),
155 .ofuncs = &(struct nouveau_ofuncs) {
156 .ctor = nv50_dmaeng_ctor,
157 .dtor = _nouveau_dmaeng_dtor,
158 .init = _nouveau_dmaeng_init,
159 .fini = _nouveau_dmaeng_fini,