This source file includes following definitions.
- nvkm_dma_oclass_new
- nvkm_dma_oclass_fifo_new
- nvkm_dma_oclass_base_get
- nvkm_dma_oclass_fifo_get
- nvkm_dma_dtor
- nvkm_dma_new_
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 #include "priv.h"
25
26 #include <core/client.h>
27 #include <engine/fifo.h>
28
29 #include <nvif/class.h>
30
31 static int
32 nvkm_dma_oclass_new(struct nvkm_device *device,
33 const struct nvkm_oclass *oclass, void *data, u32 size,
34 struct nvkm_object **pobject)
35 {
36 struct nvkm_dma *dma = nvkm_dma(oclass->engine);
37 struct nvkm_dmaobj *dmaobj = NULL;
38 int ret;
39
40 ret = dma->func->class_new(dma, oclass, data, size, &dmaobj);
41 if (dmaobj)
42 *pobject = &dmaobj->object;
43 return ret;
44 }
45
46 static const struct nvkm_device_oclass
47 nvkm_dma_oclass_base = {
48 .ctor = nvkm_dma_oclass_new,
49 };
50
51 static int
52 nvkm_dma_oclass_fifo_new(const struct nvkm_oclass *oclass, void *data, u32 size,
53 struct nvkm_object **pobject)
54 {
55 return nvkm_dma_oclass_new(oclass->engine->subdev.device,
56 oclass, data, size, pobject);
57 }
58
59 static const struct nvkm_sclass
60 nvkm_dma_sclass[] = {
61 { 0, 0, NV_DMA_FROM_MEMORY, NULL, nvkm_dma_oclass_fifo_new },
62 { 0, 0, NV_DMA_TO_MEMORY, NULL, nvkm_dma_oclass_fifo_new },
63 { 0, 0, NV_DMA_IN_MEMORY, NULL, nvkm_dma_oclass_fifo_new },
64 };
65
66 static int
67 nvkm_dma_oclass_base_get(struct nvkm_oclass *sclass, int index,
68 const struct nvkm_device_oclass **class)
69 {
70 const int count = ARRAY_SIZE(nvkm_dma_sclass);
71 if (index < count) {
72 const struct nvkm_sclass *oclass = &nvkm_dma_sclass[index];
73 sclass->base = oclass[0];
74 sclass->engn = oclass;
75 *class = &nvkm_dma_oclass_base;
76 return index;
77 }
78 return count;
79 }
80
81 static int
82 nvkm_dma_oclass_fifo_get(struct nvkm_oclass *oclass, int index)
83 {
84 const int count = ARRAY_SIZE(nvkm_dma_sclass);
85 if (index < count) {
86 oclass->base = nvkm_dma_sclass[index];
87 return index;
88 }
89 return count;
90 }
91
92 static void *
93 nvkm_dma_dtor(struct nvkm_engine *engine)
94 {
95 return nvkm_dma(engine);
96 }
97
98 static const struct nvkm_engine_func
99 nvkm_dma = {
100 .dtor = nvkm_dma_dtor,
101 .base.sclass = nvkm_dma_oclass_base_get,
102 .fifo.sclass = nvkm_dma_oclass_fifo_get,
103 };
104
105 int
106 nvkm_dma_new_(const struct nvkm_dma_func *func, struct nvkm_device *device,
107 int index, struct nvkm_dma **pdma)
108 {
109 struct nvkm_dma *dma;
110
111 if (!(dma = *pdma = kzalloc(sizeof(*dma), GFP_KERNEL)))
112 return -ENOMEM;
113 dma->func = func;
114
115 return nvkm_engine_ctor(&nvkm_dma, device, index, true, &dma->engine);
116 }