| .. | .. |
|---|
| 22 | 22 | #include "core.h" |
|---|
| 23 | 23 | #include "head.h" |
|---|
| 24 | 24 | |
|---|
| 25 | +#include <nvif/class.h> |
|---|
| 26 | +#include <nvif/pushc37b.h> |
|---|
| 27 | +#include <nvif/timer.h> |
|---|
| 28 | + |
|---|
| 29 | +#include <nvhw/class/clc37d.h> |
|---|
| 30 | + |
|---|
| 25 | 31 | #include <nouveau_bo.h> |
|---|
| 26 | 32 | |
|---|
| 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 |
|---|
| 28 | 52 | corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy) |
|---|
| 29 | 53 | { |
|---|
| 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; |
|---|
| 36 | 56 | |
|---|
| 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; |
|---|
| 42 | 59 | |
|---|
| 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)); |
|---|
| 48 | 65 | } |
|---|
| 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); |
|---|
| 49 | 79 | } |
|---|
| 50 | 80 | |
|---|
| 51 | 81 | int |
|---|
| 52 | 82 | corec37d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset, |
|---|
| 53 | 83 | struct nvif_device *device) |
|---|
| 54 | 84 | { |
|---|
| 55 | | - u32 data; |
|---|
| 56 | 85 | 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)) |
|---|
| 59 | 87 | break; |
|---|
| 60 | 88 | usleep_range(1, 2); |
|---|
| 61 | 89 | ); |
|---|
| .. | .. |
|---|
| 65 | 93 | void |
|---|
| 66 | 94 | corec37d_ntfy_init(struct nouveau_bo *bo, u32 offset) |
|---|
| 67 | 95 | { |
|---|
| 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); |
|---|
| 72 | 101 | } |
|---|
| 73 | 102 | |
|---|
| 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 |
|---|
| 75 | 128 | corec37d_init(struct nv50_core *core) |
|---|
| 76 | 129 | { |
|---|
| 130 | + struct nvif_push *push = core->chan.push; |
|---|
| 77 | 131 | 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)); |
|---|
| 93 | 154 | } |
|---|
| 155 | + |
|---|
| 156 | + core->assign_windows = true; |
|---|
| 157 | + return PUSH_KICK(push); |
|---|
| 94 | 158 | } |
|---|
| 95 | 159 | |
|---|
| 96 | 160 | static const struct nv50_core_func |
|---|
| 97 | 161 | corec37d = { |
|---|
| 98 | 162 | .init = corec37d_init, |
|---|
| 99 | 163 | .ntfy_init = corec37d_ntfy_init, |
|---|
| 164 | + .caps_init = corec37d_caps_init, |
|---|
| 100 | 165 | .ntfy_wait_done = corec37d_ntfy_wait_done, |
|---|
| 101 | 166 | .update = corec37d_update, |
|---|
| 167 | + .wndw.owner = corec37d_wndw_owner, |
|---|
| 102 | 168 | .head = &headc37d, |
|---|
| 103 | 169 | .sor = &sorc37d, |
|---|
| 170 | +#if IS_ENABLED(CONFIG_DEBUG_FS) |
|---|
| 171 | + .crc = &crcc37d, |
|---|
| 172 | +#endif |
|---|
| 104 | 173 | }; |
|---|
| 105 | 174 | |
|---|
| 106 | 175 | int |
|---|