1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <core/device.h>
26#include <core/gpuobj.h>
27#include <core/class.h>
28
29#include <subdev/fb.h>
30#include <engine/dmaobj.h>
31
32struct nvd0_dmaeng_priv {
33 struct nouveau_dmaeng base;
34};
35
36static int
37nvd0_dmaobj_bind(struct nouveau_dmaeng *dmaeng,
38 struct nouveau_object *parent,
39 struct nouveau_dmaobj *dmaobj,
40 struct nouveau_gpuobj **pgpuobj)
41{
42 u32 flags0 = 0x00000000;
43 int ret;
44
45 if (!nv_iclass(parent, NV_ENGCTX_CLASS)) {
46 switch (nv_mclass(parent->parent)) {
47 case NVD0_DISP_MAST_CLASS:
48 case NVD0_DISP_SYNC_CLASS:
49 case NVD0_DISP_OVLY_CLASS:
50 case NVE0_DISP_MAST_CLASS:
51 case NVE0_DISP_SYNC_CLASS:
52 case NVE0_DISP_OVLY_CLASS:
53 case NVF0_DISP_MAST_CLASS:
54 case NVF0_DISP_SYNC_CLASS:
55 case NVF0_DISP_OVLY_CLASS:
56 break;
57 default:
58 return -EINVAL;
59 }
60 } else
61 return 0;
62
63 if (!(dmaobj->conf0 & NVD0_DMA_CONF0_ENABLE)) {
64 if (dmaobj->target == NV_MEM_TARGET_VM) {
65 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_VM;
66 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_LP;
67 } else {
68 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_LINEAR;
69 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_SP;
70 }
71 }
72
73 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_TYPE) << 20;
74 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_PAGE) >> 4;
75
76 switch (dmaobj->target) {
77 case NV_MEM_TARGET_VRAM:
78 flags0 |= 0x00000009;
79 break;
80 default:
81 return -EINVAL;
82 break;
83 }
84
85 ret = nouveau_gpuobj_new(parent, parent, 24, 32, 0, pgpuobj);
86 if (ret == 0) {
87 nv_wo32(*pgpuobj, 0x00, flags0);
88 nv_wo32(*pgpuobj, 0x04, dmaobj->start >> 8);
89 nv_wo32(*pgpuobj, 0x08, dmaobj->limit >> 8);
90 nv_wo32(*pgpuobj, 0x0c, 0x00000000);
91 nv_wo32(*pgpuobj, 0x10, 0x00000000);
92 nv_wo32(*pgpuobj, 0x14, 0x00000000);
93 }
94
95 return ret;
96}
97
98static int
99nvd0_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
100 struct nouveau_oclass *oclass, void *data, u32 size,
101 struct nouveau_object **pobject)
102{
103 struct nvd0_dmaeng_priv *priv;
104 int ret;
105
106 ret = nouveau_dmaeng_create(parent, engine, oclass, &priv);
107 *pobject = nv_object(priv);
108 if (ret)
109 return ret;
110
111 nv_engine(priv)->sclass = nouveau_dmaobj_sclass;
112 priv->base.bind = nvd0_dmaobj_bind;
113 return 0;
114}
115
116struct nouveau_oclass
117nvd0_dmaeng_oclass = {
118 .handle = NV_ENGINE(DMAOBJ, 0xd0),
119 .ofuncs = &(struct nouveau_ofuncs) {
120 .ctor = nvd0_dmaeng_ctor,
121 .dtor = _nouveau_dmaeng_dtor,
122 .init = _nouveau_dmaeng_init,
123 .fini = _nouveau_dmaeng_fini,
124 },
125};
126