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 "priv.h" 23 #include "chan.h" 24 #include "hdmi.h" 25 #include "head.h" 26 #include "ior.h" 27 #include "outp.h" 28 29 #include <core/client.h> 30 #include <core/gpuobj.h> 31 #include <core/ramht.h> 32 #include <subdev/timer.h> 33 34 #include <nvif/class.h> 35 #include <nvif/unpack.h> 36 37 static void 38 gv100_sor_hda_device_entry(struct nvkm_ior *ior, int head) 39 { 40 struct nvkm_device *device = ior->disp->engine.subdev.device; 41 const u32 hoff = 0x800 * head; 42 43 nvkm_mask(device, 0x616528 + hoff, 0x00000070, head << 4); 44 } 45 46 const struct nvkm_ior_func_hda 47 gv100_sor_hda = { 48 .hpd = gf119_sor_hda_hpd, 49 .eld = gf119_sor_hda_eld, 50 .device_entry = gv100_sor_hda_device_entry, 51 }; 52 53 void 54 gv100_sor_dp_watermark(struct nvkm_ior *sor, int head, u8 watermark) 55 { 56 struct nvkm_device *device = sor->disp->engine.subdev.device; 57 const u32 hoff = head * 0x800; 58 59 nvkm_mask(device, 0x616550 + hoff, 0x0c00003f, 0x08000000 | watermark); 60 } 61 62 void 63 gv100_sor_dp_audio_sym(struct nvkm_ior *sor, int head, u16 h, u32 v) 64 { 65 struct nvkm_device *device = sor->disp->engine.subdev.device; 66 const u32 hoff = head * 0x800; 67 68 nvkm_mask(device, 0x616568 + hoff, 0x0000ffff, h); 69 nvkm_mask(device, 0x61656c + hoff, 0x00ffffff, v); 70 } 71 72 void 73 gv100_sor_dp_audio(struct nvkm_ior *sor, int head, bool enable) 74 { 75 struct nvkm_device *device = sor->disp->engine.subdev.device; 76 const u32 hoff = 0x800 * head; 77 const u32 data = 0x80000000 | (0x00000001 * enable); 78 const u32 mask = 0x8000000d; 79 80 nvkm_mask(device, 0x616560 + hoff, mask, data); 81 nvkm_msec(device, 2000, 82 if (!(nvkm_rd32(device, 0x616560 + hoff) & 0x80000000)) 83 break; 84 ); 85 } 86 87 static const struct nvkm_ior_func_dp 88 gv100_sor_dp = { 89 .lanes = { 0, 1, 2, 3 }, 90 .links = gf119_sor_dp_links, 91 .power = g94_sor_dp_power, 92 .pattern = gm107_sor_dp_pattern, 93 .drive = gm200_sor_dp_drive, 94 .audio = gv100_sor_dp_audio, 95 .audio_sym = gv100_sor_dp_audio_sym, 96 .watermark = gv100_sor_dp_watermark, 97 }; 98 99 static void 100 gv100_sor_hdmi_infoframe_vsi(struct nvkm_ior *ior, int head, void *data, u32 size) 101 { 102 struct nvkm_device *device = ior->disp->engine.subdev.device; 103 struct packed_hdmi_infoframe vsi; 104 const u32 hoff = head * 0x400; 105 106 pack_hdmi_infoframe(&vsi, data, size); 107 108 nvkm_mask(device, 0x6f0100 + hoff, 0x00010001, 0x00000000); 109 if (!size) 110 return; 111 112 nvkm_wr32(device, 0x6f0108 + hoff, vsi.header); 113 nvkm_wr32(device, 0x6f010c + hoff, vsi.subpack0_low); 114 nvkm_wr32(device, 0x6f0110 + hoff, vsi.subpack0_high); 115 nvkm_wr32(device, 0x6f0114 + hoff, 0x00000000); 116 nvkm_wr32(device, 0x6f0118 + hoff, 0x00000000); 117 nvkm_wr32(device, 0x6f011c + hoff, 0x00000000); 118 nvkm_wr32(device, 0x6f0120 + hoff, 0x00000000); 119 nvkm_wr32(device, 0x6f0124 + hoff, 0x00000000); 120 nvkm_mask(device, 0x6f0100 + hoff, 0x00000001, 0x00000001); 121 } 122 123 static void 124 gv100_sor_hdmi_infoframe_avi(struct nvkm_ior *ior, int head, void *data, u32 size) 125 { 126 struct nvkm_device *device = ior->disp->engine.subdev.device; 127 struct packed_hdmi_infoframe avi; 128 const u32 hoff = head * 0x400; 129 130 pack_hdmi_infoframe(&avi, data, size); 131 132 nvkm_mask(device, 0x6f0000 + hoff, 0x00000001, 0x00000000); 133 if (!size) 134 return; 135 136 nvkm_wr32(device, 0x6f0008 + hoff, avi.header); 137 nvkm_wr32(device, 0x6f000c + hoff, avi.subpack0_low); 138 nvkm_wr32(device, 0x6f0010 + hoff, avi.subpack0_high); 139 nvkm_wr32(device, 0x6f0014 + hoff, avi.subpack1_low); 140 nvkm_wr32(device, 0x6f0018 + hoff, avi.subpack1_high); 141 142 nvkm_mask(device, 0x6f0000 + hoff, 0x00000001, 0x00000001); 143 } 144 145 static void 146 gv100_sor_hdmi_ctrl(struct nvkm_ior *ior, int head, bool enable, u8 max_ac_packet, u8 rekey) 147 { 148 struct nvkm_device *device = ior->disp->engine.subdev.device; 149 const u32 ctrl = 0x40000000 * enable | 150 max_ac_packet << 16 | 151 rekey; 152 const u32 hoff = head * 0x800; 153 const u32 hdmi = head * 0x400; 154 155 if (!(ctrl & 0x40000000)) { 156 nvkm_mask(device, 0x6165c0 + hoff, 0x40000000, 0x00000000); 157 nvkm_mask(device, 0x6f0100 + hdmi, 0x00000001, 0x00000000); 158 nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000); 159 nvkm_mask(device, 0x6f0000 + hdmi, 0x00000001, 0x00000000); 160 return; 161 } 162 163 /* General Control (GCP). */ 164 nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000); 165 nvkm_wr32(device, 0x6f00cc + hdmi, 0x00000010); 166 nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000001); 167 168 /* Audio Clock Regeneration (ACR). */ 169 nvkm_wr32(device, 0x6f0080 + hdmi, 0x82000000); 170 171 /* NV_PDISP_SF_HDMI_CTRL. */ 172 nvkm_mask(device, 0x6165c0 + hoff, 0x401f007f, ctrl); 173 } 174 175 const struct nvkm_ior_func_hdmi 176 gv100_sor_hdmi = { 177 .ctrl = gv100_sor_hdmi_ctrl, 178 .scdc = gm200_sor_hdmi_scdc, 179 .infoframe_avi = gv100_sor_hdmi_infoframe_avi, 180 .infoframe_vsi = gv100_sor_hdmi_infoframe_vsi, 181 }; 182 183 void 184 gv100_sor_state(struct nvkm_ior *sor, struct nvkm_ior_state *state) 185 { 186 struct nvkm_device *device = sor->disp->engine.subdev.device; 187 const u32 coff = (state == &sor->arm) * 0x8000 + sor->id * 0x20; 188 u32 ctrl = nvkm_rd32(device, 0x680300 + coff); 189 190 state->proto_evo = (ctrl & 0x00000f00) >> 8; 191 switch (state->proto_evo) { 192 case 0: state->proto = LVDS; state->link = 1; break; 193 case 1: state->proto = TMDS; state->link = 1; break; 194 case 2: state->proto = TMDS; state->link = 2; break; 195 case 5: state->proto = TMDS; state->link = 3; break; 196 case 8: state->proto = DP; state->link = 1; break; 197 case 9: state->proto = DP; state->link = 2; break; 198 default: 199 state->proto = UNKNOWN; 200 break; 201 } 202 203 state->head = ctrl & 0x000000ff; 204 } 205 206 static const struct nvkm_ior_func 207 gv100_sor = { 208 .route = { 209 .get = gm200_sor_route_get, 210 .set = gm200_sor_route_set, 211 }, 212 .state = gv100_sor_state, 213 .power = nv50_sor_power, 214 .clock = gf119_sor_clock, 215 .hdmi = &gv100_sor_hdmi, 216 .dp = &gv100_sor_dp, 217 .hda = &gv100_sor_hda, 218 }; 219 220 static int 221 gv100_sor_new(struct nvkm_disp *disp, int id) 222 { 223 struct nvkm_device *device = disp->engine.subdev.device; 224 u32 hda; 225 226 if (!((hda = nvkm_rd32(device, 0x08a15c)) & 0x40000000)) 227 hda = nvkm_rd32(device, 0x118fb0) >> 8; 228 229 return nvkm_ior_new_(&gv100_sor, disp, SOR, id, hda & BIT(id)); 230 } 231 232 int 233 gv100_sor_cnt(struct nvkm_disp *disp, unsigned long *pmask) 234 { 235 struct nvkm_device *device = disp->engine.subdev.device; 236 237 *pmask = (nvkm_rd32(device, 0x610060) & 0x0000ff00) >> 8; 238 return (nvkm_rd32(device, 0x610074) & 0x00000f00) >> 8; 239 } 240 241 static void 242 gv100_head_vblank_put(struct nvkm_head *head) 243 { 244 struct nvkm_device *device = head->disp->engine.subdev.device; 245 nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000004, 0x00000000); 246 } 247 248 static void 249 gv100_head_vblank_get(struct nvkm_head *head) 250 { 251 struct nvkm_device *device = head->disp->engine.subdev.device; 252 nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000004, 0x00000004); 253 } 254 255 static void 256 gv100_head_rgpos(struct nvkm_head *head, u16 *hline, u16 *vline) 257 { 258 struct nvkm_device *device = head->disp->engine.subdev.device; 259 const u32 hoff = head->id * 0x800; 260 /* vline read locks hline. */ 261 *vline = nvkm_rd32(device, 0x616330 + hoff) & 0x0000ffff; 262 *hline = nvkm_rd32(device, 0x616334 + hoff) & 0x0000ffff; 263 } 264 265 static void 266 gv100_head_state(struct nvkm_head *head, struct nvkm_head_state *state) 267 { 268 struct nvkm_device *device = head->disp->engine.subdev.device; 269 const u32 hoff = (state == &head->arm) * 0x8000 + head->id * 0x400; 270 u32 data; 271 272 data = nvkm_rd32(device, 0x682064 + hoff); 273 state->vtotal = (data & 0xffff0000) >> 16; 274 state->htotal = (data & 0x0000ffff); 275 data = nvkm_rd32(device, 0x682068 + hoff); 276 state->vsynce = (data & 0xffff0000) >> 16; 277 state->hsynce = (data & 0x0000ffff); 278 data = nvkm_rd32(device, 0x68206c + hoff); 279 state->vblanke = (data & 0xffff0000) >> 16; 280 state->hblanke = (data & 0x0000ffff); 281 data = nvkm_rd32(device, 0x682070 + hoff); 282 state->vblanks = (data & 0xffff0000) >> 16; 283 state->hblanks = (data & 0x0000ffff); 284 state->hz = nvkm_rd32(device, 0x68200c + hoff); 285 286 data = nvkm_rd32(device, 0x682004 + hoff); 287 switch ((data & 0x000000f0) >> 4) { 288 case 5: state->or.depth = 30; break; 289 case 4: state->or.depth = 24; break; 290 case 1: state->or.depth = 18; break; 291 default: 292 state->or.depth = 18; 293 WARN_ON(1); 294 break; 295 } 296 } 297 298 static const struct nvkm_head_func 299 gv100_head = { 300 .state = gv100_head_state, 301 .rgpos = gv100_head_rgpos, 302 .rgclk = gf119_head_rgclk, 303 .vblank_get = gv100_head_vblank_get, 304 .vblank_put = gv100_head_vblank_put, 305 }; 306 307 int 308 gv100_head_new(struct nvkm_disp *disp, int id) 309 { 310 struct nvkm_device *device = disp->engine.subdev.device; 311 312 if (!(nvkm_rd32(device, 0x610060) & (0x00000001 << id))) 313 return 0; 314 315 return nvkm_head_new_(&gv100_head, disp, id); 316 } 317 318 int 319 gv100_head_cnt(struct nvkm_disp *disp, unsigned long *pmask) 320 { 321 struct nvkm_device *device = disp->engine.subdev.device; 322 323 *pmask = nvkm_rd32(device, 0x610060) & 0x000000ff; 324 return nvkm_rd32(device, 0x610074) & 0x0000000f; 325 } 326 327 const struct nvkm_event_func 328 gv100_disp_chan_uevent = { 329 }; 330 331 u64 332 gv100_disp_chan_user(struct nvkm_disp_chan *chan, u64 *psize) 333 { 334 *psize = 0x1000; 335 return 0x690000 + ((chan->chid.user - 1) * 0x1000); 336 } 337 338 static int 339 gv100_disp_dmac_idle(struct nvkm_disp_chan *chan) 340 { 341 struct nvkm_device *device = chan->disp->engine.subdev.device; 342 const u32 soff = (chan->chid.ctrl - 1) * 0x04; 343 nvkm_msec(device, 2000, 344 u32 stat = nvkm_rd32(device, 0x610664 + soff); 345 if ((stat & 0x000f0000) == 0x00040000) 346 return 0; 347 ); 348 return -EBUSY; 349 } 350 351 int 352 gv100_disp_dmac_bind(struct nvkm_disp_chan *chan, 353 struct nvkm_object *object, u32 handle) 354 { 355 return nvkm_ramht_insert(chan->disp->ramht, object, chan->chid.user, -9, handle, 356 chan->chid.user << 25 | 0x00000040); 357 } 358 359 void 360 gv100_disp_dmac_fini(struct nvkm_disp_chan *chan) 361 { 362 struct nvkm_device *device = chan->disp->engine.subdev.device; 363 const u32 uoff = (chan->chid.ctrl - 1) * 0x1000; 364 const u32 coff = chan->chid.ctrl * 0x04; 365 nvkm_mask(device, 0x6104e0 + coff, 0x00000010, 0x00000000); 366 gv100_disp_dmac_idle(chan); 367 nvkm_mask(device, 0x6104e0 + coff, 0x00000002, 0x00000000); 368 chan->suspend_put = nvkm_rd32(device, 0x690000 + uoff); 369 } 370 371 int 372 gv100_disp_dmac_init(struct nvkm_disp_chan *chan) 373 { 374 struct nvkm_subdev *subdev = &chan->disp->engine.subdev; 375 struct nvkm_device *device = subdev->device; 376 const u32 uoff = (chan->chid.ctrl - 1) * 0x1000; 377 const u32 poff = chan->chid.ctrl * 0x10; 378 const u32 coff = chan->chid.ctrl * 0x04; 379 380 nvkm_wr32(device, 0x610b24 + poff, lower_32_bits(chan->push)); 381 nvkm_wr32(device, 0x610b20 + poff, upper_32_bits(chan->push)); 382 nvkm_wr32(device, 0x610b28 + poff, 0x00000001); 383 nvkm_wr32(device, 0x610b2c + poff, 0x00000040); 384 385 nvkm_mask(device, 0x6104e0 + coff, 0x00000010, 0x00000010); 386 nvkm_wr32(device, 0x690000 + uoff, chan->suspend_put); 387 nvkm_wr32(device, 0x6104e0 + coff, 0x00000013); 388 return gv100_disp_dmac_idle(chan); 389 } 390 391 static void 392 gv100_disp_wimm_intr(struct nvkm_disp_chan *chan, bool en) 393 { 394 struct nvkm_device *device = chan->disp->engine.subdev.device; 395 const u32 mask = 0x00000001 << chan->head; 396 const u32 data = en ? mask : 0; 397 nvkm_mask(device, 0x611da8, mask, data); 398 } 399 400 static const struct nvkm_disp_chan_func 401 gv100_disp_wimm_func = { 402 .push = nv50_disp_dmac_push, 403 .init = gv100_disp_dmac_init, 404 .fini = gv100_disp_dmac_fini, 405 .intr = gv100_disp_wimm_intr, 406 .user = gv100_disp_chan_user, 407 }; 408 409 const struct nvkm_disp_chan_user 410 gv100_disp_wimm = { 411 .func = &gv100_disp_wimm_func, 412 .ctrl = 33, 413 .user = 33, 414 }; 415 416 static const struct nvkm_disp_mthd_list 417 gv100_disp_wndw_mthd_base = { 418 .mthd = 0x0000, 419 .addr = 0x000000, 420 .data = { 421 { 0x0200, 0x690200 }, 422 { 0x020c, 0x69020c }, 423 { 0x0210, 0x690210 }, 424 { 0x0214, 0x690214 }, 425 { 0x0218, 0x690218 }, 426 { 0x021c, 0x69021c }, 427 { 0x0220, 0x690220 }, 428 { 0x0224, 0x690224 }, 429 { 0x0228, 0x690228 }, 430 { 0x022c, 0x69022c }, 431 { 0x0230, 0x690230 }, 432 { 0x0234, 0x690234 }, 433 { 0x0238, 0x690238 }, 434 { 0x0240, 0x690240 }, 435 { 0x0244, 0x690244 }, 436 { 0x0248, 0x690248 }, 437 { 0x024c, 0x69024c }, 438 { 0x0250, 0x690250 }, 439 { 0x0254, 0x690254 }, 440 { 0x0260, 0x690260 }, 441 { 0x0264, 0x690264 }, 442 { 0x0268, 0x690268 }, 443 { 0x026c, 0x69026c }, 444 { 0x0270, 0x690270 }, 445 { 0x0274, 0x690274 }, 446 { 0x0280, 0x690280 }, 447 { 0x0284, 0x690284 }, 448 { 0x0288, 0x690288 }, 449 { 0x028c, 0x69028c }, 450 { 0x0290, 0x690290 }, 451 { 0x0298, 0x690298 }, 452 { 0x029c, 0x69029c }, 453 { 0x02a0, 0x6902a0 }, 454 { 0x02a4, 0x6902a4 }, 455 { 0x02a8, 0x6902a8 }, 456 { 0x02ac, 0x6902ac }, 457 { 0x02b0, 0x6902b0 }, 458 { 0x02b4, 0x6902b4 }, 459 { 0x02b8, 0x6902b8 }, 460 { 0x02bc, 0x6902bc }, 461 { 0x02c0, 0x6902c0 }, 462 { 0x02c4, 0x6902c4 }, 463 { 0x02c8, 0x6902c8 }, 464 { 0x02cc, 0x6902cc }, 465 { 0x02d0, 0x6902d0 }, 466 { 0x02d4, 0x6902d4 }, 467 { 0x02d8, 0x6902d8 }, 468 { 0x02dc, 0x6902dc }, 469 { 0x02e0, 0x6902e0 }, 470 { 0x02e4, 0x6902e4 }, 471 { 0x02e8, 0x6902e8 }, 472 { 0x02ec, 0x6902ec }, 473 { 0x02f0, 0x6902f0 }, 474 { 0x02f4, 0x6902f4 }, 475 { 0x02f8, 0x6902f8 }, 476 { 0x02fc, 0x6902fc }, 477 { 0x0300, 0x690300 }, 478 { 0x0304, 0x690304 }, 479 { 0x0308, 0x690308 }, 480 { 0x0310, 0x690310 }, 481 { 0x0314, 0x690314 }, 482 { 0x0318, 0x690318 }, 483 { 0x031c, 0x69031c }, 484 { 0x0320, 0x690320 }, 485 { 0x0324, 0x690324 }, 486 { 0x0328, 0x690328 }, 487 { 0x032c, 0x69032c }, 488 { 0x033c, 0x69033c }, 489 { 0x0340, 0x690340 }, 490 { 0x0344, 0x690344 }, 491 { 0x0348, 0x690348 }, 492 { 0x034c, 0x69034c }, 493 { 0x0350, 0x690350 }, 494 { 0x0354, 0x690354 }, 495 { 0x0358, 0x690358 }, 496 { 0x0364, 0x690364 }, 497 { 0x0368, 0x690368 }, 498 { 0x036c, 0x69036c }, 499 { 0x0370, 0x690370 }, 500 { 0x0374, 0x690374 }, 501 { 0x0380, 0x690380 }, 502 {} 503 } 504 }; 505 506 static const struct nvkm_disp_chan_mthd 507 gv100_disp_wndw_mthd = { 508 .name = "Window", 509 .addr = 0x001000, 510 .prev = 0x000800, 511 .data = { 512 { "Global", 1, &gv100_disp_wndw_mthd_base }, 513 {} 514 } 515 }; 516 517 static void 518 gv100_disp_wndw_intr(struct nvkm_disp_chan *chan, bool en) 519 { 520 struct nvkm_device *device = chan->disp->engine.subdev.device; 521 const u32 mask = 0x00000001 << chan->head; 522 const u32 data = en ? mask : 0; 523 nvkm_mask(device, 0x611da4, mask, data); 524 } 525 526 static const struct nvkm_disp_chan_func 527 gv100_disp_wndw_func = { 528 .push = nv50_disp_dmac_push, 529 .init = gv100_disp_dmac_init, 530 .fini = gv100_disp_dmac_fini, 531 .intr = gv100_disp_wndw_intr, 532 .user = gv100_disp_chan_user, 533 .bind = gv100_disp_dmac_bind, 534 }; 535 536 const struct nvkm_disp_chan_user 537 gv100_disp_wndw = { 538 .func = &gv100_disp_wndw_func, 539 .ctrl = 1, 540 .user = 1, 541 .mthd = &gv100_disp_wndw_mthd, 542 }; 543 544 int 545 gv100_disp_wndw_cnt(struct nvkm_disp *disp, unsigned long *pmask) 546 { 547 struct nvkm_device *device = disp->engine.subdev.device; 548 549 *pmask = nvkm_rd32(device, 0x610064); 550 return (nvkm_rd32(device, 0x610074) & 0x03f00000) >> 20; 551 } 552 553 static int 554 gv100_disp_curs_idle(struct nvkm_disp_chan *chan) 555 { 556 struct nvkm_device *device = chan->disp->engine.subdev.device; 557 const u32 soff = (chan->chid.ctrl - 1) * 0x04; 558 nvkm_msec(device, 2000, 559 u32 stat = nvkm_rd32(device, 0x610664 + soff); 560 if ((stat & 0x00070000) == 0x00040000) 561 return 0; 562 ); 563 return -EBUSY; 564 } 565 566 static void 567 gv100_disp_curs_intr(struct nvkm_disp_chan *chan, bool en) 568 { 569 struct nvkm_device *device = chan->disp->engine.subdev.device; 570 const u32 mask = 0x00010000 << chan->head; 571 const u32 data = en ? mask : 0; 572 nvkm_mask(device, 0x611dac, mask, data); 573 } 574 575 static void 576 gv100_disp_curs_fini(struct nvkm_disp_chan *chan) 577 { 578 struct nvkm_device *device = chan->disp->engine.subdev.device; 579 const u32 hoff = chan->chid.ctrl * 4; 580 nvkm_mask(device, 0x6104e0 + hoff, 0x00000010, 0x00000010); 581 gv100_disp_curs_idle(chan); 582 nvkm_mask(device, 0x6104e0 + hoff, 0x00000001, 0x00000000); 583 } 584 585 static int 586 gv100_disp_curs_init(struct nvkm_disp_chan *chan) 587 { 588 struct nvkm_subdev *subdev = &chan->disp->engine.subdev; 589 struct nvkm_device *device = subdev->device; 590 nvkm_wr32(device, 0x6104e0 + chan->chid.ctrl * 4, 0x00000001); 591 return gv100_disp_curs_idle(chan); 592 } 593 594 static const struct nvkm_disp_chan_func 595 gv100_disp_curs_func = { 596 .init = gv100_disp_curs_init, 597 .fini = gv100_disp_curs_fini, 598 .intr = gv100_disp_curs_intr, 599 .user = gv100_disp_chan_user, 600 }; 601 602 const struct nvkm_disp_chan_user 603 gv100_disp_curs = { 604 .func = &gv100_disp_curs_func, 605 .ctrl = 73, 606 .user = 73, 607 }; 608 609 static const struct nvkm_disp_mthd_list 610 gv100_disp_core_mthd_base = { 611 .mthd = 0x0000, 612 .addr = 0x000000, 613 .data = { 614 { 0x0200, 0x680200 }, 615 { 0x0208, 0x680208 }, 616 { 0x020c, 0x68020c }, 617 { 0x0210, 0x680210 }, 618 { 0x0214, 0x680214 }, 619 { 0x0218, 0x680218 }, 620 { 0x021c, 0x68021c }, 621 {} 622 } 623 }; 624 625 static const struct nvkm_disp_mthd_list 626 gv100_disp_core_mthd_sor = { 627 .mthd = 0x0020, 628 .addr = 0x000020, 629 .data = { 630 { 0x0300, 0x680300 }, 631 { 0x0304, 0x680304 }, 632 { 0x0308, 0x680308 }, 633 { 0x030c, 0x68030c }, 634 {} 635 } 636 }; 637 638 static const struct nvkm_disp_mthd_list 639 gv100_disp_core_mthd_wndw = { 640 .mthd = 0x0080, 641 .addr = 0x000080, 642 .data = { 643 { 0x1000, 0x681000 }, 644 { 0x1004, 0x681004 }, 645 { 0x1008, 0x681008 }, 646 { 0x100c, 0x68100c }, 647 { 0x1010, 0x681010 }, 648 {} 649 } 650 }; 651 652 static const struct nvkm_disp_mthd_list 653 gv100_disp_core_mthd_head = { 654 .mthd = 0x0400, 655 .addr = 0x000400, 656 .data = { 657 { 0x2000, 0x682000 }, 658 { 0x2004, 0x682004 }, 659 { 0x2008, 0x682008 }, 660 { 0x200c, 0x68200c }, 661 { 0x2014, 0x682014 }, 662 { 0x2018, 0x682018 }, 663 { 0x201c, 0x68201c }, 664 { 0x2020, 0x682020 }, 665 { 0x2028, 0x682028 }, 666 { 0x202c, 0x68202c }, 667 { 0x2030, 0x682030 }, 668 { 0x2038, 0x682038 }, 669 { 0x203c, 0x68203c }, 670 { 0x2048, 0x682048 }, 671 { 0x204c, 0x68204c }, 672 { 0x2050, 0x682050 }, 673 { 0x2054, 0x682054 }, 674 { 0x2058, 0x682058 }, 675 { 0x205c, 0x68205c }, 676 { 0x2060, 0x682060 }, 677 { 0x2064, 0x682064 }, 678 { 0x2068, 0x682068 }, 679 { 0x206c, 0x68206c }, 680 { 0x2070, 0x682070 }, 681 { 0x2074, 0x682074 }, 682 { 0x2078, 0x682078 }, 683 { 0x207c, 0x68207c }, 684 { 0x2080, 0x682080 }, 685 { 0x2088, 0x682088 }, 686 { 0x2090, 0x682090 }, 687 { 0x209c, 0x68209c }, 688 { 0x20a0, 0x6820a0 }, 689 { 0x20a4, 0x6820a4 }, 690 { 0x20a8, 0x6820a8 }, 691 { 0x20ac, 0x6820ac }, 692 { 0x2180, 0x682180 }, 693 { 0x2184, 0x682184 }, 694 { 0x218c, 0x68218c }, 695 { 0x2194, 0x682194 }, 696 { 0x2198, 0x682198 }, 697 { 0x219c, 0x68219c }, 698 { 0x21a0, 0x6821a0 }, 699 { 0x21a4, 0x6821a4 }, 700 { 0x2214, 0x682214 }, 701 { 0x2218, 0x682218 }, 702 {} 703 } 704 }; 705 706 static const struct nvkm_disp_chan_mthd 707 gv100_disp_core_mthd = { 708 .name = "Core", 709 .addr = 0x000000, 710 .prev = 0x008000, 711 .data = { 712 { "Global", 1, &gv100_disp_core_mthd_base }, 713 { "SOR", 4, &gv100_disp_core_mthd_sor }, 714 { "WINDOW", 8, &gv100_disp_core_mthd_wndw }, 715 { "HEAD", 4, &gv100_disp_core_mthd_head }, 716 {} 717 } 718 }; 719 720 static int 721 gv100_disp_core_idle(struct nvkm_disp_chan *chan) 722 { 723 struct nvkm_device *device = chan->disp->engine.subdev.device; 724 nvkm_msec(device, 2000, 725 u32 stat = nvkm_rd32(device, 0x610630); 726 if ((stat & 0x001f0000) == 0x000b0000) 727 return 0; 728 ); 729 return -EBUSY; 730 } 731 732 static u64 733 gv100_disp_core_user(struct nvkm_disp_chan *chan, u64 *psize) 734 { 735 *psize = 0x10000; 736 return 0x680000; 737 } 738 739 static void 740 gv100_disp_core_intr(struct nvkm_disp_chan *chan, bool en) 741 { 742 struct nvkm_device *device = chan->disp->engine.subdev.device; 743 const u32 mask = 0x00000001; 744 const u32 data = en ? mask : 0; 745 nvkm_mask(device, 0x611dac, mask, data); 746 } 747 748 static void 749 gv100_disp_core_fini(struct nvkm_disp_chan *chan) 750 { 751 struct nvkm_device *device = chan->disp->engine.subdev.device; 752 nvkm_mask(device, 0x6104e0, 0x00000010, 0x00000000); 753 gv100_disp_core_idle(chan); 754 nvkm_mask(device, 0x6104e0, 0x00000002, 0x00000000); 755 chan->suspend_put = nvkm_rd32(device, 0x680000); 756 } 757 758 static int 759 gv100_disp_core_init(struct nvkm_disp_chan *chan) 760 { 761 struct nvkm_subdev *subdev = &chan->disp->engine.subdev; 762 struct nvkm_device *device = subdev->device; 763 764 nvkm_wr32(device, 0x610b24, lower_32_bits(chan->push)); 765 nvkm_wr32(device, 0x610b20, upper_32_bits(chan->push)); 766 nvkm_wr32(device, 0x610b28, 0x00000001); 767 nvkm_wr32(device, 0x610b2c, 0x00000040); 768 769 nvkm_mask(device, 0x6104e0, 0x00000010, 0x00000010); 770 nvkm_wr32(device, 0x680000, chan->suspend_put); 771 nvkm_wr32(device, 0x6104e0, 0x00000013); 772 return gv100_disp_core_idle(chan); 773 } 774 775 static const struct nvkm_disp_chan_func 776 gv100_disp_core_func = { 777 .push = nv50_disp_dmac_push, 778 .init = gv100_disp_core_init, 779 .fini = gv100_disp_core_fini, 780 .intr = gv100_disp_core_intr, 781 .user = gv100_disp_core_user, 782 .bind = gv100_disp_dmac_bind, 783 }; 784 785 const struct nvkm_disp_chan_user 786 gv100_disp_core = { 787 .func = &gv100_disp_core_func, 788 .ctrl = 0, 789 .user = 0, 790 .mthd = &gv100_disp_core_mthd, 791 }; 792 793 #define gv100_disp_caps(p) container_of((p), struct gv100_disp_caps, object) 794 795 struct gv100_disp_caps { 796 struct nvkm_object object; 797 struct nvkm_disp *disp; 798 }; 799 800 static int 801 gv100_disp_caps_map(struct nvkm_object *object, void *argv, u32 argc, 802 enum nvkm_object_map *type, u64 *addr, u64 *size) 803 { 804 struct gv100_disp_caps *caps = gv100_disp_caps(object); 805 struct nvkm_device *device = caps->disp->engine.subdev.device; 806 *type = NVKM_OBJECT_MAP_IO; 807 *addr = 0x640000 + device->func->resource_addr(device, 0); 808 *size = 0x1000; 809 return 0; 810 } 811 812 static const struct nvkm_object_func 813 gv100_disp_caps = { 814 .map = gv100_disp_caps_map, 815 }; 816 817 int 818 gv100_disp_caps_new(const struct nvkm_oclass *oclass, void *argv, u32 argc, 819 struct nvkm_object **pobject) 820 { 821 struct nvkm_disp *disp = nvkm_udisp(oclass->parent); 822 struct gv100_disp_caps *caps; 823 824 if (!(caps = kzalloc(sizeof(*caps), GFP_KERNEL))) 825 return -ENOMEM; 826 *pobject = &caps->object; 827 828 nvkm_object_ctor(&gv100_disp_caps, oclass, &caps->object); 829 caps->disp = disp; 830 return 0; 831 } 832 833 void 834 gv100_disp_super(struct work_struct *work) 835 { 836 struct nvkm_disp *disp = container_of(work, struct nvkm_disp, super.work); 837 struct nvkm_subdev *subdev = &disp->engine.subdev; 838 struct nvkm_device *device = subdev->device; 839 struct nvkm_head *head; 840 u32 stat, mask[4]; 841 842 mutex_lock(&disp->super.mutex); 843 stat = nvkm_rd32(device, 0x6107a8); 844 845 nvkm_debug(subdev, "supervisor %d: %08x\n", ffs(disp->super.pending), stat); 846 list_for_each_entry(head, &disp->heads, head) { 847 mask[head->id] = nvkm_rd32(device, 0x6107ac + (head->id * 4)); 848 HEAD_DBG(head, "%08x", mask[head->id]); 849 } 850 851 if (disp->super.pending & 0x00000001) { 852 nv50_disp_chan_mthd(disp->chan[0], NV_DBG_DEBUG); 853 nv50_disp_super_1(disp); 854 list_for_each_entry(head, &disp->heads, head) { 855 if (!(mask[head->id] & 0x00001000)) 856 continue; 857 nv50_disp_super_1_0(disp, head); 858 } 859 } else 860 if (disp->super.pending & 0x00000002) { 861 list_for_each_entry(head, &disp->heads, head) { 862 if (!(mask[head->id] & 0x00001000)) 863 continue; 864 nv50_disp_super_2_0(disp, head); 865 } 866 list_for_each_entry(head, &disp->heads, head) { 867 if (!(mask[head->id] & 0x00010000)) 868 continue; 869 nv50_disp_super_2_1(disp, head); 870 } 871 list_for_each_entry(head, &disp->heads, head) { 872 if (!(mask[head->id] & 0x00001000)) 873 continue; 874 nv50_disp_super_2_2(disp, head); 875 } 876 } else 877 if (disp->super.pending & 0x00000004) { 878 list_for_each_entry(head, &disp->heads, head) { 879 if (!(mask[head->id] & 0x00001000)) 880 continue; 881 nv50_disp_super_3_0(disp, head); 882 } 883 } 884 885 list_for_each_entry(head, &disp->heads, head) 886 nvkm_wr32(device, 0x6107ac + (head->id * 4), 0x00000000); 887 888 nvkm_wr32(device, 0x6107a8, 0x80000000); 889 mutex_unlock(&disp->super.mutex); 890 } 891 892 static void 893 gv100_disp_exception(struct nvkm_disp *disp, int chid) 894 { 895 struct nvkm_subdev *subdev = &disp->engine.subdev; 896 struct nvkm_device *device = subdev->device; 897 u32 stat = nvkm_rd32(device, 0x611020 + (chid * 12)); 898 u32 type = (stat & 0x00007000) >> 12; 899 u32 mthd = (stat & 0x00000fff) << 2; 900 const struct nvkm_enum *reason = 901 nvkm_enum_find(nv50_disp_intr_error_type, type); 902 903 /*TODO: Suspect 33->41 are for WRBK channel exceptions, but we 904 * don't support those currently. 905 * 906 * CORE+WIN CHIDs map directly to the FE_EXCEPT() slots. 907 */ 908 if (chid <= 32) { 909 u32 data = nvkm_rd32(device, 0x611024 + (chid * 12)); 910 u32 code = nvkm_rd32(device, 0x611028 + (chid * 12)); 911 nvkm_error(subdev, "chid %d stat %08x reason %d [%s] " 912 "mthd %04x data %08x code %08x\n", 913 chid, stat, type, reason ? reason->name : "", 914 mthd, data, code); 915 } else { 916 nvkm_error(subdev, "chid %d stat %08x reason %d [%s] " 917 "mthd %04x\n", 918 chid, stat, type, reason ? reason->name : "", mthd); 919 } 920 921 if (chid < ARRAY_SIZE(disp->chan) && disp->chan[chid]) { 922 switch (mthd) { 923 case 0x0200: 924 nv50_disp_chan_mthd(disp->chan[chid], NV_DBG_ERROR); 925 break; 926 default: 927 break; 928 } 929 } 930 931 nvkm_wr32(device, 0x611020 + (chid * 12), 0x90000000); 932 } 933 934 static void 935 gv100_disp_intr_ctrl_disp(struct nvkm_disp *disp) 936 { 937 struct nvkm_subdev *subdev = &disp->engine.subdev; 938 struct nvkm_device *device = subdev->device; 939 u32 stat = nvkm_rd32(device, 0x611c30); 940 941 if (stat & 0x00000007) { 942 disp->super.pending = (stat & 0x00000007); 943 queue_work(disp->super.wq, &disp->super.work); 944 nvkm_wr32(device, 0x611860, disp->super.pending); 945 stat &= ~0x00000007; 946 } 947 948 /*TODO: I would guess this is VBIOS_RELEASE, however, NFI how to 949 * ACK it, nor does RM appear to bother. 950 */ 951 if (stat & 0x00000008) 952 stat &= ~0x00000008; 953 954 if (stat & 0x00000080) { 955 u32 error = nvkm_mask(device, 0x611848, 0x00000000, 0x00000000); 956 nvkm_warn(subdev, "error %08x\n", error); 957 stat &= ~0x00000080; 958 } 959 960 if (stat & 0x00000100) { 961 unsigned long wndws = nvkm_rd32(device, 0x611858); 962 unsigned long other = nvkm_rd32(device, 0x61185c); 963 int wndw; 964 965 nvkm_wr32(device, 0x611858, wndws); 966 nvkm_wr32(device, 0x61185c, other); 967 968 /* AWAKEN_OTHER_CORE. */ 969 if (other & 0x00000001) 970 nv50_disp_chan_uevent_send(disp, 0); 971 972 /* AWAKEN_WIN_CH(n). */ 973 for_each_set_bit(wndw, &wndws, disp->wndw.nr) { 974 nv50_disp_chan_uevent_send(disp, 1 + wndw); 975 } 976 } 977 978 if (stat) 979 nvkm_warn(subdev, "ctrl %08x\n", stat); 980 } 981 982 static void 983 gv100_disp_intr_exc_other(struct nvkm_disp *disp) 984 { 985 struct nvkm_subdev *subdev = &disp->engine.subdev; 986 struct nvkm_device *device = subdev->device; 987 u32 stat = nvkm_rd32(device, 0x611854); 988 unsigned long mask; 989 int head; 990 991 if (stat & 0x00000001) { 992 nvkm_wr32(device, 0x611854, 0x00000001); 993 gv100_disp_exception(disp, 0); 994 stat &= ~0x00000001; 995 } 996 997 if ((mask = (stat & 0x00ff0000) >> 16)) { 998 for_each_set_bit(head, &mask, disp->wndw.nr) { 999 nvkm_wr32(device, 0x611854, 0x00010000 << head); 1000 gv100_disp_exception(disp, 73 + head); 1001 stat &= ~(0x00010000 << head); 1002 } 1003 } 1004 1005 if (stat) { 1006 nvkm_warn(subdev, "exception %08x\n", stat); 1007 nvkm_wr32(device, 0x611854, stat); 1008 } 1009 } 1010 1011 static void 1012 gv100_disp_intr_exc_winim(struct nvkm_disp *disp) 1013 { 1014 struct nvkm_subdev *subdev = &disp->engine.subdev; 1015 struct nvkm_device *device = subdev->device; 1016 unsigned long stat = nvkm_rd32(device, 0x611850); 1017 int wndw; 1018 1019 for_each_set_bit(wndw, &stat, disp->wndw.nr) { 1020 nvkm_wr32(device, 0x611850, BIT(wndw)); 1021 gv100_disp_exception(disp, 33 + wndw); 1022 stat &= ~BIT(wndw); 1023 } 1024 1025 if (stat) { 1026 nvkm_warn(subdev, "wimm %08x\n", (u32)stat); 1027 nvkm_wr32(device, 0x611850, stat); 1028 } 1029 } 1030 1031 static void 1032 gv100_disp_intr_exc_win(struct nvkm_disp *disp) 1033 { 1034 struct nvkm_subdev *subdev = &disp->engine.subdev; 1035 struct nvkm_device *device = subdev->device; 1036 unsigned long stat = nvkm_rd32(device, 0x61184c); 1037 int wndw; 1038 1039 for_each_set_bit(wndw, &stat, disp->wndw.nr) { 1040 nvkm_wr32(device, 0x61184c, BIT(wndw)); 1041 gv100_disp_exception(disp, 1 + wndw); 1042 stat &= ~BIT(wndw); 1043 } 1044 1045 if (stat) { 1046 nvkm_warn(subdev, "wndw %08x\n", (u32)stat); 1047 nvkm_wr32(device, 0x61184c, stat); 1048 } 1049 } 1050 1051 static void 1052 gv100_disp_intr_head_timing(struct nvkm_disp *disp, int head) 1053 { 1054 struct nvkm_subdev *subdev = &disp->engine.subdev; 1055 struct nvkm_device *device = subdev->device; 1056 u32 stat = nvkm_rd32(device, 0x611800 + (head * 0x04)); 1057 1058 /* LAST_DATA, LOADV. */ 1059 if (stat & 0x00000003) { 1060 nvkm_wr32(device, 0x611800 + (head * 0x04), stat & 0x00000003); 1061 stat &= ~0x00000003; 1062 } 1063 1064 if (stat & 0x00000004) { 1065 nvkm_disp_vblank(disp, head); 1066 nvkm_wr32(device, 0x611800 + (head * 0x04), 0x00000004); 1067 stat &= ~0x00000004; 1068 } 1069 1070 if (stat) { 1071 nvkm_warn(subdev, "head %08x\n", stat); 1072 nvkm_wr32(device, 0x611800 + (head * 0x04), stat); 1073 } 1074 } 1075 1076 void 1077 gv100_disp_intr(struct nvkm_disp *disp) 1078 { 1079 struct nvkm_subdev *subdev = &disp->engine.subdev; 1080 struct nvkm_device *device = subdev->device; 1081 u32 stat = nvkm_rd32(device, 0x611ec0); 1082 unsigned long mask; 1083 int head; 1084 1085 if ((mask = (stat & 0x000000ff))) { 1086 for_each_set_bit(head, &mask, 8) { 1087 gv100_disp_intr_head_timing(disp, head); 1088 stat &= ~BIT(head); 1089 } 1090 } 1091 1092 if (stat & 0x00000200) { 1093 gv100_disp_intr_exc_win(disp); 1094 stat &= ~0x00000200; 1095 } 1096 1097 if (stat & 0x00000400) { 1098 gv100_disp_intr_exc_winim(disp); 1099 stat &= ~0x00000400; 1100 } 1101 1102 if (stat & 0x00000800) { 1103 gv100_disp_intr_exc_other(disp); 1104 stat &= ~0x00000800; 1105 } 1106 1107 if (stat & 0x00001000) { 1108 gv100_disp_intr_ctrl_disp(disp); 1109 stat &= ~0x00001000; 1110 } 1111 1112 if (stat) 1113 nvkm_warn(subdev, "intr %08x\n", stat); 1114 } 1115 1116 void 1117 gv100_disp_fini(struct nvkm_disp *disp) 1118 { 1119 struct nvkm_device *device = disp->engine.subdev.device; 1120 nvkm_wr32(device, 0x611db0, 0x00000000); 1121 } 1122 1123 static int 1124 gv100_disp_init(struct nvkm_disp *disp) 1125 { 1126 struct nvkm_device *device = disp->engine.subdev.device; 1127 struct nvkm_head *head; 1128 int i, j; 1129 u32 tmp; 1130 1131 /* Claim ownership of display. */ 1132 if (nvkm_rd32(device, 0x6254e8) & 0x00000002) { 1133 nvkm_mask(device, 0x6254e8, 0x00000001, 0x00000000); 1134 if (nvkm_msec(device, 2000, 1135 if (!(nvkm_rd32(device, 0x6254e8) & 0x00000002)) 1136 break; 1137 ) < 0) 1138 return -EBUSY; 1139 } 1140 1141 /* Lock pin capabilities. */ 1142 tmp = nvkm_rd32(device, 0x610068); 1143 nvkm_wr32(device, 0x640008, tmp); 1144 1145 /* SOR capabilities. */ 1146 for (i = 0; i < disp->sor.nr; i++) { 1147 tmp = nvkm_rd32(device, 0x61c000 + (i * 0x800)); 1148 nvkm_mask(device, 0x640000, 0x00000100 << i, 0x00000100 << i); 1149 nvkm_wr32(device, 0x640144 + (i * 0x08), tmp); 1150 } 1151 1152 /* Head capabilities. */ 1153 list_for_each_entry(head, &disp->heads, head) { 1154 const int id = head->id; 1155 1156 /* RG. */ 1157 tmp = nvkm_rd32(device, 0x616300 + (id * 0x800)); 1158 nvkm_wr32(device, 0x640048 + (id * 0x020), tmp); 1159 1160 /* POSTCOMP. */ 1161 for (j = 0; j < 6 * 4; j += 4) { 1162 tmp = nvkm_rd32(device, 0x616100 + (id * 0x800) + j); 1163 nvkm_wr32(device, 0x640030 + (id * 0x20) + j, tmp); 1164 } 1165 } 1166 1167 /* Window capabilities. */ 1168 for (i = 0; i < disp->wndw.nr; i++) { 1169 nvkm_mask(device, 0x640004, 1 << i, 1 << i); 1170 for (j = 0; j < 6 * 4; j += 4) { 1171 tmp = nvkm_rd32(device, 0x630050 + (i * 0x800) + j); 1172 nvkm_wr32(device, 0x6401e4 + (i * 0x20) + j, tmp); 1173 } 1174 } 1175 1176 /* IHUB capabilities. */ 1177 for (i = 0; i < 4; i++) { 1178 tmp = nvkm_rd32(device, 0x62e000 + (i * 0x04)); 1179 nvkm_wr32(device, 0x640010 + (i * 0x04), tmp); 1180 } 1181 1182 nvkm_mask(device, 0x610078, 0x00000001, 0x00000001); 1183 1184 /* Setup instance memory. */ 1185 switch (nvkm_memory_target(disp->inst->memory)) { 1186 case NVKM_MEM_TARGET_VRAM: tmp = 0x00000001; break; 1187 case NVKM_MEM_TARGET_NCOH: tmp = 0x00000002; break; 1188 case NVKM_MEM_TARGET_HOST: tmp = 0x00000003; break; 1189 default: 1190 break; 1191 } 1192 nvkm_wr32(device, 0x610010, 0x00000008 | tmp); 1193 nvkm_wr32(device, 0x610014, disp->inst->addr >> 16); 1194 1195 /* CTRL_DISP: AWAKEN, ERROR, SUPERVISOR[1-3]. */ 1196 nvkm_wr32(device, 0x611cf0, 0x00000187); /* MSK. */ 1197 nvkm_wr32(device, 0x611db0, 0x00000187); /* EN. */ 1198 1199 /* EXC_OTHER: CURSn, CORE. */ 1200 nvkm_wr32(device, 0x611cec, disp->head.mask << 16 | 1201 0x00000001); /* MSK. */ 1202 nvkm_wr32(device, 0x611dac, 0x00000000); /* EN. */ 1203 1204 /* EXC_WINIM. */ 1205 nvkm_wr32(device, 0x611ce8, disp->wndw.mask); /* MSK. */ 1206 nvkm_wr32(device, 0x611da8, 0x00000000); /* EN. */ 1207 1208 /* EXC_WIN. */ 1209 nvkm_wr32(device, 0x611ce4, disp->wndw.mask); /* MSK. */ 1210 nvkm_wr32(device, 0x611da4, 0x00000000); /* EN. */ 1211 1212 /* HEAD_TIMING(n): VBLANK. */ 1213 list_for_each_entry(head, &disp->heads, head) { 1214 const u32 hoff = head->id * 4; 1215 nvkm_wr32(device, 0x611cc0 + hoff, 0x00000004); /* MSK. */ 1216 nvkm_wr32(device, 0x611d80 + hoff, 0x00000000); /* EN. */ 1217 } 1218 1219 /* OR. */ 1220 nvkm_wr32(device, 0x611cf4, 0x00000000); /* MSK. */ 1221 nvkm_wr32(device, 0x611db4, 0x00000000); /* EN. */ 1222 return 0; 1223 } 1224 1225 static const struct nvkm_disp_func 1226 gv100_disp = { 1227 .oneinit = nv50_disp_oneinit, 1228 .init = gv100_disp_init, 1229 .fini = gv100_disp_fini, 1230 .intr = gv100_disp_intr, 1231 .super = gv100_disp_super, 1232 .uevent = &gv100_disp_chan_uevent, 1233 .wndw = { .cnt = gv100_disp_wndw_cnt }, 1234 .head = { .cnt = gv100_head_cnt, .new = gv100_head_new }, 1235 .sor = { .cnt = gv100_sor_cnt, .new = gv100_sor_new }, 1236 .ramht_size = 0x2000, 1237 .root = { 0, 0,GV100_DISP }, 1238 .user = { 1239 {{-1,-1,GV100_DISP_CAPS }, gv100_disp_caps_new }, 1240 {{ 0, 0,GV100_DISP_CURSOR }, nvkm_disp_chan_new, &gv100_disp_curs }, 1241 {{ 0, 0,GV100_DISP_WINDOW_IMM_CHANNEL_DMA}, nvkm_disp_wndw_new, &gv100_disp_wimm }, 1242 {{ 0, 0,GV100_DISP_CORE_CHANNEL_DMA }, nvkm_disp_core_new, &gv100_disp_core }, 1243 {{ 0, 0,GV100_DISP_WINDOW_CHANNEL_DMA }, nvkm_disp_wndw_new, &gv100_disp_wndw }, 1244 {} 1245 }, 1246 }; 1247 1248 int 1249 gv100_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, 1250 struct nvkm_disp **pdisp) 1251 { 1252 return nvkm_disp_new_(&gv100_disp, device, type, inst, pdisp); 1253 } 1254