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 break;
54 default:
55 return -EINVAL;
56 }
57 } else
58 return 0;
59
60 if (!(dmaobj->conf0 & NVD0_DMA_CONF0_ENABLE)) {
61 if (dmaobj->target == NV_MEM_TARGET_VM) {
62 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_VM;
63 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_LP;
64 } else {
65 dmaobj->conf0 |= NVD0_DMA_CONF0_TYPE_LINEAR;
66 dmaobj->conf0 |= NVD0_DMA_CONF0_PAGE_SP;
67 }
68 }
69
70 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_TYPE) << 20;
71 flags0 |= (dmaobj->conf0 & NVD0_DMA_CONF0_PAGE) >> 4;
72
73 switch (dmaobj->target) {
74 case NV_MEM_TARGET_VRAM:
75 flags0 |= 0x00000009;
76 break;
77 default:
78 return -EINVAL;
79 break;
80 }
81
82 ret = nouveau_gpuobj_new(parent, parent, 24, 32, 0, pgpuobj);
83 if (ret == 0) {
84 nv_wo32(*pgpuobj, 0x00, flags0);
85 nv_wo32(*pgpuobj, 0x04, dmaobj->start >> 8);
86 nv_wo32(*pgpuobj, 0x08, dmaobj->limit >> 8);
87 nv_wo32(*pgpuobj, 0x0c, 0x00000000);
88 nv_wo32(*pgpuobj, 0x10, 0x00000000);
89 nv_wo32(*pgpuobj, 0x14, 0x00000000);
90 }
91
92 return ret;
93}
94
95static int
96nvd0_dmaeng_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
97 struct nouveau_oclass *oclass, void *data, u32 size,
98 struct nouveau_object **pobject)
99{
100 struct nvd0_dmaeng_priv *priv;
101 int ret;
102
103 ret = nouveau_dmaeng_create(parent, engine, oclass, &priv);
104 *pobject = nv_object(priv);
105 if (ret)
106 return ret;
107
108 nv_engine(priv)->sclass = nouveau_dmaobj_sclass;
109 priv->base.bind = nvd0_dmaobj_bind;
110 return 0;
111}
112
113struct nouveau_oclass
114nvd0_dmaeng_oclass = {
115 .handle = NV_ENGINE(DMAOBJ, 0xd0),
116 .ofuncs = &(struct nouveau_ofuncs) {
117 .ctor = nvd0_dmaeng_ctor,
118 .dtor = _nouveau_dmaeng_dtor,
119 .init = _nouveau_dmaeng_init,
120 .fini = _nouveau_dmaeng_fini,
121 },
122};
123