This source file includes following definitions.
- nvkm_ltc_tags_clear
- nvkm_ltc_zbc_color_get
- nvkm_ltc_zbc_depth_get
- nvkm_ltc_zbc_stencil_get
- nvkm_ltc_invalidate
- nvkm_ltc_flush
- nvkm_ltc_intr
- nvkm_ltc_oneinit
- nvkm_ltc_init
- nvkm_ltc_dtor
- nvkm_ltc_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/memory.h>
27
28 void
29 nvkm_ltc_tags_clear(struct nvkm_device *device, u32 first, u32 count)
30 {
31 struct nvkm_ltc *ltc = device->ltc;
32 const u32 limit = first + count - 1;
33
34 BUG_ON((first > limit) || (limit >= ltc->num_tags));
35
36 mutex_lock(<c->subdev.mutex);
37 ltc->func->cbc_clear(ltc, first, limit);
38 ltc->func->cbc_wait(ltc);
39 mutex_unlock(<c->subdev.mutex);
40 }
41
42 int
43 nvkm_ltc_zbc_color_get(struct nvkm_ltc *ltc, int index, const u32 color[4])
44 {
45 memcpy(ltc->zbc_color[index], color, sizeof(ltc->zbc_color[index]));
46 ltc->func->zbc_clear_color(ltc, index, color);
47 return index;
48 }
49
50 int
51 nvkm_ltc_zbc_depth_get(struct nvkm_ltc *ltc, int index, const u32 depth)
52 {
53 ltc->zbc_depth[index] = depth;
54 ltc->func->zbc_clear_depth(ltc, index, depth);
55 return index;
56 }
57
58 int
59 nvkm_ltc_zbc_stencil_get(struct nvkm_ltc *ltc, int index, const u32 stencil)
60 {
61 ltc->zbc_stencil[index] = stencil;
62 ltc->func->zbc_clear_stencil(ltc, index, stencil);
63 return index;
64 }
65
66 void
67 nvkm_ltc_invalidate(struct nvkm_ltc *ltc)
68 {
69 if (ltc->func->invalidate)
70 ltc->func->invalidate(ltc);
71 }
72
73 void
74 nvkm_ltc_flush(struct nvkm_ltc *ltc)
75 {
76 if (ltc->func->flush)
77 ltc->func->flush(ltc);
78 }
79
80 static void
81 nvkm_ltc_intr(struct nvkm_subdev *subdev)
82 {
83 struct nvkm_ltc *ltc = nvkm_ltc(subdev);
84 ltc->func->intr(ltc);
85 }
86
87 static int
88 nvkm_ltc_oneinit(struct nvkm_subdev *subdev)
89 {
90 struct nvkm_ltc *ltc = nvkm_ltc(subdev);
91 return ltc->func->oneinit(ltc);
92 }
93
94 static int
95 nvkm_ltc_init(struct nvkm_subdev *subdev)
96 {
97 struct nvkm_ltc *ltc = nvkm_ltc(subdev);
98 int i;
99
100 for (i = ltc->zbc_min; i <= ltc->zbc_max; i++) {
101 ltc->func->zbc_clear_color(ltc, i, ltc->zbc_color[i]);
102 ltc->func->zbc_clear_depth(ltc, i, ltc->zbc_depth[i]);
103 if (ltc->func->zbc_clear_stencil)
104 ltc->func->zbc_clear_stencil(ltc, i, ltc->zbc_stencil[i]);
105 }
106
107 ltc->func->init(ltc);
108 return 0;
109 }
110
111 static void *
112 nvkm_ltc_dtor(struct nvkm_subdev *subdev)
113 {
114 struct nvkm_ltc *ltc = nvkm_ltc(subdev);
115 nvkm_memory_unref(<c->tag_ram);
116 return ltc;
117 }
118
119 static const struct nvkm_subdev_func
120 nvkm_ltc = {
121 .dtor = nvkm_ltc_dtor,
122 .oneinit = nvkm_ltc_oneinit,
123 .init = nvkm_ltc_init,
124 .intr = nvkm_ltc_intr,
125 };
126
127 int
128 nvkm_ltc_new_(const struct nvkm_ltc_func *func, struct nvkm_device *device,
129 int index, struct nvkm_ltc **pltc)
130 {
131 struct nvkm_ltc *ltc;
132
133 if (!(ltc = *pltc = kzalloc(sizeof(*ltc), GFP_KERNEL)))
134 return -ENOMEM;
135
136 nvkm_subdev_ctor(&nvkm_ltc, device, index, <c->subdev);
137 ltc->func = func;
138 ltc->zbc_min = 1;
139 ltc->zbc_max = min(func->zbc, NVKM_LTC_MAX_ZBC_CNT) - 1;
140 return 0;
141 }