2 * Copyright 2018 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <nvif/class.h>
26 #include <nvif/pushc37b.h>
27 #include <nvif/timer.h>
29 #include <nouveau_bo.h>
32 corec37d_wndw_owner(struct nv50_core *core)
34 struct nvif_push *push = core->chan.push;
35 const u32 windows = 8; /*XXX*/
38 if ((ret = PUSH_WAIT(push, windows * 2)))
41 for (i = 0; i < windows; i++)
42 PUSH_NVSQ(push, NVC37D, 0x1000 + (i * 0x080), i >> 1);
48 corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy)
50 struct nvif_push *push = core->chan.push;
53 if ((ret = PUSH_WAIT(push, 9)))
57 PUSH_NVSQ(push, NVC37D, 0x020c, 0x00001000 | NV50_DISP_CORE_NTFY);
59 PUSH_NVSQ(push, NVC37D, 0x0218, interlock[NV50_DISP_INTERLOCK_CURS],
60 0x021c, interlock[NV50_DISP_INTERLOCK_WNDW]);
61 PUSH_NVSQ(push, NVC37D, 0x0200, 0x00000001);
64 PUSH_NVSQ(push, NVC37D, 0x020c, 0x00000000);
66 return PUSH_KICK(push);
70 corec37d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset,
71 struct nvif_device *device)
74 s64 time = nvif_msec(device, 2000ULL,
75 data = nouveau_bo_rd32(bo, offset / 4 + 0);
76 if ((data & 0xc0000000) == 0x80000000)
80 return time < 0 ? time : 0;
84 corec37d_ntfy_init(struct nouveau_bo *bo, u32 offset)
86 nouveau_bo_wr32(bo, offset / 4 + 0, 0x00000000);
87 nouveau_bo_wr32(bo, offset / 4 + 1, 0x00000000);
88 nouveau_bo_wr32(bo, offset / 4 + 2, 0x00000000);
89 nouveau_bo_wr32(bo, offset / 4 + 3, 0x00000000);
92 int corec37d_caps_init(struct nouveau_drm *drm, struct nv50_disp *disp)
96 ret = nvif_object_ctor(&disp->disp->object, "dispCaps", 0,
97 GV100_DISP_CAPS, NULL, 0, &disp->caps);
100 "Failed to init notifier caps region: %d\n",
105 ret = nvif_object_map(&disp->caps, NULL, 0);
108 "Failed to map notifier caps region: %d\n",
117 corec37d_init(struct nv50_core *core)
119 struct nvif_push *push = core->chan.push;
120 const u32 windows = 8; /*XXX*/
123 if ((ret = PUSH_WAIT(push, 2 + windows * 5)))
126 PUSH_NVSQ(push, NVC37D, 0x0208, core->chan.sync.handle);
128 for (i = 0; i < windows; i++) {
129 PUSH_NVSQ(push, NVC37D, 0x1004 + (i * 0x080), 0x0000001f,
130 0x1008 + (i * 0x080), 0x00000000);
131 PUSH_NVSQ(push, NVC37D, 0x1010 + (i * 0x080), 0x00127fff);
134 core->assign_windows = true;
135 return PUSH_KICK(push);
138 static const struct nv50_core_func
140 .init = corec37d_init,
141 .ntfy_init = corec37d_ntfy_init,
142 .caps_init = corec37d_caps_init,
143 .ntfy_wait_done = corec37d_ntfy_wait_done,
144 .update = corec37d_update,
145 .wndw.owner = corec37d_wndw_owner,
148 #if IS_ENABLED(CONFIG_DEBUG_FS)
154 corec37d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore)
156 return core507d_new_(&corec37d, drm, oclass, pcore);