forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpu/drm/nouveau/dispnv50/corec37d.c
....@@ -22,40 +22,68 @@
2222 #include "core.h"
2323 #include "head.h"
2424
25
+#include <nvif/class.h>
26
+#include <nvif/pushc37b.h>
27
+#include <nvif/timer.h>
28
+
29
+#include <nvhw/class/clc37d.h>
30
+
2531 #include <nouveau_bo.h>
2632
27
-static void
33
+int
34
+corec37d_wndw_owner(struct nv50_core *core)
35
+{
36
+ struct nvif_push *push = core->chan.push;
37
+ const u32 windows = 8; /*XXX*/
38
+ int ret, i;
39
+
40
+ if ((ret = PUSH_WAIT(push, windows * 2)))
41
+ return ret;
42
+
43
+ for (i = 0; i < windows; i++) {
44
+ PUSH_MTHD(push, NVC37D, WINDOW_SET_CONTROL(i),
45
+ NVDEF(NVC37D, WINDOW_SET_CONTROL, OWNER, HEAD(i >> 1)));
46
+ }
47
+
48
+ return 0;
49
+}
50
+
51
+int
2852 corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
2953 {
30
- u32 *push;
31
- if ((push = evo_wait(&core->chan, 9))) {
32
- if (ntfy) {
33
- evo_mthd(push, 0x020c, 1);
34
- evo_data(push, 0x00001000 | NV50_DISP_CORE_NTFY);
35
- }
54
+ struct nvif_push *push = core->chan.push;
55
+ int ret;
3656
37
- evo_mthd(push, 0x0218, 2);
38
- evo_data(push, interlock[NV50_DISP_INTERLOCK_CURS]);
39
- evo_data(push, interlock[NV50_DISP_INTERLOCK_WNDW]);
40
- evo_mthd(push, 0x0200, 1);
41
- evo_data(push, 0x00000001);
57
+ if ((ret = PUSH_WAIT(push, 9)))
58
+ return ret;
4259
43
- if (ntfy) {
44
- evo_mthd(push, 0x020c, 1);
45
- evo_data(push, 0x00000000);
46
- }
47
- evo_kick(push, &core->chan);
60
+ if (ntfy) {
61
+ PUSH_MTHD(push, NVC37D, SET_NOTIFIER_CONTROL,
62
+ NVDEF(NVC37D, SET_NOTIFIER_CONTROL, MODE, WRITE) |
63
+ NVVAL(NVC37D, SET_NOTIFIER_CONTROL, OFFSET, NV50_DISP_CORE_NTFY >> 4) |
64
+ NVDEF(NVC37D, SET_NOTIFIER_CONTROL, NOTIFY, ENABLE));
4865 }
66
+
67
+ PUSH_MTHD(push, NVC37D, SET_INTERLOCK_FLAGS, interlock[NV50_DISP_INTERLOCK_CURS],
68
+ SET_WINDOW_INTERLOCK_FLAGS, interlock[NV50_DISP_INTERLOCK_WNDW]);
69
+ PUSH_MTHD(push, NVC37D, UPDATE, 0x00000001 |
70
+ NVDEF(NVC37D, UPDATE, SPECIAL_HANDLING, NONE) |
71
+ NVDEF(NVC37D, UPDATE, INHIBIT_INTERRUPTS, FALSE));
72
+
73
+ if (ntfy) {
74
+ PUSH_MTHD(push, NVC37D, SET_NOTIFIER_CONTROL,
75
+ NVDEF(NVC37D, SET_NOTIFIER_CONTROL, NOTIFY, DISABLE));
76
+ }
77
+
78
+ return PUSH_KICK(push);
4979 }
5080
5181 int
5282 corec37d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset,
5383 struct nvif_device *device)
5484 {
55
- u32 data;
5685 s64 time = nvif_msec(device, 2000ULL,
57
- data = nouveau_bo_rd32(bo, offset / 4 + 0);
58
- if ((data & 0xc0000000) == 0x80000000)
86
+ if (NVBO_TD32(bo, offset, NV_DISP_NOTIFIER, _0, STATUS, ==, FINISHED))
5987 break;
6088 usleep_range(1, 2);
6189 );
....@@ -65,42 +93,83 @@
6593 void
6694 corec37d_ntfy_init(struct nouveau_bo *bo, u32 offset)
6795 {
68
- nouveau_bo_wr32(bo, offset / 4 + 0, 0x00000000);
69
- nouveau_bo_wr32(bo, offset / 4 + 1, 0x00000000);
70
- nouveau_bo_wr32(bo, offset / 4 + 2, 0x00000000);
71
- nouveau_bo_wr32(bo, offset / 4 + 3, 0x00000000);
96
+ NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _0,
97
+ NVDEF(NV_DISP_NOTIFIER, _0, STATUS, NOT_BEGUN));
98
+ NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _1, 0);
99
+ NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _2, 0);
100
+ NVBO_WR32(bo, offset, NV_DISP_NOTIFIER, _3, 0);
72101 }
73102
74
-void
103
+int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
104
+{
105
+ int ret;
106
+
107
+ ret = nvif_object_ctor(&disp->disp->object, "dispCaps", 0,
108
+ GV100_DISP_CAPS, NULL, 0, &disp->caps);
109
+ if (ret) {
110
+ NV_ERROR(drm,
111
+ "Failed to init notifier caps region: %d\n",
112
+ ret);
113
+ return ret;
114
+ }
115
+
116
+ ret = nvif_object_map(&disp->caps, NULL, 0);
117
+ if (ret) {
118
+ NV_ERROR(drm,
119
+ "Failed to map notifier caps region: %d\n",
120
+ ret);
121
+ return ret;
122
+ }
123
+
124
+ return 0;
125
+}
126
+
127
+static int
75128 corec37d_init(struct nv50_core *core)
76129 {
130
+ struct nvif_push *push = core->chan.push;
77131 const u32 windows = 8; /*XXX*/
78
- u32 *push, i;
79
- if ((push = evo_wait(&core->chan, 2 + 6 * windows + 2))) {
80
- evo_mthd(push, 0x0208, 1);
81
- evo_data(push, core->chan.sync.handle);
82
- for (i = 0; i < windows; i++) {
83
- evo_mthd(push, 0x1000 + (i * 0x080), 3);
84
- evo_data(push, i >> 1);
85
- evo_data(push, 0x00000017);
86
- evo_data(push, 0x00000000);
87
- evo_mthd(push, 0x1010 + (i * 0x080), 1);
88
- evo_data(push, 0x00127fff);
89
- }
90
- evo_mthd(push, 0x0200, 1);
91
- evo_data(push, 0x00000001);
92
- evo_kick(push, &core->chan);
132
+ int ret, i;
133
+
134
+ if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
135
+ return ret;
136
+
137
+ PUSH_MTHD(push, NVC37D, SET_CONTEXT_DMA_NOTIFIER, core->chan.sync.handle);
138
+
139
+ for (i = 0; i < windows; i++) {
140
+ PUSH_MTHD(push, NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS(i),
141
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED1BPP, TRUE) |
142
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED2BPP, TRUE) |
143
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED4BPP, TRUE) |
144
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, RGB_PACKED8BPP, TRUE) |
145
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_FORMAT_USAGE_BOUNDS, YUV_PACKED422, TRUE),
146
+
147
+ WINDOW_SET_WINDOW_ROTATED_FORMAT_USAGE_BOUNDS(i), 0x00000000);
148
+
149
+ PUSH_MTHD(push, NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS(i),
150
+ NVVAL(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, MAX_PIXELS_FETCHED_PER_LINE, 0x7fff) |
151
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, INPUT_LUT, USAGE_1025) |
152
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, INPUT_SCALER_TAPS, TAPS_2) |
153
+ NVDEF(NVC37D, WINDOW_SET_WINDOW_USAGE_BOUNDS, UPSCALING_ALLOWED, FALSE));
93154 }
155
+
156
+ core->assign_windows = true;
157
+ return PUSH_KICK(push);
94158 }
95159
96160 static const struct nv50_core_func
97161 corec37d = {
98162 .init = corec37d_init,
99163 .ntfy_init = corec37d_ntfy_init,
164
+ .caps_init = corec37d_caps_init,
100165 .ntfy_wait_done = corec37d_ntfy_wait_done,
101166 .update = corec37d_update,
167
+ .wndw.owner = corec37d_wndw_owner,
102168 .head = &headc37d,
103169 .sor = &sorc37d,
170
+#if IS_ENABLED(CONFIG_DEBUG_FS)
171
+ .crc = &crcc37d,
172
+#endif
104173 };
105174
106175 int