2 * Copyright 2011 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 <linux/dma-mapping.h>
28 #include "drm_crtc_helper.h"
30 #include "nouveau_drv.h"
31 #include "nouveau_connector.h"
32 #include "nouveau_encoder.h"
33 #include "nouveau_crtc.h"
34 #include "nouveau_fb.h"
35 #include "nv50_display.h"
37 #define MEM_SYNC 0xe0000001
38 #define MEM_VRAM 0xe0010000
39 #include "nouveau_dma.h"
42 struct nouveau_gpuobj *mem;
48 struct tasklet_struct tasklet;
52 static struct nvd0_display *
53 nvd0_display(struct drm_device *dev)
55 struct drm_nouveau_private *dev_priv = dev->dev_private;
56 return dev_priv->engine.display.priv;
60 evo_icmd(struct drm_device *dev, int id, u32 mthd, u32 data)
63 nv_mask(dev, 0x610700 + (id * 0x10), 0x00000001, 0x00000001);
64 nv_wr32(dev, 0x610704 + (id * 0x10), data);
65 nv_mask(dev, 0x610704 + (id * 0x10), 0x80000ffc, 0x80000000 | mthd);
66 if (!nv_wait(dev, 0x610704 + (id * 0x10), 0x80000000, 0x00000000))
68 nv_mask(dev, 0x610700 + (id * 0x10), 0x00000001, 0x00000000);
73 evo_wait(struct drm_device *dev, int id, int nr)
75 struct nvd0_display *disp = nvd0_display(dev);
76 u32 put = nv_rd32(dev, 0x640000 + (id * 0x1000)) / 4;
78 if (put + nr >= (PAGE_SIZE / 4)) {
79 disp->evo[id].ptr[put] = 0x20000000;
81 nv_wr32(dev, 0x640000 + (id * 0x1000), 0x00000000);
82 if (!nv_wait(dev, 0x640004 + (id * 0x1000), ~0, 0x00000000)) {
83 NV_ERROR(dev, "evo %d dma stalled\n", id);
90 return disp->evo[id].ptr + put;
94 evo_kick(u32 *push, struct drm_device *dev, int id)
96 struct nvd0_display *disp = nvd0_display(dev);
97 nv_wr32(dev, 0x640000 + (id * 0x1000), (push - disp->evo[id].ptr) << 2);
100 #define evo_mthd(p,m,s) *((p)++) = (((s) << 18) | (m))
101 #define evo_data(p,d) *((p)++) = (d)
103 static struct drm_crtc *
104 nvd0_display_crtc_get(struct drm_encoder *encoder)
106 return nouveau_encoder(encoder)->crtc;
109 /******************************************************************************
111 *****************************************************************************/
113 nvd0_crtc_set_dither(struct nouveau_crtc *nv_crtc, bool on, bool update)
115 struct drm_device *dev = nv_crtc->base.dev;
120 /* 0x11: 6bpc dynamic 2x2
121 * 0x13: 8bpc dynamic 2x2
122 * 0x19: 6bpc static 2x2
123 * 0x1b: 8bpc static 2x2
124 * 0x21: 6bpc temporal
125 * 0x23: 8bpc temporal
130 push = evo_wait(dev, 0, 4);
132 evo_mthd(push, 0x0490 + (nv_crtc->index * 0x300), 1);
133 evo_data(push, mode);
135 evo_mthd(push, 0x0080, 1);
136 evo_data(push, 0x00000000);
138 evo_kick(push, dev, 0);
145 nvd0_crtc_set_scale(struct nouveau_crtc *nv_crtc, int type, bool update)
147 struct drm_display_mode *mode = &nv_crtc->base.mode;
148 struct drm_device *dev = nv_crtc->base.dev;
149 struct nouveau_connector *nv_connector;
150 u32 *push, outX, outY;
152 outX = mode->hdisplay;
153 outY = mode->vdisplay;
155 nv_connector = nouveau_crtc_connector_get(nv_crtc);
156 if (nv_connector && nv_connector->native_mode) {
157 struct drm_display_mode *native = nv_connector->native_mode;
158 u32 xratio = (native->hdisplay << 19) / mode->hdisplay;
159 u32 yratio = (native->vdisplay << 19) / mode->vdisplay;
162 case DRM_MODE_SCALE_ASPECT:
163 if (xratio > yratio) {
164 outX = (mode->hdisplay * yratio) >> 19;
165 outY = (mode->vdisplay * yratio) >> 19;
167 outX = (mode->hdisplay * xratio) >> 19;
168 outY = (mode->vdisplay * xratio) >> 19;
171 case DRM_MODE_SCALE_FULLSCREEN:
172 outX = native->hdisplay;
173 outY = native->vdisplay;
180 push = evo_wait(dev, 0, 16);
182 evo_mthd(push, 0x04c0 + (nv_crtc->index * 0x300), 3);
183 evo_data(push, (outY << 16) | outX);
184 evo_data(push, (outY << 16) | outX);
185 evo_data(push, (outY << 16) | outX);
186 evo_mthd(push, 0x0494 + (nv_crtc->index * 0x300), 1);
187 evo_data(push, 0x00000000);
188 evo_mthd(push, 0x04b8 + (nv_crtc->index * 0x300), 1);
189 evo_data(push, (mode->vdisplay << 16) | mode->hdisplay);
191 evo_mthd(push, 0x0080, 1);
192 evo_data(push, 0x00000000);
194 evo_kick(push, dev, 0);
201 nvd0_crtc_set_image(struct nouveau_crtc *nv_crtc, struct drm_framebuffer *fb,
202 int x, int y, bool update)
204 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(fb);
207 push = evo_wait(fb->dev, 0, 16);
209 evo_mthd(push, 0x0460 + (nv_crtc->index * 0x300), 1);
210 evo_data(push, nvfb->nvbo->bo.offset >> 8);
211 evo_mthd(push, 0x0468 + (nv_crtc->index * 0x300), 4);
212 evo_data(push, (fb->height << 16) | fb->width);
213 evo_data(push, nvfb->r_pitch);
214 evo_data(push, nvfb->r_format);
215 evo_data(push, nvfb->r_dma);
216 evo_mthd(push, 0x04b0 + (nv_crtc->index * 0x300), 1);
217 evo_data(push, (y << 16) | x);
219 evo_mthd(push, 0x0080, 1);
220 evo_data(push, 0x00000000);
222 evo_kick(push, fb->dev, 0);
225 nv_crtc->fb.tile_flags = nvfb->r_dma;
230 nvd0_crtc_cursor_show(struct nouveau_crtc *nv_crtc, bool show, bool update)
232 struct drm_device *dev = nv_crtc->base.dev;
233 u32 *push = evo_wait(dev, 0, 16);
236 evo_mthd(push, 0x0480 + (nv_crtc->index * 0x300), 2);
237 evo_data(push, 0x85000000);
238 evo_data(push, nv_crtc->cursor.nvbo->bo.offset >> 8);
239 evo_mthd(push, 0x048c + (nv_crtc->index * 0x300), 1);
240 evo_data(push, MEM_VRAM);
242 evo_mthd(push, 0x0480 + (nv_crtc->index * 0x300), 1);
243 evo_data(push, 0x05000000);
244 evo_mthd(push, 0x048c + (nv_crtc->index * 0x300), 1);
245 evo_data(push, 0x00000000);
249 evo_mthd(push, 0x0080, 1);
250 evo_data(push, 0x00000000);
253 evo_kick(push, dev, 0);
258 nvd0_crtc_dpms(struct drm_crtc *crtc, int mode)
263 nvd0_crtc_prepare(struct drm_crtc *crtc)
265 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
268 push = evo_wait(crtc->dev, 0, 2);
270 evo_mthd(push, 0x0474 + (nv_crtc->index * 0x300), 1);
271 evo_data(push, 0x00000000);
272 evo_mthd(push, 0x0440 + (nv_crtc->index * 0x300), 1);
273 evo_data(push, 0x03000000);
274 evo_mthd(push, 0x045c + (nv_crtc->index * 0x300), 1);
275 evo_data(push, 0x00000000);
276 evo_kick(push, crtc->dev, 0);
279 nvd0_crtc_cursor_show(nv_crtc, false, false);
283 nvd0_crtc_commit(struct drm_crtc *crtc)
285 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
288 push = evo_wait(crtc->dev, 0, 32);
290 evo_mthd(push, 0x0474 + (nv_crtc->index * 0x300), 1);
291 evo_data(push, nv_crtc->fb.tile_flags);
292 evo_mthd(push, 0x0440 + (nv_crtc->index * 0x300), 4);
293 evo_data(push, 0x83000000);
294 evo_data(push, nv_crtc->lut.nvbo->bo.offset >> 8);
295 evo_data(push, 0x00000000);
296 evo_data(push, 0x00000000);
297 evo_mthd(push, 0x045c + (nv_crtc->index * 0x300), 1);
298 evo_data(push, MEM_VRAM);
299 evo_mthd(push, 0x0430 + (nv_crtc->index * 0x300), 1);
300 evo_data(push, 0xffffff00);
301 evo_kick(push, crtc->dev, 0);
304 nvd0_crtc_cursor_show(nv_crtc, nv_crtc->cursor.visible, true);
308 nvd0_crtc_mode_fixup(struct drm_crtc *crtc, struct drm_display_mode *mode,
309 struct drm_display_mode *adjusted_mode)
315 nvd0_crtc_swap_fbs(struct drm_crtc *crtc, struct drm_framebuffer *old_fb)
317 struct nouveau_framebuffer *nvfb = nouveau_framebuffer(crtc->fb);
320 ret = nouveau_bo_pin(nvfb->nvbo, TTM_PL_FLAG_VRAM);
325 nvfb = nouveau_framebuffer(old_fb);
326 nouveau_bo_unpin(nvfb->nvbo);
333 nvd0_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *umode,
334 struct drm_display_mode *mode, int x, int y,
335 struct drm_framebuffer *old_fb)
337 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
338 struct nouveau_connector *nv_connector;
339 u32 htotal = mode->htotal;
340 u32 vtotal = mode->vtotal;
341 u32 hsyncw = mode->hsync_end - mode->hsync_start - 1;
342 u32 vsyncw = mode->vsync_end - mode->vsync_start - 1;
343 u32 hfrntp = mode->hsync_start - mode->hdisplay;
344 u32 vfrntp = mode->vsync_start - mode->vdisplay;
345 u32 hbackp = mode->htotal - mode->hsync_end;
346 u32 vbackp = mode->vtotal - mode->vsync_end;
347 u32 hss2be = hsyncw + hbackp;
348 u32 vss2be = vsyncw + vbackp;
349 u32 hss2de = htotal - hfrntp;
350 u32 vss2de = vtotal - vfrntp;
355 if (mode->flags & DRM_MODE_FLAG_NHSYNC)
357 if (mode->flags & DRM_MODE_FLAG_NVSYNC)
360 ret = nvd0_crtc_swap_fbs(crtc, old_fb);
364 push = evo_wait(crtc->dev, 0, 64);
366 evo_mthd(push, 0x0410 + (nv_crtc->index * 0x300), 5);
367 evo_data(push, 0x00000000);
368 evo_data(push, (vtotal << 16) | htotal);
369 evo_data(push, (vsyncw << 16) | hsyncw);
370 evo_data(push, (vss2be << 16) | hss2be);
371 evo_data(push, (vss2de << 16) | hss2de);
372 evo_mthd(push, 0x042c + (nv_crtc->index * 0x300), 1);
373 evo_data(push, 0x00000000); /* ??? */
374 evo_mthd(push, 0x0450 + (nv_crtc->index * 0x300), 3);
375 evo_data(push, mode->clock * 1000);
376 evo_data(push, 0x00200000); /* ??? */
377 evo_data(push, mode->clock * 1000);
378 evo_mthd(push, 0x0404 + (nv_crtc->index * 0x300), 1);
379 evo_data(push, syncs);
380 evo_kick(push, crtc->dev, 0);
383 nv_connector = nouveau_crtc_connector_get(nv_crtc);
384 nvd0_crtc_set_dither(nv_crtc, nv_connector->use_dithering, false);
385 nvd0_crtc_set_scale(nv_crtc, nv_connector->scaling_mode, false);
386 nvd0_crtc_set_image(nv_crtc, crtc->fb, x, y, false);
391 nvd0_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
392 struct drm_framebuffer *old_fb)
394 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
397 ret = nvd0_crtc_swap_fbs(crtc, old_fb);
401 nvd0_crtc_set_image(nv_crtc, crtc->fb, x, y, true);
406 nvd0_crtc_mode_set_base_atomic(struct drm_crtc *crtc,
407 struct drm_framebuffer *fb, int x, int y,
408 enum mode_set_atomic state)
410 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
411 nvd0_crtc_set_image(nv_crtc, fb, x, y, true);
416 nvd0_crtc_lut_load(struct drm_crtc *crtc)
418 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
419 void __iomem *lut = nvbo_kmap_obj_iovirtual(nv_crtc->lut.nvbo);
422 for (i = 0; i < 256; i++) {
423 writew(0x6000 + (nv_crtc->lut.r[i] >> 2), lut + (i * 0x20) + 0);
424 writew(0x6000 + (nv_crtc->lut.g[i] >> 2), lut + (i * 0x20) + 2);
425 writew(0x6000 + (nv_crtc->lut.b[i] >> 2), lut + (i * 0x20) + 4);
430 nvd0_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
431 uint32_t handle, uint32_t width, uint32_t height)
433 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
434 struct drm_device *dev = crtc->dev;
435 struct drm_gem_object *gem;
436 struct nouveau_bo *nvbo;
437 bool visible = (handle != 0);
441 if (width != 64 || height != 64)
444 gem = drm_gem_object_lookup(dev, file_priv, handle);
447 nvbo = nouveau_gem_object(gem);
449 ret = nouveau_bo_map(nvbo);
451 for (i = 0; i < 64 * 64; i++) {
452 u32 v = nouveau_bo_rd32(nvbo, i);
453 nouveau_bo_wr32(nv_crtc->cursor.nvbo, i, v);
455 nouveau_bo_unmap(nvbo);
458 drm_gem_object_unreference_unlocked(gem);
461 if (visible != nv_crtc->cursor.visible) {
462 nvd0_crtc_cursor_show(nv_crtc, visible, true);
463 nv_crtc->cursor.visible = visible;
470 nvd0_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
472 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
473 const u32 data = (y << 16) | x;
475 nv_wr32(crtc->dev, 0x64d084 + (nv_crtc->index * 0x1000), data);
476 nv_wr32(crtc->dev, 0x64d080 + (nv_crtc->index * 0x1000), 0x00000000);
481 nvd0_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
482 uint32_t start, uint32_t size)
484 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
485 u32 end = max(start + size, (u32)256);
488 for (i = start; i < end; i++) {
489 nv_crtc->lut.r[i] = r[i];
490 nv_crtc->lut.g[i] = g[i];
491 nv_crtc->lut.b[i] = b[i];
494 nvd0_crtc_lut_load(crtc);
498 nvd0_crtc_destroy(struct drm_crtc *crtc)
500 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
501 nouveau_bo_unmap(nv_crtc->cursor.nvbo);
502 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
503 nouveau_bo_unmap(nv_crtc->lut.nvbo);
504 nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
505 drm_crtc_cleanup(crtc);
509 static const struct drm_crtc_helper_funcs nvd0_crtc_hfunc = {
510 .dpms = nvd0_crtc_dpms,
511 .prepare = nvd0_crtc_prepare,
512 .commit = nvd0_crtc_commit,
513 .mode_fixup = nvd0_crtc_mode_fixup,
514 .mode_set = nvd0_crtc_mode_set,
515 .mode_set_base = nvd0_crtc_mode_set_base,
516 .mode_set_base_atomic = nvd0_crtc_mode_set_base_atomic,
517 .load_lut = nvd0_crtc_lut_load,
520 static const struct drm_crtc_funcs nvd0_crtc_func = {
521 .cursor_set = nvd0_crtc_cursor_set,
522 .cursor_move = nvd0_crtc_cursor_move,
523 .gamma_set = nvd0_crtc_gamma_set,
524 .set_config = drm_crtc_helper_set_config,
525 .destroy = nvd0_crtc_destroy,
529 nvd0_crtc_create(struct drm_device *dev, int index)
531 struct nouveau_crtc *nv_crtc;
532 struct drm_crtc *crtc;
535 nv_crtc = kzalloc(sizeof(*nv_crtc), GFP_KERNEL);
539 nv_crtc->index = index;
540 nv_crtc->set_dither = nvd0_crtc_set_dither;
541 nv_crtc->set_scale = nvd0_crtc_set_scale;
542 for (i = 0; i < 256; i++) {
543 nv_crtc->lut.r[i] = i << 8;
544 nv_crtc->lut.g[i] = i << 8;
545 nv_crtc->lut.b[i] = i << 8;
548 crtc = &nv_crtc->base;
549 drm_crtc_init(dev, crtc, &nvd0_crtc_func);
550 drm_crtc_helper_add(crtc, &nvd0_crtc_hfunc);
551 drm_mode_crtc_set_gamma_size(crtc, 256);
553 ret = nouveau_bo_new(dev, 64 * 64 * 4, 0x100, TTM_PL_FLAG_VRAM,
554 0, 0x0000, &nv_crtc->cursor.nvbo);
556 ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM);
558 ret = nouveau_bo_map(nv_crtc->cursor.nvbo);
560 nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
566 ret = nouveau_bo_new(dev, 8192, 0x100, TTM_PL_FLAG_VRAM,
567 0, 0x0000, &nv_crtc->lut.nvbo);
569 ret = nouveau_bo_pin(nv_crtc->lut.nvbo, TTM_PL_FLAG_VRAM);
571 ret = nouveau_bo_map(nv_crtc->lut.nvbo);
573 nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
579 nvd0_crtc_lut_load(crtc);
583 nvd0_crtc_destroy(crtc);
587 /******************************************************************************
589 *****************************************************************************/
591 nvd0_dac_dpms(struct drm_encoder *encoder, int mode)
593 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
594 struct drm_device *dev = encoder->dev;
595 int or = nv_encoder->or;
598 dpms_ctrl = 0x80000000;
599 if (mode == DRM_MODE_DPMS_STANDBY || mode == DRM_MODE_DPMS_OFF)
600 dpms_ctrl |= 0x00000001;
601 if (mode == DRM_MODE_DPMS_SUSPEND || mode == DRM_MODE_DPMS_OFF)
602 dpms_ctrl |= 0x00000004;
604 nv_wait(dev, 0x61a004 + (or * 0x0800), 0x80000000, 0x00000000);
605 nv_mask(dev, 0x61a004 + (or * 0x0800), 0xc000007f, dpms_ctrl);
606 nv_wait(dev, 0x61a004 + (or * 0x0800), 0x80000000, 0x00000000);
610 nvd0_dac_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
611 struct drm_display_mode *adjusted_mode)
613 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
614 struct nouveau_connector *nv_connector;
616 nv_connector = nouveau_encoder_connector_get(nv_encoder);
617 if (nv_connector && nv_connector->native_mode) {
618 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
619 int id = adjusted_mode->base.id;
620 *adjusted_mode = *nv_connector->native_mode;
621 adjusted_mode->base.id = id;
629 nvd0_dac_prepare(struct drm_encoder *encoder)
634 nvd0_dac_commit(struct drm_encoder *encoder)
639 nvd0_dac_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
640 struct drm_display_mode *adjusted_mode)
642 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
643 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
646 nvd0_dac_dpms(encoder, DRM_MODE_DPMS_ON);
648 push = evo_wait(encoder->dev, 0, 4);
650 evo_mthd(push, 0x0180 + (nv_encoder->or * 0x20), 2);
651 evo_data(push, 1 << nv_crtc->index);
652 evo_data(push, 0x00ff);
653 evo_kick(push, encoder->dev, 0);
656 nv_encoder->crtc = encoder->crtc;
660 nvd0_dac_disconnect(struct drm_encoder *encoder)
662 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
663 struct drm_device *dev = encoder->dev;
666 if (nv_encoder->crtc) {
667 nvd0_crtc_prepare(nv_encoder->crtc);
669 push = evo_wait(dev, 0, 4);
671 evo_mthd(push, 0x0180 + (nv_encoder->or * 0x20), 1);
672 evo_data(push, 0x00000000);
673 evo_mthd(push, 0x0080, 1);
674 evo_data(push, 0x00000000);
675 evo_kick(push, dev, 0);
678 nv_encoder->crtc = NULL;
682 static enum drm_connector_status
683 nvd0_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
685 enum drm_connector_status status = connector_status_disconnected;
686 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
687 struct drm_device *dev = encoder->dev;
688 int or = nv_encoder->or;
691 nv_wr32(dev, 0x61a00c + (or * 0x800), 0x00100000);
693 nv_wr32(dev, 0x61a00c + (or * 0x800), 0x80000000);
695 load = nv_rd32(dev, 0x61a00c + (or * 0x800));
696 if ((load & 0x38000000) == 0x38000000)
697 status = connector_status_connected;
699 nv_wr32(dev, 0x61a00c + (or * 0x800), 0x00000000);
704 nvd0_dac_destroy(struct drm_encoder *encoder)
706 drm_encoder_cleanup(encoder);
710 static const struct drm_encoder_helper_funcs nvd0_dac_hfunc = {
711 .dpms = nvd0_dac_dpms,
712 .mode_fixup = nvd0_dac_mode_fixup,
713 .prepare = nvd0_dac_prepare,
714 .commit = nvd0_dac_commit,
715 .mode_set = nvd0_dac_mode_set,
716 .disable = nvd0_dac_disconnect,
717 .get_crtc = nvd0_display_crtc_get,
718 .detect = nvd0_dac_detect
721 static const struct drm_encoder_funcs nvd0_dac_func = {
722 .destroy = nvd0_dac_destroy,
726 nvd0_dac_create(struct drm_connector *connector, struct dcb_entry *dcbe)
728 struct drm_device *dev = connector->dev;
729 struct nouveau_encoder *nv_encoder;
730 struct drm_encoder *encoder;
732 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
735 nv_encoder->dcb = dcbe;
736 nv_encoder->or = ffs(dcbe->or) - 1;
738 encoder = to_drm_encoder(nv_encoder);
739 encoder->possible_crtcs = dcbe->heads;
740 encoder->possible_clones = 0;
741 drm_encoder_init(dev, encoder, &nvd0_dac_func, DRM_MODE_ENCODER_DAC);
742 drm_encoder_helper_add(encoder, &nvd0_dac_hfunc);
744 drm_mode_connector_attach_encoder(connector, encoder);
748 /******************************************************************************
750 *****************************************************************************/
752 nvd0_sor_dpms(struct drm_encoder *encoder, int mode)
754 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
755 struct drm_device *dev = encoder->dev;
756 struct drm_encoder *partner;
757 int or = nv_encoder->or;
760 nv_encoder->last_dpms = mode;
762 list_for_each_entry(partner, &dev->mode_config.encoder_list, head) {
763 struct nouveau_encoder *nv_partner = nouveau_encoder(partner);
765 if (partner->encoder_type != DRM_MODE_ENCODER_TMDS)
768 if (nv_partner != nv_encoder &&
769 nv_partner->dcb->or == nv_encoder->or) {
770 if (nv_partner->last_dpms == DRM_MODE_DPMS_ON)
776 dpms_ctrl = (mode == DRM_MODE_DPMS_ON);
777 dpms_ctrl |= 0x80000000;
779 nv_wait(dev, 0x61c004 + (or * 0x0800), 0x80000000, 0x00000000);
780 nv_mask(dev, 0x61c004 + (or * 0x0800), 0x80000001, dpms_ctrl);
781 nv_wait(dev, 0x61c004 + (or * 0x0800), 0x80000000, 0x00000000);
782 nv_wait(dev, 0x61c030 + (or * 0x0800), 0x10000000, 0x00000000);
786 nvd0_sor_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
787 struct drm_display_mode *adjusted_mode)
789 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
790 struct nouveau_connector *nv_connector;
792 nv_connector = nouveau_encoder_connector_get(nv_encoder);
793 if (nv_connector && nv_connector->native_mode) {
794 if (nv_connector->scaling_mode != DRM_MODE_SCALE_NONE) {
795 int id = adjusted_mode->base.id;
796 *adjusted_mode = *nv_connector->native_mode;
797 adjusted_mode->base.id = id;
805 nvd0_sor_prepare(struct drm_encoder *encoder)
810 nvd0_sor_commit(struct drm_encoder *encoder)
815 nvd0_sor_mode_set(struct drm_encoder *encoder, struct drm_display_mode *umode,
816 struct drm_display_mode *mode)
818 struct drm_nouveau_private *dev_priv = encoder->dev->dev_private;
819 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
820 struct nouveau_crtc *nv_crtc = nouveau_crtc(encoder->crtc);
821 struct nouveau_connector *nv_connector;
822 struct nvbios *bios = &dev_priv->vbios;
823 u32 mode_ctrl = (1 << nv_crtc->index);
824 u32 *push, or_config;
826 nv_connector = nouveau_encoder_connector_get(nv_encoder);
827 switch (nv_encoder->dcb->type) {
829 if (nv_encoder->dcb->sorconf.link & 1) {
830 if (mode->clock < 165000)
831 mode_ctrl |= 0x00000100;
833 mode_ctrl |= 0x00000500;
835 mode_ctrl |= 0x00000200;
838 or_config = (mode_ctrl & 0x00000f00) >> 8;
839 if (mode->clock >= 165000)
843 or_config = (mode_ctrl & 0x00000f00) >> 8;
844 if (bios->fp_no_ddc) {
845 if (bios->fp.dual_link)
847 if (bios->fp.if_is_24bit)
850 if (nv_connector->dcb->type == DCB_CONNECTOR_LVDS_SPWG) {
851 if (((u8 *)nv_connector->edid)[121] == 2)
854 if (mode->clock >= bios->fp.duallink_transition_clk) {
858 if (or_config & 0x0100) {
859 if (bios->fp.strapless_is_24bit & 2)
862 if (bios->fp.strapless_is_24bit & 1)
866 if (nv_connector->base.display_info.bpc == 8)
876 nvd0_sor_dpms(encoder, DRM_MODE_DPMS_ON);
878 push = evo_wait(encoder->dev, 0, 4);
880 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x20), 2);
881 evo_data(push, mode_ctrl);
882 evo_data(push, or_config);
883 evo_kick(push, encoder->dev, 0);
886 nv_encoder->crtc = encoder->crtc;
890 nvd0_sor_disconnect(struct drm_encoder *encoder)
892 struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
893 struct drm_device *dev = encoder->dev;
896 if (nv_encoder->crtc) {
897 nvd0_crtc_prepare(nv_encoder->crtc);
899 push = evo_wait(dev, 0, 4);
901 evo_mthd(push, 0x0200 + (nv_encoder->or * 0x20), 1);
902 evo_data(push, 0x00000000);
903 evo_mthd(push, 0x0080, 1);
904 evo_data(push, 0x00000000);
905 evo_kick(push, dev, 0);
908 nv_encoder->crtc = NULL;
909 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF;
914 nvd0_sor_destroy(struct drm_encoder *encoder)
916 drm_encoder_cleanup(encoder);
920 static const struct drm_encoder_helper_funcs nvd0_sor_hfunc = {
921 .dpms = nvd0_sor_dpms,
922 .mode_fixup = nvd0_sor_mode_fixup,
923 .prepare = nvd0_sor_prepare,
924 .commit = nvd0_sor_commit,
925 .mode_set = nvd0_sor_mode_set,
926 .disable = nvd0_sor_disconnect,
927 .get_crtc = nvd0_display_crtc_get,
930 static const struct drm_encoder_funcs nvd0_sor_func = {
931 .destroy = nvd0_sor_destroy,
935 nvd0_sor_create(struct drm_connector *connector, struct dcb_entry *dcbe)
937 struct drm_device *dev = connector->dev;
938 struct nouveau_encoder *nv_encoder;
939 struct drm_encoder *encoder;
941 nv_encoder = kzalloc(sizeof(*nv_encoder), GFP_KERNEL);
944 nv_encoder->dcb = dcbe;
945 nv_encoder->or = ffs(dcbe->or) - 1;
946 nv_encoder->last_dpms = DRM_MODE_DPMS_OFF;
948 encoder = to_drm_encoder(nv_encoder);
949 encoder->possible_crtcs = dcbe->heads;
950 encoder->possible_clones = 0;
951 drm_encoder_init(dev, encoder, &nvd0_sor_func, DRM_MODE_ENCODER_TMDS);
952 drm_encoder_helper_add(encoder, &nvd0_sor_hfunc);
954 drm_mode_connector_attach_encoder(connector, encoder);
958 /******************************************************************************
960 *****************************************************************************/
962 debug_irq(struct drm_device *dev, int i)
964 if (drm_debug & (DRM_UT_DRIVER | DRM_UT_KMS)) {
965 NV_INFO(dev, "PDISP: modeset req %d\n", i);
966 NV_INFO(dev, " STAT: 0x%08x 0x%08x 0x%08x\n",
967 nv_rd32(dev, 0x6101d0),
968 nv_rd32(dev, 0x6101d4), nv_rd32(dev, 0x6109d4));
969 for (i = 0; i < 8; i++) {
970 NV_INFO(dev, " %s%d: 0x%08x 0x%08x\n",
971 i < 4 ? "DAC" : "SOR", i,
972 nv_rd32(dev, 0x640180 + (i * 0x20)),
973 nv_rd32(dev, 0x660180 + (i * 0x20)));
978 static struct dcb_entry *
979 lookup_dcb(struct drm_device *dev, int id, u32 mc)
981 struct drm_nouveau_private *dev_priv = dev->dev_private;
985 type = OUTPUT_ANALOG;
988 switch (mc & 0x00000f00) {
989 case 0x00000000: type = OUTPUT_LVDS; break;
990 case 0x00000100: type = OUTPUT_TMDS; break;
991 case 0x00000200: type = OUTPUT_TMDS; break;
992 case 0x00000500: type = OUTPUT_TMDS; break;
994 NV_ERROR(dev, "PDISP: unknown SOR mc 0x%08x\n", mc);
1001 for (i = 0; i < dev_priv->vbios.dcb.entries; i++) {
1002 struct dcb_entry *dcb = &dev_priv->vbios.dcb.entry[i];
1003 if (dcb->type == type && (dcb->or & (1 << or)))
1007 NV_ERROR(dev, "PDISP: DCB for %d/0x%08x not found\n", id, mc);
1012 nvd0_display_unk1_handler(struct drm_device *dev)
1014 struct dcb_entry *dcb;
1018 mask = nv_rd32(dev, 0x6101d4);
1021 mask = nv_rd32(dev, 0x6109d4);
1026 for (i = 0; mask && i < 8; i++) {
1027 u32 mcc = nv_rd32(dev, 0x640180 + (i * 0x20));
1028 if (!(mcc & (1 << crtc)))
1031 dcb = lookup_dcb(dev, i, mcc);
1035 nouveau_bios_run_display_table(dev, 0x0000, -1, dcb, crtc);
1038 nv_wr32(dev, 0x6101d4, 0x00000000);
1039 nv_wr32(dev, 0x6109d4, 0x00000000);
1040 nv_wr32(dev, 0x6101d0, 0x80000000);
1044 nvd0_display_unk2_handler(struct drm_device *dev)
1046 struct dcb_entry *dcb;
1047 u32 mask, crtc, pclk;
1051 mask = nv_rd32(dev, 0x6101d4);
1054 mask = nv_rd32(dev, 0x6109d4);
1059 for (i = 0; mask && i < 8; i++) {
1060 u32 mcc = nv_rd32(dev, 0x640180 + (i * 0x20));
1061 if (!(mcc & (1 << crtc)))
1064 dcb = lookup_dcb(dev, i, mcc);
1068 nouveau_bios_run_display_table(dev, 0x0000, -2, dcb, crtc);
1071 pclk = nv_rd32(dev, 0x660450 + (crtc * 0x300)) / 1000;
1072 if (mask & 0x00010000) {
1073 nv50_crtc_set_clock(dev, crtc, pclk);
1076 for (i = 0; mask && i < 8; i++) {
1077 u32 mcp = nv_rd32(dev, 0x660180 + (i * 0x20));
1078 u32 cfg = nv_rd32(dev, 0x660184 + (i * 0x20));
1079 if (!(mcp & (1 << crtc)))
1082 dcb = lookup_dcb(dev, i, mcp);
1085 or = ffs(dcb->or) - 1;
1087 nouveau_bios_run_display_table(dev, cfg, pclk, dcb, crtc);
1089 nv_wr32(dev, 0x612200 + (crtc * 0x800), 0x00000000);
1090 switch (dcb->type) {
1092 nv_wr32(dev, 0x612280 + (or * 0x800), 0x00000000);
1096 if (cfg & 0x00000100)
1101 nv_mask(dev, 0x612300 + (or * 0x800), 0x00000707, tmp);
1110 nv_wr32(dev, 0x6101d4, 0x00000000);
1111 nv_wr32(dev, 0x6109d4, 0x00000000);
1112 nv_wr32(dev, 0x6101d0, 0x80000000);
1116 nvd0_display_unk4_handler(struct drm_device *dev)
1118 struct dcb_entry *dcb;
1122 mask = nv_rd32(dev, 0x6101d4);
1125 mask = nv_rd32(dev, 0x6109d4);
1130 pclk = nv_rd32(dev, 0x660450 + (crtc * 0x300)) / 1000;
1132 for (i = 0; mask && i < 8; i++) {
1133 u32 mcp = nv_rd32(dev, 0x660180 + (i * 0x20));
1134 u32 cfg = nv_rd32(dev, 0x660184 + (i * 0x20));
1135 if (!(mcp & (1 << crtc)))
1138 dcb = lookup_dcb(dev, i, mcp);
1142 nouveau_bios_run_display_table(dev, cfg, -pclk, dcb, crtc);
1145 nv_wr32(dev, 0x6101d4, 0x00000000);
1146 nv_wr32(dev, 0x6109d4, 0x00000000);
1147 nv_wr32(dev, 0x6101d0, 0x80000000);
1151 nvd0_display_bh(unsigned long data)
1153 struct drm_device *dev = (struct drm_device *)data;
1154 struct nvd0_display *disp = nvd0_display(dev);
1156 if (disp->modeset & 0x00000001)
1157 nvd0_display_unk1_handler(dev);
1158 if (disp->modeset & 0x00000002)
1159 nvd0_display_unk2_handler(dev);
1160 if (disp->modeset & 0x00000004)
1161 nvd0_display_unk4_handler(dev);
1165 nvd0_display_intr(struct drm_device *dev)
1167 struct nvd0_display *disp = nvd0_display(dev);
1168 u32 intr = nv_rd32(dev, 0x610088);
1170 if (intr & 0x00000002) {
1171 u32 stat = nv_rd32(dev, 0x61009c);
1172 int chid = ffs(stat) - 1;
1174 u32 mthd = nv_rd32(dev, 0x6101f0 + (chid * 12));
1175 u32 data = nv_rd32(dev, 0x6101f4 + (chid * 12));
1176 u32 unkn = nv_rd32(dev, 0x6101f8 + (chid * 12));
1178 NV_INFO(dev, "EvoCh: chid %d mthd 0x%04x data 0x%08x "
1180 chid, (mthd & 0x0000ffc), data, mthd, unkn);
1181 nv_wr32(dev, 0x61009c, (1 << chid));
1182 nv_wr32(dev, 0x6101f0 + (chid * 12), 0x90000000);
1185 intr &= ~0x00000002;
1188 if (intr & 0x00100000) {
1189 u32 stat = nv_rd32(dev, 0x6100ac);
1191 if (stat & 0x00000007) {
1192 disp->modeset = stat;
1193 tasklet_schedule(&disp->tasklet);
1195 nv_wr32(dev, 0x6100ac, (stat & 0x00000007));
1196 stat &= ~0x00000007;
1200 NV_INFO(dev, "PDISP: unknown intr24 0x%08x\n", stat);
1201 nv_wr32(dev, 0x6100ac, stat);
1204 intr &= ~0x00100000;
1207 if (intr & 0x01000000) {
1208 u32 stat = nv_rd32(dev, 0x6100bc);
1209 nv_wr32(dev, 0x6100bc, stat);
1210 intr &= ~0x01000000;
1213 if (intr & 0x02000000) {
1214 u32 stat = nv_rd32(dev, 0x6108bc);
1215 nv_wr32(dev, 0x6108bc, stat);
1216 intr &= ~0x02000000;
1220 NV_INFO(dev, "PDISP: unknown intr 0x%08x\n", intr);
1223 /******************************************************************************
1225 *****************************************************************************/
1227 nvd0_display_fini(struct drm_device *dev)
1232 for (i = 14; i >= 13; i--) {
1233 if (!(nv_rd32(dev, 0x610490 + (i * 0x10)) & 0x00000001))
1236 nv_mask(dev, 0x610490 + (i * 0x10), 0x00000001, 0x00000000);
1237 nv_wait(dev, 0x610490 + (i * 0x10), 0x00010000, 0x00000000);
1238 nv_mask(dev, 0x610090, 1 << i, 0x00000000);
1239 nv_mask(dev, 0x6100a0, 1 << i, 0x00000000);
1243 if (nv_rd32(dev, 0x610490) & 0x00000010) {
1244 nv_mask(dev, 0x610490, 0x00000010, 0x00000000);
1245 nv_mask(dev, 0x610490, 0x00000003, 0x00000000);
1246 nv_wait(dev, 0x610490, 0x80000000, 0x00000000);
1247 nv_mask(dev, 0x610090, 0x00000001, 0x00000000);
1248 nv_mask(dev, 0x6100a0, 0x00000001, 0x00000000);
1253 nvd0_display_init(struct drm_device *dev)
1255 struct nvd0_display *disp = nvd0_display(dev);
1259 if (nv_rd32(dev, 0x6100ac) & 0x00000100) {
1260 nv_wr32(dev, 0x6100ac, 0x00000100);
1261 nv_mask(dev, 0x6194e8, 0x00000001, 0x00000000);
1262 if (!nv_wait(dev, 0x6194e8, 0x00000002, 0x00000000)) {
1263 NV_ERROR(dev, "PDISP: 0x6194e8 0x%08x\n",
1264 nv_rd32(dev, 0x6194e8));
1269 /* nfi what these are exactly, i do know that SOR_MODE_CTRL won't
1270 * work at all unless you do the SOR part below.
1272 for (i = 0; i < 3; i++) {
1273 u32 dac = nv_rd32(dev, 0x61a000 + (i * 0x800));
1274 nv_wr32(dev, 0x6101c0 + (i * 0x800), dac);
1277 for (i = 0; i < 4; i++) {
1278 u32 sor = nv_rd32(dev, 0x61c000 + (i * 0x800));
1279 nv_wr32(dev, 0x6301c4 + (i * 0x800), sor);
1282 for (i = 0; i < 2; i++) {
1283 u32 crtc0 = nv_rd32(dev, 0x616104 + (i * 0x800));
1284 u32 crtc1 = nv_rd32(dev, 0x616108 + (i * 0x800));
1285 u32 crtc2 = nv_rd32(dev, 0x61610c + (i * 0x800));
1286 nv_wr32(dev, 0x6101b4 + (i * 0x800), crtc0);
1287 nv_wr32(dev, 0x6101b8 + (i * 0x800), crtc1);
1288 nv_wr32(dev, 0x6101bc + (i * 0x800), crtc2);
1291 /* point at our hash table / objects, enable interrupts */
1292 nv_wr32(dev, 0x610010, (disp->mem->vinst >> 8) | 9);
1293 nv_mask(dev, 0x6100b0, 0x00000307, 0x00000307);
1296 nv_wr32(dev, 0x610494, (disp->evo[0].handle >> 8) | 3);
1297 nv_wr32(dev, 0x610498, 0x00010000);
1298 nv_wr32(dev, 0x61049c, 0x00000001);
1299 nv_mask(dev, 0x610490, 0x00000010, 0x00000010);
1300 nv_wr32(dev, 0x640000, 0x00000000);
1301 nv_wr32(dev, 0x610490, 0x01000013);
1302 if (!nv_wait(dev, 0x610490, 0x80000000, 0x00000000)) {
1303 NV_ERROR(dev, "PDISP: master 0x%08x\n",
1304 nv_rd32(dev, 0x610490));
1307 nv_mask(dev, 0x610090, 0x00000001, 0x00000001);
1308 nv_mask(dev, 0x6100a0, 0x00000001, 0x00000001);
1311 for (i = 13; i <= 14; i++) {
1312 nv_wr32(dev, 0x610490 + (i * 0x10), 0x00000001);
1313 if (!nv_wait(dev, 0x610490 + (i * 0x10), 0x00010000, 0x00010000)) {
1314 NV_ERROR(dev, "PDISP: curs%d 0x%08x\n", i,
1315 nv_rd32(dev, 0x610490 + (i * 0x10)));
1319 nv_mask(dev, 0x610090, 1 << i, 1 << i);
1320 nv_mask(dev, 0x6100a0, 1 << i, 1 << i);
1323 push = evo_wait(dev, 0, 32);
1326 evo_mthd(push, 0x0088, 1);
1327 evo_data(push, MEM_SYNC);
1328 evo_mthd(push, 0x0084, 1);
1329 evo_data(push, 0x00000000);
1330 evo_mthd(push, 0x0084, 1);
1331 evo_data(push, 0x80000000);
1332 evo_mthd(push, 0x008c, 1);
1333 evo_data(push, 0x00000000);
1334 evo_kick(push, dev, 0);
1340 nvd0_display_destroy(struct drm_device *dev)
1342 struct drm_nouveau_private *dev_priv = dev->dev_private;
1343 struct nvd0_display *disp = nvd0_display(dev);
1344 struct pci_dev *pdev = dev->pdev;
1346 nvd0_display_fini(dev);
1348 pci_free_consistent(pdev, PAGE_SIZE, disp->evo[0].ptr, disp->evo[0].handle);
1349 nouveau_gpuobj_ref(NULL, &disp->mem);
1350 nouveau_irq_unregister(dev, 26);
1352 dev_priv->engine.display.priv = NULL;
1357 nvd0_display_create(struct drm_device *dev)
1359 struct drm_nouveau_private *dev_priv = dev->dev_private;
1360 struct nouveau_instmem_engine *pinstmem = &dev_priv->engine.instmem;
1361 struct dcb_table *dcb = &dev_priv->vbios.dcb;
1362 struct drm_connector *connector, *tmp;
1363 struct pci_dev *pdev = dev->pdev;
1364 struct nvd0_display *disp;
1365 struct dcb_entry *dcbe;
1368 disp = kzalloc(sizeof(*disp), GFP_KERNEL);
1371 dev_priv->engine.display.priv = disp;
1373 /* create crtc objects to represent the hw heads */
1374 for (i = 0; i < 2; i++) {
1375 ret = nvd0_crtc_create(dev, i);
1380 /* create encoder/connector objects based on VBIOS DCB table */
1381 for (i = 0, dcbe = &dcb->entry[0]; i < dcb->entries; i++, dcbe++) {
1382 connector = nouveau_connector_create(dev, dcbe->connector);
1383 if (IS_ERR(connector))
1386 if (dcbe->location != DCB_LOC_ON_CHIP) {
1387 NV_WARN(dev, "skipping off-chip encoder %d/%d\n",
1388 dcbe->type, ffs(dcbe->or) - 1);
1392 switch (dcbe->type) {
1395 nvd0_sor_create(connector, dcbe);
1398 nvd0_dac_create(connector, dcbe);
1401 NV_WARN(dev, "skipping unsupported encoder %d/%d\n",
1402 dcbe->type, ffs(dcbe->or) - 1);
1407 /* cull any connectors we created that don't have an encoder */
1408 list_for_each_entry_safe(connector, tmp, &dev->mode_config.connector_list, head) {
1409 if (connector->encoder_ids[0])
1412 NV_WARN(dev, "%s has no encoders, removing\n",
1413 drm_get_connector_name(connector));
1414 connector->funcs->destroy(connector);
1417 /* setup interrupt handling */
1418 tasklet_init(&disp->tasklet, nvd0_display_bh, (unsigned long)dev);
1419 nouveau_irq_register(dev, 26, nvd0_display_intr);
1421 /* hash table and dma objects for the memory areas we care about */
1422 ret = nouveau_gpuobj_new(dev, NULL, 0x4000, 0x10000,
1423 NVOBJ_FLAG_ZERO_ALLOC, &disp->mem);
1427 nv_wo32(disp->mem, 0x1000, 0x00000049);
1428 nv_wo32(disp->mem, 0x1004, (disp->mem->vinst + 0x2000) >> 8);
1429 nv_wo32(disp->mem, 0x1008, (disp->mem->vinst + 0x2fff) >> 8);
1430 nv_wo32(disp->mem, 0x100c, 0x00000000);
1431 nv_wo32(disp->mem, 0x1010, 0x00000000);
1432 nv_wo32(disp->mem, 0x1014, 0x00000000);
1433 nv_wo32(disp->mem, 0x0000, MEM_SYNC);
1434 nv_wo32(disp->mem, 0x0004, (0x1000 << 9) | 0x00000001);
1436 nv_wo32(disp->mem, 0x1020, 0x00000049);
1437 nv_wo32(disp->mem, 0x1024, 0x00000000);
1438 nv_wo32(disp->mem, 0x1028, (dev_priv->vram_size - 1) >> 8);
1439 nv_wo32(disp->mem, 0x102c, 0x00000000);
1440 nv_wo32(disp->mem, 0x1030, 0x00000000);
1441 nv_wo32(disp->mem, 0x1034, 0x00000000);
1442 nv_wo32(disp->mem, 0x0008, MEM_VRAM);
1443 nv_wo32(disp->mem, 0x000c, (0x1020 << 9) | 0x00000001);
1445 nv_wo32(disp->mem, 0x1040, 0x00000009);
1446 nv_wo32(disp->mem, 0x1044, 0x00000000);
1447 nv_wo32(disp->mem, 0x1048, (dev_priv->vram_size - 1) >> 8);
1448 nv_wo32(disp->mem, 0x104c, 0x00000000);
1449 nv_wo32(disp->mem, 0x1050, 0x00000000);
1450 nv_wo32(disp->mem, 0x1054, 0x00000000);
1451 nv_wo32(disp->mem, 0x0010, NvEvoVRAM_LP);
1452 nv_wo32(disp->mem, 0x0014, (0x1040 << 9) | 0x00000001);
1454 nv_wo32(disp->mem, 0x1060, 0x0fe00009);
1455 nv_wo32(disp->mem, 0x1064, 0x00000000);
1456 nv_wo32(disp->mem, 0x1068, (dev_priv->vram_size - 1) >> 8);
1457 nv_wo32(disp->mem, 0x106c, 0x00000000);
1458 nv_wo32(disp->mem, 0x1070, 0x00000000);
1459 nv_wo32(disp->mem, 0x1074, 0x00000000);
1460 nv_wo32(disp->mem, 0x0018, NvEvoFB32);
1461 nv_wo32(disp->mem, 0x001c, (0x1060 << 9) | 0x00000001);
1463 pinstmem->flush(dev);
1465 /* push buffers for evo channels */
1467 pci_alloc_consistent(pdev, PAGE_SIZE, &disp->evo[0].handle);
1468 if (!disp->evo[0].ptr) {
1473 ret = nvd0_display_init(dev);
1479 nvd0_display_destroy(dev);