1 /* 2 * Copyright 2018 Red Hat Inc. 3 * 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: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 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. 21 */ 22 #include "core.h" 23 #include "head.h" 24 25 #include <nouveau_bo.h> 26 27 #include <nvif/timer.h> 28 29 void 30 corec37d_wndw_owner(struct nv50_core *core) 31 { 32 const u32 windows = 8; /*XXX*/ 33 u32 *push, i; 34 if ((push = evo_wait(&core->chan, 2 * windows))) { 35 for (i = 0; i < windows; i++) { 36 evo_mthd(push, 0x1000 + (i * 0x080), 1); 37 evo_data(push, i >> 1); 38 } 39 evo_kick(push, &core->chan); 40 } 41 } 42 43 void 44 corec37d_update(struct nv50_core *core, u32 *interlock, bool ntfy) 45 { 46 u32 *push; 47 if ((push = evo_wait(&core->chan, 9))) { 48 if (ntfy) { 49 evo_mthd(push, 0x020c, 1); 50 evo_data(push, 0x00001000 | NV50_DISP_CORE_NTFY); 51 } 52 53 evo_mthd(push, 0x0218, 2); 54 evo_data(push, interlock[NV50_DISP_INTERLOCK_CURS]); 55 evo_data(push, interlock[NV50_DISP_INTERLOCK_WNDW]); 56 evo_mthd(push, 0x0200, 1); 57 evo_data(push, 0x00000001); 58 59 if (ntfy) { 60 evo_mthd(push, 0x020c, 1); 61 evo_data(push, 0x00000000); 62 } 63 evo_kick(push, &core->chan); 64 } 65 } 66 67 int 68 corec37d_ntfy_wait_done(struct nouveau_bo *bo, u32 offset, 69 struct nvif_device *device) 70 { 71 u32 data; 72 s64 time = nvif_msec(device, 2000ULL, 73 data = nouveau_bo_rd32(bo, offset / 4 + 0); 74 if ((data & 0xc0000000) == 0x80000000) 75 break; 76 usleep_range(1, 2); 77 ); 78 return time < 0 ? time : 0; 79 } 80 81 void 82 corec37d_ntfy_init(struct nouveau_bo *bo, u32 offset) 83 { 84 nouveau_bo_wr32(bo, offset / 4 + 0, 0x00000000); 85 nouveau_bo_wr32(bo, offset / 4 + 1, 0x00000000); 86 nouveau_bo_wr32(bo, offset / 4 + 2, 0x00000000); 87 nouveau_bo_wr32(bo, offset / 4 + 3, 0x00000000); 88 } 89 90 static void 91 corec37d_init(struct nv50_core *core) 92 { 93 const u32 windows = 8; /*XXX*/ 94 u32 *push, i; 95 if ((push = evo_wait(&core->chan, 2 + 5 * windows))) { 96 evo_mthd(push, 0x0208, 1); 97 evo_data(push, core->chan.sync.handle); 98 for (i = 0; i < windows; i++) { 99 evo_mthd(push, 0x1004 + (i * 0x080), 2); 100 evo_data(push, 0x0000001f); 101 evo_data(push, 0x00000000); 102 evo_mthd(push, 0x1010 + (i * 0x080), 1); 103 evo_data(push, 0x00127fff); 104 } 105 evo_kick(push, &core->chan); 106 core->assign_windows = true; 107 } 108 } 109 110 static const struct nv50_core_func 111 corec37d = { 112 .init = corec37d_init, 113 .ntfy_init = corec37d_ntfy_init, 114 .ntfy_wait_done = corec37d_ntfy_wait_done, 115 .update = corec37d_update, 116 .wndw.owner = corec37d_wndw_owner, 117 .head = &headc37d, 118 .sor = &sorc37d, 119 }; 120 121 int 122 corec37d_new(struct nouveau_drm *drm, s32 oclass, struct nv50_core **pcore) 123 { 124 return core507d_new_(&corec37d, drm, oclass, pcore); 125 } 126