2 * Copyright 2012 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 <core/object.h>
26 #include <core/parent.h>
27 #include <core/handle.h>
28 #include <core/class.h>
30 #include <engine/software.h>
31 #include <engine/disp.h>
33 #include <subdev/timer.h>
34 #include <subdev/fb.h>
35 #include <subdev/bar.h>
39 /*******************************************************************************
40 * EVO channel base class
41 ******************************************************************************/
44 nv50_disp_chan_create_(struct nouveau_object *parent,
45 struct nouveau_object *engine,
46 struct nouveau_oclass *oclass, int chid,
47 int length, void **pobject)
49 struct nv50_disp_base *base = (void *)parent;
50 struct nv50_disp_chan *chan;
53 if (base->chan & (1 << chid))
55 base->chan |= (1 << chid);
57 ret = nouveau_namedb_create_(parent, engine, oclass, 0, NULL,
58 (1ULL << NVDEV_ENGINE_DMAOBJ),
69 nv50_disp_chan_destroy(struct nv50_disp_chan *chan)
71 struct nv50_disp_base *base = (void *)nv_object(chan)->parent;
72 base->chan &= ~(1 << chan->chid);
73 nouveau_namedb_destroy(&chan->base);
77 nv50_disp_chan_rd32(struct nouveau_object *object, u64 addr)
79 struct nv50_disp_priv *priv = (void *)object->engine;
80 struct nv50_disp_chan *chan = (void *)object;
81 return nv_rd32(priv, 0x640000 + (chan->chid * 0x1000) + addr);
85 nv50_disp_chan_wr32(struct nouveau_object *object, u64 addr, u32 data)
87 struct nv50_disp_priv *priv = (void *)object->engine;
88 struct nv50_disp_chan *chan = (void *)object;
89 nv_wr32(priv, 0x640000 + (chan->chid * 0x1000) + addr, data);
92 /*******************************************************************************
93 * EVO DMA channel base class
94 ******************************************************************************/
97 nv50_disp_dmac_object_attach(struct nouveau_object *parent,
98 struct nouveau_object *object, u32 name)
100 struct nv50_disp_base *base = (void *)parent->parent;
101 struct nv50_disp_chan *chan = (void *)parent;
102 u32 addr = nv_gpuobj(object)->node->offset;
103 u32 chid = chan->chid;
104 u32 data = (chid << 28) | (addr << 10) | chid;
105 return nouveau_ramht_insert(base->ramht, chid, name, data);
109 nv50_disp_dmac_object_detach(struct nouveau_object *parent, int cookie)
111 struct nv50_disp_base *base = (void *)parent->parent;
112 nouveau_ramht_remove(base->ramht, cookie);
116 nv50_disp_dmac_create_(struct nouveau_object *parent,
117 struct nouveau_object *engine,
118 struct nouveau_oclass *oclass, u32 pushbuf, int chid,
119 int length, void **pobject)
121 struct nv50_disp_dmac *dmac;
124 ret = nv50_disp_chan_create_(parent, engine, oclass, chid,
130 dmac->pushdma = (void *)nouveau_handle_ref(parent, pushbuf);
134 switch (nv_mclass(dmac->pushdma)) {
137 if (dmac->pushdma->limit - dmac->pushdma->start != 0xfff)
140 switch (dmac->pushdma->target) {
141 case NV_MEM_TARGET_VRAM:
142 dmac->push = 0x00000000 | dmac->pushdma->start >> 8;
144 case NV_MEM_TARGET_PCI_NOSNOOP:
145 dmac->push = 0x00000003 | dmac->pushdma->start >> 8;
159 nv50_disp_dmac_dtor(struct nouveau_object *object)
161 struct nv50_disp_dmac *dmac = (void *)object;
162 nouveau_object_ref(NULL, (struct nouveau_object **)&dmac->pushdma);
163 nv50_disp_chan_destroy(&dmac->base);
167 nv50_disp_dmac_init(struct nouveau_object *object)
169 struct nv50_disp_priv *priv = (void *)object->engine;
170 struct nv50_disp_dmac *dmac = (void *)object;
171 int chid = dmac->base.chid;
174 ret = nv50_disp_chan_init(&dmac->base);
178 /* enable error reporting */
179 nv_mask(priv, 0x610028, 0x00010001 << chid, 0x00010001 << chid);
181 /* initialise channel for dma command submission */
182 nv_wr32(priv, 0x610204 + (chid * 0x0010), dmac->push);
183 nv_wr32(priv, 0x610208 + (chid * 0x0010), 0x00010000);
184 nv_wr32(priv, 0x61020c + (chid * 0x0010), chid);
185 nv_mask(priv, 0x610200 + (chid * 0x0010), 0x00000010, 0x00000010);
186 nv_wr32(priv, 0x640000 + (chid * 0x1000), 0x00000000);
187 nv_wr32(priv, 0x610200 + (chid * 0x0010), 0x00000013);
189 /* wait for it to go inactive */
190 if (!nv_wait(priv, 0x610200 + (chid * 0x10), 0x80000000, 0x00000000)) {
191 nv_error(dmac, "init timeout, 0x%08x\n",
192 nv_rd32(priv, 0x610200 + (chid * 0x10)));
200 nv50_disp_dmac_fini(struct nouveau_object *object, bool suspend)
202 struct nv50_disp_priv *priv = (void *)object->engine;
203 struct nv50_disp_dmac *dmac = (void *)object;
204 int chid = dmac->base.chid;
206 /* deactivate channel */
207 nv_mask(priv, 0x610200 + (chid * 0x0010), 0x00001010, 0x00001000);
208 nv_mask(priv, 0x610200 + (chid * 0x0010), 0x00000003, 0x00000000);
209 if (!nv_wait(priv, 0x610200 + (chid * 0x10), 0x001e0000, 0x00000000)) {
210 nv_error(dmac, "fini timeout, 0x%08x\n",
211 nv_rd32(priv, 0x610200 + (chid * 0x10)));
216 /* disable error reporting */
217 nv_mask(priv, 0x610028, 0x00010001 << chid, 0x00000000 << chid);
219 return nv50_disp_chan_fini(&dmac->base, suspend);
222 /*******************************************************************************
223 * EVO master channel object
224 ******************************************************************************/
227 nv50_disp_mast_ctor(struct nouveau_object *parent,
228 struct nouveau_object *engine,
229 struct nouveau_oclass *oclass, void *data, u32 size,
230 struct nouveau_object **pobject)
232 struct nv50_display_mast_class *args = data;
233 struct nv50_disp_dmac *mast;
236 if (size < sizeof(*args))
239 ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
240 0, sizeof(*mast), (void **)&mast);
241 *pobject = nv_object(mast);
245 nv_parent(mast)->object_attach = nv50_disp_dmac_object_attach;
246 nv_parent(mast)->object_detach = nv50_disp_dmac_object_detach;
251 nv50_disp_mast_init(struct nouveau_object *object)
253 struct nv50_disp_priv *priv = (void *)object->engine;
254 struct nv50_disp_dmac *mast = (void *)object;
257 ret = nv50_disp_chan_init(&mast->base);
261 /* enable error reporting */
262 nv_mask(priv, 0x610028, 0x00010001, 0x00010001);
264 /* attempt to unstick channel from some unknown state */
265 if ((nv_rd32(priv, 0x610200) & 0x009f0000) == 0x00020000)
266 nv_mask(priv, 0x610200, 0x00800000, 0x00800000);
267 if ((nv_rd32(priv, 0x610200) & 0x003f0000) == 0x00030000)
268 nv_mask(priv, 0x610200, 0x00600000, 0x00600000);
270 /* initialise channel for dma command submission */
271 nv_wr32(priv, 0x610204, mast->push);
272 nv_wr32(priv, 0x610208, 0x00010000);
273 nv_wr32(priv, 0x61020c, 0x00000000);
274 nv_mask(priv, 0x610200, 0x00000010, 0x00000010);
275 nv_wr32(priv, 0x640000, 0x00000000);
276 nv_wr32(priv, 0x610200, 0x01000013);
278 /* wait for it to go inactive */
279 if (!nv_wait(priv, 0x610200, 0x80000000, 0x00000000)) {
280 nv_error(mast, "init: 0x%08x\n", nv_rd32(priv, 0x610200));
288 nv50_disp_mast_fini(struct nouveau_object *object, bool suspend)
290 struct nv50_disp_priv *priv = (void *)object->engine;
291 struct nv50_disp_dmac *mast = (void *)object;
293 /* deactivate channel */
294 nv_mask(priv, 0x610200, 0x00000010, 0x00000000);
295 nv_mask(priv, 0x610200, 0x00000003, 0x00000000);
296 if (!nv_wait(priv, 0x610200, 0x001e0000, 0x00000000)) {
297 nv_error(mast, "fini: 0x%08x\n", nv_rd32(priv, 0x610200));
302 /* disable error reporting */
303 nv_mask(priv, 0x610028, 0x00010001, 0x00000000);
305 return nv50_disp_chan_fini(&mast->base, suspend);
308 struct nouveau_ofuncs
309 nv50_disp_mast_ofuncs = {
310 .ctor = nv50_disp_mast_ctor,
311 .dtor = nv50_disp_dmac_dtor,
312 .init = nv50_disp_mast_init,
313 .fini = nv50_disp_mast_fini,
314 .rd32 = nv50_disp_chan_rd32,
315 .wr32 = nv50_disp_chan_wr32,
318 /*******************************************************************************
319 * EVO sync channel objects
320 ******************************************************************************/
323 nv50_disp_sync_ctor(struct nouveau_object *parent,
324 struct nouveau_object *engine,
325 struct nouveau_oclass *oclass, void *data, u32 size,
326 struct nouveau_object **pobject)
328 struct nv50_display_sync_class *args = data;
329 struct nv50_disp_dmac *dmac;
332 if (size < sizeof(*data) || args->head > 1)
335 ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
336 1 + args->head, sizeof(*dmac),
338 *pobject = nv_object(dmac);
342 nv_parent(dmac)->object_attach = nv50_disp_dmac_object_attach;
343 nv_parent(dmac)->object_detach = nv50_disp_dmac_object_detach;
347 struct nouveau_ofuncs
348 nv50_disp_sync_ofuncs = {
349 .ctor = nv50_disp_sync_ctor,
350 .dtor = nv50_disp_dmac_dtor,
351 .init = nv50_disp_dmac_init,
352 .fini = nv50_disp_dmac_fini,
353 .rd32 = nv50_disp_chan_rd32,
354 .wr32 = nv50_disp_chan_wr32,
357 /*******************************************************************************
358 * EVO overlay channel objects
359 ******************************************************************************/
362 nv50_disp_ovly_ctor(struct nouveau_object *parent,
363 struct nouveau_object *engine,
364 struct nouveau_oclass *oclass, void *data, u32 size,
365 struct nouveau_object **pobject)
367 struct nv50_display_ovly_class *args = data;
368 struct nv50_disp_dmac *dmac;
371 if (size < sizeof(*data) || args->head > 1)
374 ret = nv50_disp_dmac_create_(parent, engine, oclass, args->pushbuf,
375 3 + args->head, sizeof(*dmac),
377 *pobject = nv_object(dmac);
381 nv_parent(dmac)->object_attach = nv50_disp_dmac_object_attach;
382 nv_parent(dmac)->object_detach = nv50_disp_dmac_object_detach;
386 struct nouveau_ofuncs
387 nv50_disp_ovly_ofuncs = {
388 .ctor = nv50_disp_ovly_ctor,
389 .dtor = nv50_disp_dmac_dtor,
390 .init = nv50_disp_dmac_init,
391 .fini = nv50_disp_dmac_fini,
392 .rd32 = nv50_disp_chan_rd32,
393 .wr32 = nv50_disp_chan_wr32,
396 /*******************************************************************************
397 * EVO PIO channel base class
398 ******************************************************************************/
401 nv50_disp_pioc_create_(struct nouveau_object *parent,
402 struct nouveau_object *engine,
403 struct nouveau_oclass *oclass, int chid,
404 int length, void **pobject)
406 return nv50_disp_chan_create_(parent, engine, oclass, chid,
411 nv50_disp_pioc_dtor(struct nouveau_object *object)
413 struct nv50_disp_pioc *pioc = (void *)object;
414 nv50_disp_chan_destroy(&pioc->base);
418 nv50_disp_pioc_init(struct nouveau_object *object)
420 struct nv50_disp_priv *priv = (void *)object->engine;
421 struct nv50_disp_pioc *pioc = (void *)object;
422 int chid = pioc->base.chid;
425 ret = nv50_disp_chan_init(&pioc->base);
429 nv_wr32(priv, 0x610200 + (chid * 0x10), 0x00002000);
430 if (!nv_wait(priv, 0x610200 + (chid * 0x10), 0x00000000, 0x00000000)) {
431 nv_error(pioc, "timeout0: 0x%08x\n",
432 nv_rd32(priv, 0x610200 + (chid * 0x10)));
436 nv_wr32(priv, 0x610200 + (chid * 0x10), 0x00000001);
437 if (!nv_wait(priv, 0x610200 + (chid * 0x10), 0x00030000, 0x00010000)) {
438 nv_error(pioc, "timeout1: 0x%08x\n",
439 nv_rd32(priv, 0x610200 + (chid * 0x10)));
447 nv50_disp_pioc_fini(struct nouveau_object *object, bool suspend)
449 struct nv50_disp_priv *priv = (void *)object->engine;
450 struct nv50_disp_pioc *pioc = (void *)object;
451 int chid = pioc->base.chid;
453 nv_mask(priv, 0x610200 + (chid * 0x10), 0x00000001, 0x00000000);
454 if (!nv_wait(priv, 0x610200 + (chid * 0x10), 0x00030000, 0x00000000)) {
455 nv_error(pioc, "timeout: 0x%08x\n",
456 nv_rd32(priv, 0x610200 + (chid * 0x10)));
461 return nv50_disp_chan_fini(&pioc->base, suspend);
464 /*******************************************************************************
465 * EVO immediate overlay channel objects
466 ******************************************************************************/
469 nv50_disp_oimm_ctor(struct nouveau_object *parent,
470 struct nouveau_object *engine,
471 struct nouveau_oclass *oclass, void *data, u32 size,
472 struct nouveau_object **pobject)
474 struct nv50_display_oimm_class *args = data;
475 struct nv50_disp_pioc *pioc;
478 if (size < sizeof(*args) || args->head > 1)
481 ret = nv50_disp_pioc_create_(parent, engine, oclass, 5 + args->head,
482 sizeof(*pioc), (void **)&pioc);
483 *pobject = nv_object(pioc);
490 struct nouveau_ofuncs
491 nv50_disp_oimm_ofuncs = {
492 .ctor = nv50_disp_oimm_ctor,
493 .dtor = nv50_disp_pioc_dtor,
494 .init = nv50_disp_pioc_init,
495 .fini = nv50_disp_pioc_fini,
496 .rd32 = nv50_disp_chan_rd32,
497 .wr32 = nv50_disp_chan_wr32,
500 /*******************************************************************************
501 * EVO cursor channel objects
502 ******************************************************************************/
505 nv50_disp_curs_ctor(struct nouveau_object *parent,
506 struct nouveau_object *engine,
507 struct nouveau_oclass *oclass, void *data, u32 size,
508 struct nouveau_object **pobject)
510 struct nv50_display_curs_class *args = data;
511 struct nv50_disp_pioc *pioc;
514 if (size < sizeof(*args) || args->head > 1)
517 ret = nv50_disp_pioc_create_(parent, engine, oclass, 7 + args->head,
518 sizeof(*pioc), (void **)&pioc);
519 *pobject = nv_object(pioc);
526 struct nouveau_ofuncs
527 nv50_disp_curs_ofuncs = {
528 .ctor = nv50_disp_curs_ctor,
529 .dtor = nv50_disp_pioc_dtor,
530 .init = nv50_disp_pioc_init,
531 .fini = nv50_disp_pioc_fini,
532 .rd32 = nv50_disp_chan_rd32,
533 .wr32 = nv50_disp_chan_wr32,
536 /*******************************************************************************
537 * Base display object
538 ******************************************************************************/
541 nv50_disp_base_ctor(struct nouveau_object *parent,
542 struct nouveau_object *engine,
543 struct nouveau_oclass *oclass, void *data, u32 size,
544 struct nouveau_object **pobject)
546 struct nv50_disp_priv *priv = (void *)engine;
547 struct nv50_disp_base *base;
550 ret = nouveau_parent_create(parent, engine, oclass, 0,
551 priv->sclass, 0, &base);
552 *pobject = nv_object(base);
556 return nouveau_ramht_new(parent, parent, 0x1000, 0, &base->ramht);
560 nv50_disp_base_dtor(struct nouveau_object *object)
562 struct nv50_disp_base *base = (void *)object;
563 nouveau_ramht_ref(NULL, &base->ramht);
564 nouveau_parent_destroy(&base->base);
568 nv50_disp_base_init(struct nouveau_object *object)
570 struct nv50_disp_priv *priv = (void *)object->engine;
571 struct nv50_disp_base *base = (void *)object;
575 ret = nouveau_parent_init(&base->base);
579 /* The below segments of code copying values from one register to
580 * another appear to inform EVO of the display capabilities or
581 * something similar. NFI what the 0x614004 caps are for..
583 tmp = nv_rd32(priv, 0x614004);
584 nv_wr32(priv, 0x610184, tmp);
587 for (i = 0; i < priv->head.nr; i++) {
588 tmp = nv_rd32(priv, 0x616100 + (i * 0x800));
589 nv_wr32(priv, 0x610190 + (i * 0x10), tmp);
590 tmp = nv_rd32(priv, 0x616104 + (i * 0x800));
591 nv_wr32(priv, 0x610194 + (i * 0x10), tmp);
592 tmp = nv_rd32(priv, 0x616108 + (i * 0x800));
593 nv_wr32(priv, 0x610198 + (i * 0x10), tmp);
594 tmp = nv_rd32(priv, 0x61610c + (i * 0x800));
595 nv_wr32(priv, 0x61019c + (i * 0x10), tmp);
599 for (i = 0; i < priv->dac.nr; i++) {
600 tmp = nv_rd32(priv, 0x61a000 + (i * 0x800));
601 nv_wr32(priv, 0x6101d0 + (i * 0x04), tmp);
605 for (i = 0; i < priv->sor.nr; i++) {
606 tmp = nv_rd32(priv, 0x61c000 + (i * 0x800));
607 nv_wr32(priv, 0x6101e0 + (i * 0x04), tmp);
611 for (i = 0; i < 3; i++) {
612 tmp = nv_rd32(priv, 0x61e000 + (i * 0x800));
613 nv_wr32(priv, 0x6101f0 + (i * 0x04), tmp);
616 /* steal display away from vbios, or something like that */
617 if (nv_rd32(priv, 0x610024) & 0x00000100) {
618 nv_wr32(priv, 0x610024, 0x00000100);
619 nv_mask(priv, 0x6194e8, 0x00000001, 0x00000000);
620 if (!nv_wait(priv, 0x6194e8, 0x00000002, 0x00000000)) {
621 nv_error(priv, "timeout acquiring display\n");
626 /* point at display engine memory area (hash table, objects) */
627 nv_wr32(priv, 0x610010, (nv_gpuobj(base->ramht)->addr >> 8) | 9);
629 /* enable supervisor interrupts, disable everything else */
630 nv_wr32(priv, 0x61002c, 0x00000370);
631 nv_wr32(priv, 0x610028, 0x00000000);
636 nv50_disp_base_fini(struct nouveau_object *object, bool suspend)
638 struct nv50_disp_priv *priv = (void *)object->engine;
639 struct nv50_disp_base *base = (void *)object;
641 /* disable all interrupts */
642 nv_wr32(priv, 0x610024, 0x00000000);
643 nv_wr32(priv, 0x610020, 0x00000000);
645 return nouveau_parent_fini(&base->base, suspend);
648 struct nouveau_ofuncs
649 nv50_disp_base_ofuncs = {
650 .ctor = nv50_disp_base_ctor,
651 .dtor = nv50_disp_base_dtor,
652 .init = nv50_disp_base_init,
653 .fini = nv50_disp_base_fini,
656 static struct nouveau_omthds
657 nv50_disp_base_omthds[] = {
658 { SOR_MTHD(NV50_DISP_SOR_PWR) , nv50_sor_mthd },
659 { SOR_MTHD(NV50_DISP_SOR_LVDS_SCRIPT) , nv50_sor_mthd },
660 { DAC_MTHD(NV50_DISP_DAC_PWR) , nv50_dac_mthd },
661 { DAC_MTHD(NV50_DISP_DAC_LOAD) , nv50_dac_mthd },
665 static struct nouveau_oclass
666 nv50_disp_base_oclass[] = {
667 { NV50_DISP_CLASS, &nv50_disp_base_ofuncs, nv50_disp_base_omthds },
671 static struct nouveau_oclass
672 nv50_disp_sclass[] = {
673 { NV50_DISP_MAST_CLASS, &nv50_disp_mast_ofuncs },
674 { NV50_DISP_SYNC_CLASS, &nv50_disp_sync_ofuncs },
675 { NV50_DISP_OVLY_CLASS, &nv50_disp_ovly_ofuncs },
676 { NV50_DISP_OIMM_CLASS, &nv50_disp_oimm_ofuncs },
677 { NV50_DISP_CURS_CLASS, &nv50_disp_curs_ofuncs },
681 /*******************************************************************************
682 * Display context, tracks instmem allocation and prevents more than one
683 * client using the display hardware at any time.
684 ******************************************************************************/
687 nv50_disp_data_ctor(struct nouveau_object *parent,
688 struct nouveau_object *engine,
689 struct nouveau_oclass *oclass, void *data, u32 size,
690 struct nouveau_object **pobject)
692 struct nv50_disp_priv *priv = (void *)engine;
693 struct nouveau_engctx *ectx;
696 /* no context needed for channel objects... */
697 if (nv_mclass(parent) != NV_DEVICE_CLASS) {
698 atomic_inc(&parent->refcount);
703 /* allocate display hardware to client */
704 mutex_lock(&nv_subdev(priv)->mutex);
705 if (list_empty(&nv_engine(priv)->contexts)) {
706 ret = nouveau_engctx_create(parent, engine, oclass, NULL,
708 NVOBJ_FLAG_HEAP, &ectx);
709 *pobject = nv_object(ectx);
711 mutex_unlock(&nv_subdev(priv)->mutex);
715 struct nouveau_oclass
717 .handle = NV_ENGCTX(DISP, 0x50),
718 .ofuncs = &(struct nouveau_ofuncs) {
719 .ctor = nv50_disp_data_ctor,
720 .dtor = _nouveau_engctx_dtor,
721 .init = _nouveau_engctx_init,
722 .fini = _nouveau_engctx_fini,
723 .rd32 = _nouveau_engctx_rd32,
724 .wr32 = _nouveau_engctx_wr32,
728 /*******************************************************************************
729 * Display engine implementation
730 ******************************************************************************/
733 nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc)
735 struct nouveau_disp *disp = &priv->base;
736 struct nouveau_software_chan *chan, *temp;
739 spin_lock_irqsave(&disp->vblank.lock, flags);
740 list_for_each_entry_safe(chan, temp, &disp->vblank.list, vblank.head) {
741 if (chan->vblank.crtc != crtc)
744 nv_wr32(priv, 0x001704, chan->vblank.channel);
745 nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma);
747 if (nv_device(priv)->chipset == 0x50) {
748 nv_wr32(priv, 0x001570, chan->vblank.offset);
749 nv_wr32(priv, 0x001574, chan->vblank.value);
751 if (nv_device(priv)->chipset >= 0xc0) {
752 nv_wr32(priv, 0x06000c,
753 upper_32_bits(chan->vblank.offset));
755 nv_wr32(priv, 0x060010, chan->vblank.offset);
756 nv_wr32(priv, 0x060014, chan->vblank.value);
759 list_del(&chan->vblank.head);
760 if (disp->vblank.put)
761 disp->vblank.put(disp->vblank.data, crtc);
763 spin_unlock_irqrestore(&disp->vblank.lock, flags);
765 if (disp->vblank.notify)
766 disp->vblank.notify(disp->vblank.data, crtc);
770 nv50_disp_intr(struct nouveau_subdev *subdev)
772 struct nv50_disp_priv *priv = (void *)subdev;
773 u32 stat1 = nv_rd32(priv, 0x610024);
775 if (stat1 & 0x00000004) {
776 nv50_disp_intr_vblank(priv, 0);
777 nv_wr32(priv, 0x610024, 0x00000004);
778 stat1 &= ~0x00000004;
781 if (stat1 & 0x00000008) {
782 nv50_disp_intr_vblank(priv, 1);
783 nv_wr32(priv, 0x610024, 0x00000008);
784 stat1 &= ~0x00000008;
790 nv50_disp_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
791 struct nouveau_oclass *oclass, void *data, u32 size,
792 struct nouveau_object **pobject)
794 struct nv50_disp_priv *priv;
797 ret = nouveau_disp_create(parent, engine, oclass, "PDISP",
799 *pobject = nv_object(priv);
803 nv_engine(priv)->sclass = nv50_disp_base_oclass;
804 nv_engine(priv)->cclass = &nv50_disp_cclass;
805 nv_subdev(priv)->intr = nv50_disp_intr;
806 priv->sclass = nv50_disp_sclass;
810 priv->dac.power = nv50_dac_power;
811 priv->dac.sense = nv50_dac_sense;
812 priv->sor.power = nv50_sor_power;
814 INIT_LIST_HEAD(&priv->base.vblank.list);
815 spin_lock_init(&priv->base.vblank.lock);
819 struct nouveau_oclass
821 .handle = NV_ENGINE(DISP, 0x50),
822 .ofuncs = &(struct nouveau_ofuncs) {
823 .ctor = nv50_disp_ctor,
824 .dtor = _nouveau_disp_dtor,
825 .init = _nouveau_disp_init,
826 .fini = _nouveau_disp_fini,