1 /***************************************************************************\
3 |* Copyright 1993-2003 NVIDIA, Corporation. All rights reserved. *|
5 |* NOTICE TO USER: The source code is copyrighted under U.S. and *|
6 |* international laws. Users and possessors of this source code are *|
7 |* hereby granted a nonexclusive, royalty-free copyright license to *|
8 |* use this code in individual and commercial software. *|
10 |* Any use of this source code must include, in the user documenta- *|
11 |* tion and internal comments to the code, notices to the end user *|
14 |* Copyright 1993-2003 NVIDIA, Corporation. All rights reserved. *|
16 |* NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY *|
17 |* OF THIS SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" *|
18 |* WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. NVIDIA, CORPOR- *|
19 |* ATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOURCE CODE, *|
20 |* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE- *|
21 |* MENT, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL *|
22 |* NVIDIA, CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT, INCI- *|
23 |* DENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RE- *|
24 |* SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION *|
25 |* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *|
26 |* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *|
28 |* U.S. Government End Users. This source code is a "commercial *|
29 |* item," as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *|
30 |* consisting of "commercial computer software" and "commercial *|
31 |* computer software documentation," as such terms are used in *|
32 |* 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Govern- *|
33 |* ment only as a commercial end item. Consistent with 48 C.F.R. *|
34 |* 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *|
35 |* all U.S. Government End Users acquire the source code with only *|
36 |* those rights set forth herein. *|
38 \***************************************************************************/
39 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_hw.c,v 1.21 2006/06/16 00:19:33 mvojkovi Exp $ */
47 #include "nv_include.h"
57 VGA_WR08(pNv->PCIO, 0x3D4, 0x1F);
58 VGA_WR08(pNv->PCIO, 0x3D5, Lock ? 0x99 : 0x57);
60 VGA_WR08(pNv->PCIO, 0x3D4, 0x11);
61 cr11 = VGA_RD08(pNv->PCIO, 0x3D5);
62 if(Lock) cr11 |= 0x80;
64 VGA_WR08(pNv->PCIO, 0x3D5, cr11);
67 int NVShowHideCursor (
72 int current = pNv->CurrentState->cursor1;
74 pNv->CurrentState->cursor1 = (pNv->CurrentState->cursor1 & 0xFE) |
76 VGA_WR08(pNv->PCIO, 0x3D4, 0x31);
77 VGA_WR08(pNv->PCIO, 0x3D5, pNv->CurrentState->cursor1);
79 if(pNv->Architecture == NV_ARCH_40) { /* HW bug */
80 volatile CARD32 curpos = pNv->PRAMDAC[0x0300/4];
81 pNv->PRAMDAC[0x0300/4] = curpos;
84 return (current & 0x01);
87 /****************************************************************************\
89 * The video arbitration routines calculate some "magic" numbers. Fixes *
90 * the snow seen when accessing the framebuffer without it. *
91 * It just works (I hope). *
93 \****************************************************************************/
98 int graphics_burst_size;
120 int graphics_burst_size;
121 int video_burst_size;
141 static void nvGetClocks(NVPtr pNv, unsigned int *MClk, unsigned int *NVClk)
143 unsigned int pll, N, M, MB, NB, P;
145 if(pNv->Architecture >= NV_ARCH_40) {
146 pll = pNv->PMC[0x4020/4];
147 P = (pll >> 16) & 0x07;
148 pll = pNv->PMC[0x4024/4];
150 N = (pll >> 8) & 0xFF;
151 if(((pNv->Chipset & 0xfff0) == 0x0290) ||
152 ((pNv->Chipset & 0xfff0) == 0x0390))
157 MB = (pll >> 16) & 0xFF;
158 NB = (pll >> 24) & 0xFF;
160 *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
162 pll = pNv->PMC[0x4000/4];
163 P = (pll >> 16) & 0x07;
164 pll = pNv->PMC[0x4004/4];
166 N = (pll >> 8) & 0xFF;
167 MB = (pll >> 16) & 0xFF;
168 NB = (pll >> 24) & 0xFF;
170 *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
172 if(pNv->twoStagePLL) {
173 pll = pNv->PRAMDAC0[0x0504/4];
175 N = (pll >> 8) & 0xFF;
176 P = (pll >> 16) & 0x0F;
177 pll = pNv->PRAMDAC0[0x0574/4];
178 if(pll & 0x80000000) {
180 NB = (pll >> 8) & 0xFF;
185 *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
187 pll = pNv->PRAMDAC0[0x0500/4];
189 N = (pll >> 8) & 0xFF;
190 P = (pll >> 16) & 0x0F;
191 pll = pNv->PRAMDAC0[0x0570/4];
192 if(pll & 0x80000000) {
194 NB = (pll >> 8) & 0xFF;
199 *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
201 if(((pNv->Chipset & 0x0ff0) == 0x0300) ||
202 ((pNv->Chipset & 0x0ff0) == 0x0330))
204 pll = pNv->PRAMDAC0[0x0504/4];
206 N = (pll >> 8) & 0xFF;
207 P = (pll >> 16) & 0x07;
208 if(pll & 0x00000080) {
209 MB = (pll >> 4) & 0x07;
210 NB = (pll >> 19) & 0x1f;
215 *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
217 pll = pNv->PRAMDAC0[0x0500/4];
219 N = (pll >> 8) & 0xFF;
220 P = (pll >> 16) & 0x07;
221 if(pll & 0x00000080) {
222 MB = (pll >> 4) & 0x07;
223 NB = (pll >> 19) & 0x1f;
228 *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
230 pll = pNv->PRAMDAC0[0x0504/4];
232 N = (pll >> 8) & 0xFF;
233 P = (pll >> 16) & 0x0F;
234 *MClk = (N * pNv->CrystalFreqKHz / M) >> P;
236 pll = pNv->PRAMDAC0[0x0500/4];
238 N = (pll >> 8) & 0xFF;
239 P = (pll >> 16) & 0x0F;
240 *NVClk = (N * pNv->CrystalFreqKHz / M) >> P;
244 ErrorF("NVClock = %i MHz, MEMClock = %i MHz\n", *NVClk/1000, *MClk/1000);
249 static void nv4CalcArbitration (
254 int data, pagemiss, cas,width, video_enable, bpp;
255 int nvclks, mclks, pclks, vpagemiss, crtpagemiss, vbs;
256 int found, mclk_extra, mclk_loop, cbs, m1, p1;
257 int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
258 int us_m, us_n, us_p, video_drain_rate, crtc_drain_rate;
259 int vpm_us, us_video, vlwm, video_fill_us, cpm_us, us_crt,clwm;
262 pclk_freq = arb->pclk_khz;
263 mclk_freq = arb->mclk_khz;
264 nvclk_freq = arb->nvclk_khz;
265 pagemiss = arb->mem_page_miss;
266 cas = arb->mem_latency;
267 width = arb->memory_width >> 6;
268 video_enable = arb->enable_video;
270 mp_enable = arb->enable_mp;
301 mclk_loop = mclks+mclk_extra;
302 us_m = mclk_loop *1000*1000 / mclk_freq;
303 us_n = nvclks*1000*1000 / nvclk_freq;
304 us_p = nvclks*1000*1000 / pclk_freq;
307 video_drain_rate = pclk_freq * 2;
308 crtc_drain_rate = pclk_freq * bpp/8;
312 vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
313 if (nvclk_freq * 2 > mclk_freq * width)
314 video_fill_us = cbs*1000*1000 / 16 / nvclk_freq ;
316 video_fill_us = cbs*1000*1000 / (8 * width) / mclk_freq;
317 us_video = vpm_us + us_m + us_n + us_p + video_fill_us;
318 vlwm = us_video * video_drain_rate/(1000*1000);
321 if (vlwm > 128) vbs = 64;
322 if (vlwm > (256-64)) vbs = 32;
323 if (nvclk_freq * 2 > mclk_freq * width)
324 video_fill_us = vbs *1000*1000/ 16 / nvclk_freq ;
326 video_fill_us = vbs*1000*1000 / (8 * width) / mclk_freq;
327 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
334 clwm = us_crt * crtc_drain_rate/(1000*1000);
339 crtc_drain_rate = pclk_freq * bpp/8;
342 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
343 us_crt = cpm_us + us_m + us_n + us_p ;
344 clwm = us_crt * crtc_drain_rate/(1000*1000);
347 m1 = clwm + cbs - 512;
348 p1 = m1 * pclk_freq / mclk_freq;
350 if ((p1 < m1) && (m1 > 0))
354 if (mclk_extra ==0) found = 1;
357 else if (video_enable)
359 if ((clwm > 511) || (vlwm > 255))
363 if (mclk_extra ==0) found = 1;
373 if (mclk_extra ==0) found = 1;
377 if (clwm < 384) clwm = 384;
378 if (vlwm < 128) vlwm = 128;
380 fifo->graphics_lwm = data;
381 fifo->graphics_burst_size = 128;
382 data = (int)((vlwm+15));
383 fifo->video_lwm = data;
384 fifo->video_burst_size = vbs;
388 static void nv4UpdateArbitrationSettings (
396 nv4_fifo_info fifo_data;
397 nv4_sim_state sim_data;
398 unsigned int MClk, NVClk, cfg1;
400 nvGetClocks(pNv, &MClk, &NVClk);
402 cfg1 = pNv->PFB[0x00000204/4];
403 sim_data.pix_bpp = (char)pixelDepth;
404 sim_data.enable_video = 0;
405 sim_data.enable_mp = 0;
406 sim_data.memory_width = (pNv->PEXTDEV[0x0000/4] & 0x10) ? 128 : 64;
407 sim_data.mem_latency = (char)cfg1 & 0x0F;
408 sim_data.mem_aligned = 1;
409 sim_data.mem_page_miss = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
410 sim_data.gr_during_vid = 0;
411 sim_data.pclk_khz = VClk;
412 sim_data.mclk_khz = MClk;
413 sim_data.nvclk_khz = NVClk;
414 nv4CalcArbitration(&fifo_data, &sim_data);
417 int b = fifo_data.graphics_burst_size >> 4;
419 while (b >>= 1) (*burst)++;
420 *lwm = fifo_data.graphics_lwm >> 3;
424 static void nv10CalcArbitration (
425 nv10_fifo_info *fifo,
429 int data, pagemiss, width, video_enable, bpp;
430 int nvclks, mclks, pclks, vpagemiss, crtpagemiss;
432 int found, mclk_extra, mclk_loop, cbs, m1;
433 int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
434 int us_m, us_m_min, us_n, us_p, crtc_drain_rate;
436 int vpm_us, us_video, cpm_us, us_crt,clwm;
438 int m2us, us_pipe_min, p1clk, p2;
440 int us_min_mclk_extra;
443 pclk_freq = arb->pclk_khz; /* freq in KHz */
444 mclk_freq = arb->mclk_khz;
445 nvclk_freq = arb->nvclk_khz;
446 pagemiss = arb->mem_page_miss;
447 width = arb->memory_width/64;
448 video_enable = arb->enable_video;
450 mp_enable = arb->enable_mp;
455 pclks = 4; /* lwm detect. */
457 nvclks = 3; /* lwm -> sync. */
458 nvclks += 2; /* fbi bus cycles (1 req + 1 busy) */
460 mclks = 1; /* 2 edge sync. may be very close to edge so just put one. */
462 mclks += 1; /* arb_hp_req */
463 mclks += 5; /* ap_hp_req tiling pipeline */
465 mclks += 2; /* tc_req latency fifo */
466 mclks += 2; /* fb_cas_n_ memory request to fbio block */
467 mclks += 7; /* sm_d_rdv data returned from fbio block */
469 /* fb.rd.d.Put_gc need to accumulate 256 bits for read */
470 if (arb->memory_type == 0)
471 if (arb->memory_width == 64) /* 64 bit bus */
476 if (arb->memory_width == 64) /* 64 bit bus */
481 if ((!video_enable) && (arb->memory_width == 128))
483 mclk_extra = (bpp == 32) ? 31 : 42; /* Margin of error */
488 mclk_extra = (bpp == 32) ? 8 : 4; /* Margin of error */
489 /* mclk_extra = 4; */ /* Margin of error */
493 nvclks += 1; /* 2 edge sync. may be very close to edge so just put one. */
494 nvclks += 1; /* fbi_d_rdv_n */
495 nvclks += 1; /* Fbi_d_rdata */
496 nvclks += 1; /* crtfifo load */
499 mclks+=4; /* Mp can get in with a burst of 8. */
500 /* Extra clocks determined by heuristics */
508 mclk_loop = mclks+mclk_extra;
509 us_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
510 us_m_min = mclks * 1000*1000 / mclk_freq; /* Minimum Mclk latency in us */
511 us_min_mclk_extra = min_mclk_extra *1000*1000 / mclk_freq;
512 us_n = nvclks*1000*1000 / nvclk_freq;/* nvclk latency in us */
513 us_p = pclks*1000*1000 / pclk_freq;/* nvclk latency in us */
514 us_pipe_min = us_m_min + us_n + us_p;
516 vus_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
519 crtc_drain_rate = pclk_freq * bpp/8; /* MB/s */
521 vpagemiss = 1; /* self generating page miss */
522 vpagemiss += 1; /* One higher priority before */
524 crtpagemiss = 2; /* self generating page miss */
526 crtpagemiss += 1; /* if MA0 conflict */
528 vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
530 us_video = vpm_us + vus_m; /* Video has separate read return path */
532 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
534 us_video /* Wait for video */
535 +cpm_us /* CRT Page miss */
536 +us_m + us_n +us_p /* other latency */
539 clwm = us_crt * crtc_drain_rate/(1000*1000);
540 clwm++; /* fixed point <= float_point - 1. Fixes that */
542 crtc_drain_rate = pclk_freq * bpp/8; /* bpp * pclk/8 */
544 crtpagemiss = 1; /* self generating page miss */
545 crtpagemiss += 1; /* MA0 page miss */
547 crtpagemiss += 1; /* if MA0 conflict */
548 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
549 us_crt = cpm_us + us_m + us_n + us_p ;
550 clwm = us_crt * crtc_drain_rate/(1000*1000);
551 clwm++; /* fixed point <= float_point - 1. Fixes that */
553 /* Finally, a heuristic check when width == 64 bits */
555 nvclk_fill = nvclk_freq * 8;
556 if(crtc_drain_rate * 100 >= nvclk_fill * 102)
557 clwm = 0xfff; /*Large number to fail */
559 else if(crtc_drain_rate * 100 >= nvclk_fill * 98) {
572 clwm_rnd_down = ((int)clwm/8)*8;
573 if (clwm_rnd_down < clwm)
576 m1 = clwm + cbs - 1024; /* Amount of overfill */
577 m2us = us_pipe_min + us_min_mclk_extra;
579 /* pclk cycles to drain */
580 p1clk = m2us * pclk_freq/(1000*1000);
581 p2 = p1clk * bpp / 8; /* bytes drained. */
583 if((p2 < m1) && (m1 > 0)) {
586 if(min_mclk_extra == 0) {
588 found = 1; /* Can't adjust anymore! */
590 cbs = cbs/2; /* reduce the burst size */
596 if (clwm > 1023){ /* Have some margin */
599 if(min_mclk_extra == 0)
600 found = 1; /* Can't adjust anymore! */
606 if(clwm < (1024-cbs+8)) clwm = 1024-cbs+8;
608 /* printf("CRT LWM: %f bytes, prog: 0x%x, bs: 256\n", clwm, data ); */
609 fifo->graphics_lwm = data; fifo->graphics_burst_size = cbs;
611 fifo->video_lwm = 1024; fifo->video_burst_size = 512;
615 static void nv10UpdateArbitrationSettings (
623 nv10_fifo_info fifo_data;
624 nv10_sim_state sim_data;
625 unsigned int MClk, NVClk, cfg1;
627 nvGetClocks(pNv, &MClk, &NVClk);
629 cfg1 = pNv->PFB[0x0204/4];
630 sim_data.pix_bpp = (char)pixelDepth;
631 sim_data.enable_video = 1;
632 sim_data.enable_mp = 0;
633 sim_data.memory_type = (pNv->PFB[0x0200/4] & 0x01) ? 1 : 0;
634 sim_data.memory_width = (pNv->PEXTDEV[0x0000/4] & 0x10) ? 128 : 64;
635 sim_data.mem_latency = (char)cfg1 & 0x0F;
636 sim_data.mem_aligned = 1;
637 sim_data.mem_page_miss = (char)(((cfg1>>4) &0x0F) + ((cfg1>>31) & 0x01));
638 sim_data.gr_during_vid = 0;
639 sim_data.pclk_khz = VClk;
640 sim_data.mclk_khz = MClk;
641 sim_data.nvclk_khz = NVClk;
642 nv10CalcArbitration(&fifo_data, &sim_data);
643 if (fifo_data.valid) {
644 int b = fifo_data.graphics_burst_size >> 4;
646 while (b >>= 1) (*burst)++;
647 *lwm = fifo_data.graphics_lwm >> 3;
652 static void nv30UpdateArbitrationSettings (
658 unsigned int MClk, NVClk;
659 unsigned int fifo_size, burst_size, graphics_lwm;
663 graphics_lwm = fifo_size - burst_size;
665 nvGetClocks(pNv, &MClk, &NVClk);
669 while(burst_size >>= 1) (*burst)++;
670 *lwm = graphics_lwm >> 3;
673 static void nForceUpdateArbitrationSettings (
681 nv10_fifo_info fifo_data;
682 nv10_sim_state sim_data;
683 unsigned int M, N, P, pll, MClk, NVClk, memctrl;
685 if((pNv->Chipset & 0x0FF0) == 0x01A0) {
686 unsigned int uMClkPostDiv;
688 uMClkPostDiv = (pciReadLong(pciTag(0, 0, 3), 0x6C) >> 8) & 0xf;
689 if(!uMClkPostDiv) uMClkPostDiv = 4;
690 MClk = 400000 / uMClkPostDiv;
692 MClk = pciReadLong(pciTag(0, 0, 5), 0x4C) / 1000;
695 pll = pNv->PRAMDAC0[0x0500/4];
696 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
697 NVClk = (N * pNv->CrystalFreqKHz / M) >> P;
698 sim_data.pix_bpp = (char)pixelDepth;
699 sim_data.enable_video = 0;
700 sim_data.enable_mp = 0;
701 sim_data.memory_type = (pciReadLong(pciTag(0, 0, 1), 0x7C) >> 12) & 1;
702 sim_data.memory_width = 64;
704 memctrl = pciReadLong(pciTag(0, 0, 3), 0x00) >> 16;
706 if((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) {
709 dimm[0] = (pciReadLong(pciTag(0, 0, 2), 0x40) >> 8) & 0x4F;
710 dimm[1] = (pciReadLong(pciTag(0, 0, 2), 0x44) >> 8) & 0x4F;
711 dimm[2] = (pciReadLong(pciTag(0, 0, 2), 0x48) >> 8) & 0x4F;
713 if((dimm[0] + dimm[1]) != dimm[2]) {
715 "your nForce DIMMs are not arranged in optimal banks!\n");
719 sim_data.mem_latency = 3;
720 sim_data.mem_aligned = 1;
721 sim_data.mem_page_miss = 10;
722 sim_data.gr_during_vid = 0;
723 sim_data.pclk_khz = VClk;
724 sim_data.mclk_khz = MClk;
725 sim_data.nvclk_khz = NVClk;
726 nv10CalcArbitration(&fifo_data, &sim_data);
729 int b = fifo_data.graphics_burst_size >> 4;
731 while (b >>= 1) (*burst)++;
732 *lwm = fifo_data.graphics_lwm >> 3;
737 /****************************************************************************\
739 * RIVA Mode State Routines *
741 \****************************************************************************/
744 * Calculate the Video Clock parameters for the PLL.
746 static void CalcVClock (
753 unsigned lowM, highM;
754 unsigned DeltaNew, DeltaOld;
758 DeltaOld = 0xFFFFFFFF;
760 VClk = (unsigned)clockIn;
762 if (pNv->CrystalFreqKHz == 13500) {
770 for (P = 0; P <= 4; P++) {
772 if ((Freq >= 128000) && (Freq <= 350000)) {
773 for (M = lowM; M <= highM; M++) {
774 N = ((VClk << P) * M) / pNv->CrystalFreqKHz;
776 Freq = ((pNv->CrystalFreqKHz * N) / M) >> P;
778 DeltaNew = Freq - VClk;
780 DeltaNew = VClk - Freq;
781 if (DeltaNew < DeltaOld) {
782 *pllOut = (P << 16) | (N << 8) | M;
792 static void CalcVClock2Stage (
800 unsigned DeltaNew, DeltaOld;
804 DeltaOld = 0xFFFFFFFF;
806 *pllBOut = 0x80000401; /* fixed at x4 for now */
808 VClk = (unsigned)clockIn;
810 for (P = 0; P <= 6; P++) {
812 if ((Freq >= 400000) && (Freq <= 1000000)) {
813 for (M = 1; M <= 13; M++) {
814 N = ((VClk << P) * M) / (pNv->CrystalFreqKHz << 2);
815 if((N >= 5) && (N <= 255)) {
816 Freq = (((pNv->CrystalFreqKHz << 2) * N) / M) >> P;
818 DeltaNew = Freq - VClk;
820 DeltaNew = VClk - Freq;
821 if (DeltaNew < DeltaOld) {
822 *pllOut = (P << 16) | (N << 8) | M;
833 * Calculate extended mode parameters (SVGA) and save in a
834 * mode state structure.
836 void NVCalcStateExt (
838 RIVA_HW_STATE *state,
847 int pixelDepth, VClk;
849 * Save mode parameters.
851 state->bpp = bpp; /* this is not bitsPerPixel, it's 8,15,16,32 */
852 state->width = width;
853 state->height = height;
855 * Extended RIVA registers.
857 pixelDepth = (bpp + 1)/8;
859 CalcVClock2Stage(dotClock, &VClk, &state->pll, &state->pllB, pNv);
861 CalcVClock(dotClock, &VClk, &state->pll, pNv);
863 switch (pNv->Architecture)
866 nv4UpdateArbitrationSettings(VClk,
868 &(state->arbitration0),
869 &(state->arbitration1),
871 state->cursor0 = 0x00;
872 state->cursor1 = 0xbC;
873 if (flags & V_DBLSCAN)
875 state->cursor2 = 0x00000000;
876 state->pllsel = 0x10000700;
877 state->config = 0x00001114;
878 state->general = bpp == 16 ? 0x00101100 : 0x00100100;
879 state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
885 if(((pNv->Chipset & 0xfff0) == 0x0240) ||
886 ((pNv->Chipset & 0xfff0) == 0x03D0))
888 state->arbitration0 = 128;
889 state->arbitration1 = 0x0480;
891 if(((pNv->Chipset & 0xffff) == 0x01A0) ||
892 ((pNv->Chipset & 0xffff) == 0x01f0))
894 nForceUpdateArbitrationSettings(VClk,
896 &(state->arbitration0),
897 &(state->arbitration1),
899 } else if(pNv->Architecture < NV_ARCH_30) {
900 nv10UpdateArbitrationSettings(VClk,
902 &(state->arbitration0),
903 &(state->arbitration1),
906 nv30UpdateArbitrationSettings(pNv,
907 &(state->arbitration0),
908 &(state->arbitration1));
910 state->cursor0 = 0x80 | (pNv->CursorStart >> 17);
911 state->cursor1 = (pNv->CursorStart >> 11) << 2;
912 state->cursor2 = pNv->CursorStart >> 24;
913 if (flags & V_DBLSCAN)
915 state->pllsel = 0x10000700;
916 state->config = pNv->PFB[0x00000200/4];
917 state->general = bpp == 16 ? 0x00101100 : 0x00100100;
918 state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
922 if(bpp != 8) /* DirectColor */
923 state->general |= 0x00000030;
925 state->repaint0 = (((width / 8) * pixelDepth) & 0x700) >> 3;
926 state->pixel = (pixelDepth > 2) ? 3 : pixelDepth;
930 void NVLoadStateExt (
937 pNv->PMC[0x0140/4] = 0x00000000;
938 pNv->PMC[0x0200/4] = 0xFFFF00FF;
939 pNv->PMC[0x0200/4] = 0xFFFFFFFF;
941 pNv->PTIMER[0x0200] = 0x00000008;
942 pNv->PTIMER[0x0210] = 0x00000003;
943 pNv->PTIMER[0x0140] = 0x00000000;
944 pNv->PTIMER[0x0100] = 0xFFFFFFFF;
946 if(pNv->Architecture == NV_ARCH_04) {
947 pNv->PFB[0x0200/4] = state->config;
949 if((pNv->Architecture < NV_ARCH_40) ||
950 ((pNv->Chipset & 0xfff0) == 0x0040))
952 for(i = 0; i < 8; i++) {
953 pNv->PFB[(0x0240 + (i * 0x10))/4] = 0;
954 pNv->PFB[(0x0244 + (i * 0x10))/4] = pNv->FbMapSize - 1;
959 if(((pNv->Chipset & 0xfff0) == 0x0090) ||
960 ((pNv->Chipset & 0xfff0) == 0x01D0) ||
961 ((pNv->Chipset & 0xfff0) == 0x0290) ||
962 ((pNv->Chipset & 0xfff0) == 0x0390) ||
963 ((pNv->Chipset & 0xfff0) == 0x03D0))
968 for(i = 0; i < regions; i++) {
969 pNv->PFB[(0x0600 + (i * 0x10))/4] = 0;
970 pNv->PFB[(0x0604 + (i * 0x10))/4] = pNv->FbMapSize - 1;
974 if(pNv->Architecture >= NV_ARCH_40) {
975 pNv->PRAMIN[0x0000] = 0x80000010;
976 pNv->PRAMIN[0x0001] = 0x00101202;
977 pNv->PRAMIN[0x0002] = 0x80000011;
978 pNv->PRAMIN[0x0003] = 0x00101204;
979 pNv->PRAMIN[0x0004] = 0x80000012;
980 pNv->PRAMIN[0x0005] = 0x00101206;
981 pNv->PRAMIN[0x0006] = 0x80000013;
982 pNv->PRAMIN[0x0007] = 0x00101208;
983 pNv->PRAMIN[0x0008] = 0x80000014;
984 pNv->PRAMIN[0x0009] = 0x0010120A;
985 pNv->PRAMIN[0x000A] = 0x80000015;
986 pNv->PRAMIN[0x000B] = 0x0010120C;
987 pNv->PRAMIN[0x000C] = 0x80000016;
988 pNv->PRAMIN[0x000D] = 0x0010120E;
989 pNv->PRAMIN[0x000E] = 0x80000017;
990 pNv->PRAMIN[0x000F] = 0x00101210;
991 pNv->PRAMIN[0x0800] = 0x00003000;
992 pNv->PRAMIN[0x0801] = pNv->FbMapSize - 1;
993 pNv->PRAMIN[0x0802] = 0x00000002;
994 pNv->PRAMIN[0x0808] = 0x02080062;
995 pNv->PRAMIN[0x0809] = 0x00000000;
996 pNv->PRAMIN[0x080A] = 0x00001200;
997 pNv->PRAMIN[0x080B] = 0x00001200;
998 pNv->PRAMIN[0x080C] = 0x00000000;
999 pNv->PRAMIN[0x080D] = 0x00000000;
1000 pNv->PRAMIN[0x0810] = 0x02080043;
1001 pNv->PRAMIN[0x0811] = 0x00000000;
1002 pNv->PRAMIN[0x0812] = 0x00000000;
1003 pNv->PRAMIN[0x0813] = 0x00000000;
1004 pNv->PRAMIN[0x0814] = 0x00000000;
1005 pNv->PRAMIN[0x0815] = 0x00000000;
1006 pNv->PRAMIN[0x0818] = 0x02080044;
1007 pNv->PRAMIN[0x0819] = 0x02000000;
1008 pNv->PRAMIN[0x081A] = 0x00000000;
1009 pNv->PRAMIN[0x081B] = 0x00000000;
1010 pNv->PRAMIN[0x081C] = 0x00000000;
1011 pNv->PRAMIN[0x081D] = 0x00000000;
1012 pNv->PRAMIN[0x0820] = 0x02080019;
1013 pNv->PRAMIN[0x0821] = 0x00000000;
1014 pNv->PRAMIN[0x0822] = 0x00000000;
1015 pNv->PRAMIN[0x0823] = 0x00000000;
1016 pNv->PRAMIN[0x0824] = 0x00000000;
1017 pNv->PRAMIN[0x0825] = 0x00000000;
1018 pNv->PRAMIN[0x0828] = 0x020A005C;
1019 pNv->PRAMIN[0x0829] = 0x00000000;
1020 pNv->PRAMIN[0x082A] = 0x00000000;
1021 pNv->PRAMIN[0x082B] = 0x00000000;
1022 pNv->PRAMIN[0x082C] = 0x00000000;
1023 pNv->PRAMIN[0x082D] = 0x00000000;
1024 pNv->PRAMIN[0x0830] = 0x0208009F;
1025 pNv->PRAMIN[0x0831] = 0x00000000;
1026 pNv->PRAMIN[0x0832] = 0x00001200;
1027 pNv->PRAMIN[0x0833] = 0x00001200;
1028 pNv->PRAMIN[0x0834] = 0x00000000;
1029 pNv->PRAMIN[0x0835] = 0x00000000;
1030 pNv->PRAMIN[0x0838] = 0x0208004A;
1031 pNv->PRAMIN[0x0839] = 0x02000000;
1032 pNv->PRAMIN[0x083A] = 0x00000000;
1033 pNv->PRAMIN[0x083B] = 0x00000000;
1034 pNv->PRAMIN[0x083C] = 0x00000000;
1035 pNv->PRAMIN[0x083D] = 0x00000000;
1036 pNv->PRAMIN[0x0840] = 0x02080077;
1037 pNv->PRAMIN[0x0841] = 0x00000000;
1038 pNv->PRAMIN[0x0842] = 0x00001200;
1039 pNv->PRAMIN[0x0843] = 0x00001200;
1040 pNv->PRAMIN[0x0844] = 0x00000000;
1041 pNv->PRAMIN[0x0845] = 0x00000000;
1042 pNv->PRAMIN[0x084C] = 0x00003002;
1043 pNv->PRAMIN[0x084D] = 0x00007FFF;
1044 pNv->PRAMIN[0x084E] = pNv->FbUsableSize | 0x00000002;
1046 #if X_BYTE_ORDER == X_BIG_ENDIAN
1047 pNv->PRAMIN[0x080A] |= 0x01000000;
1048 pNv->PRAMIN[0x0812] |= 0x01000000;
1049 pNv->PRAMIN[0x081A] |= 0x01000000;
1050 pNv->PRAMIN[0x0822] |= 0x01000000;
1051 pNv->PRAMIN[0x082A] |= 0x01000000;
1052 pNv->PRAMIN[0x0832] |= 0x01000000;
1053 pNv->PRAMIN[0x083A] |= 0x01000000;
1054 pNv->PRAMIN[0x0842] |= 0x01000000;
1055 pNv->PRAMIN[0x0819] = 0x01000000;
1056 pNv->PRAMIN[0x0839] = 0x01000000;
1059 pNv->PRAMIN[0x0000] = 0x80000010;
1060 pNv->PRAMIN[0x0001] = 0x80011201;
1061 pNv->PRAMIN[0x0002] = 0x80000011;
1062 pNv->PRAMIN[0x0003] = 0x80011202;
1063 pNv->PRAMIN[0x0004] = 0x80000012;
1064 pNv->PRAMIN[0x0005] = 0x80011203;
1065 pNv->PRAMIN[0x0006] = 0x80000013;
1066 pNv->PRAMIN[0x0007] = 0x80011204;
1067 pNv->PRAMIN[0x0008] = 0x80000014;
1068 pNv->PRAMIN[0x0009] = 0x80011205;
1069 pNv->PRAMIN[0x000A] = 0x80000015;
1070 pNv->PRAMIN[0x000B] = 0x80011206;
1071 pNv->PRAMIN[0x000C] = 0x80000016;
1072 pNv->PRAMIN[0x000D] = 0x80011207;
1073 pNv->PRAMIN[0x000E] = 0x80000017;
1074 pNv->PRAMIN[0x000F] = 0x80011208;
1075 pNv->PRAMIN[0x0800] = 0x00003000;
1076 pNv->PRAMIN[0x0801] = pNv->FbMapSize - 1;
1077 pNv->PRAMIN[0x0802] = 0x00000002;
1078 pNv->PRAMIN[0x0803] = 0x00000002;
1079 if(pNv->Architecture >= NV_ARCH_10)
1080 pNv->PRAMIN[0x0804] = 0x01008062;
1082 pNv->PRAMIN[0x0804] = 0x01008042;
1083 pNv->PRAMIN[0x0805] = 0x00000000;
1084 pNv->PRAMIN[0x0806] = 0x12001200;
1085 pNv->PRAMIN[0x0807] = 0x00000000;
1086 pNv->PRAMIN[0x0808] = 0x01008043;
1087 pNv->PRAMIN[0x0809] = 0x00000000;
1088 pNv->PRAMIN[0x080A] = 0x00000000;
1089 pNv->PRAMIN[0x080B] = 0x00000000;
1090 pNv->PRAMIN[0x080C] = 0x01008044;
1091 pNv->PRAMIN[0x080D] = 0x00000002;
1092 pNv->PRAMIN[0x080E] = 0x00000000;
1093 pNv->PRAMIN[0x080F] = 0x00000000;
1094 pNv->PRAMIN[0x0810] = 0x01008019;
1095 pNv->PRAMIN[0x0811] = 0x00000000;
1096 pNv->PRAMIN[0x0812] = 0x00000000;
1097 pNv->PRAMIN[0x0813] = 0x00000000;
1098 pNv->PRAMIN[0x0814] = 0x0100A05C;
1099 pNv->PRAMIN[0x0815] = 0x00000000;
1100 pNv->PRAMIN[0x0816] = 0x00000000;
1101 pNv->PRAMIN[0x0817] = 0x00000000;
1102 if(pNv->WaitVSyncPossible)
1103 pNv->PRAMIN[0x0818] = 0x0100809F;
1105 pNv->PRAMIN[0x0818] = 0x0100805F;
1106 pNv->PRAMIN[0x0819] = 0x00000000;
1107 pNv->PRAMIN[0x081A] = 0x12001200;
1108 pNv->PRAMIN[0x081B] = 0x00000000;
1109 pNv->PRAMIN[0x081C] = 0x0100804A;
1110 pNv->PRAMIN[0x081D] = 0x00000002;
1111 pNv->PRAMIN[0x081E] = 0x00000000;
1112 pNv->PRAMIN[0x081F] = 0x00000000;
1113 pNv->PRAMIN[0x0820] = 0x01018077;
1114 pNv->PRAMIN[0x0821] = 0x00000000;
1115 pNv->PRAMIN[0x0822] = 0x12001200;
1116 pNv->PRAMIN[0x0823] = 0x00000000;
1117 pNv->PRAMIN[0x0824] = 0x00003002;
1118 pNv->PRAMIN[0x0825] = 0x00007FFF;
1119 pNv->PRAMIN[0x0826] = pNv->FbUsableSize | 0x00000002;
1120 pNv->PRAMIN[0x0827] = 0x00000002;
1122 #if X_BYTE_ORDER == X_BIG_ENDIAN
1123 pNv->PRAMIN[0x0804] |= 0x00080000;
1124 pNv->PRAMIN[0x0808] |= 0x00080000;
1125 pNv->PRAMIN[0x080C] |= 0x00080000;
1126 pNv->PRAMIN[0x0810] |= 0x00080000;
1127 pNv->PRAMIN[0x0814] |= 0x00080000;
1128 pNv->PRAMIN[0x0818] |= 0x00080000;
1129 pNv->PRAMIN[0x081C] |= 0x00080000;
1130 pNv->PRAMIN[0x0820] |= 0x00080000;
1131 pNv->PRAMIN[0x080D] = 0x00000001;
1132 pNv->PRAMIN[0x081D] = 0x00000001;
1136 if(pNv->Architecture < NV_ARCH_10) {
1137 if((pNv->Chipset & 0x0fff) == 0x0020) {
1138 pNv->PRAMIN[0x0824] |= 0x00020000;
1139 pNv->PRAMIN[0x0826] += pNv->FbAddress;
1141 pNv->PGRAPH[0x0080/4] = 0x000001FF;
1142 pNv->PGRAPH[0x0080/4] = 0x1230C000;
1143 pNv->PGRAPH[0x0084/4] = 0x72111101;
1144 pNv->PGRAPH[0x0088/4] = 0x11D5F071;
1145 pNv->PGRAPH[0x008C/4] = 0x0004FF31;
1146 pNv->PGRAPH[0x008C/4] = 0x4004FF31;
1148 pNv->PGRAPH[0x0140/4] = 0x00000000;
1149 pNv->PGRAPH[0x0100/4] = 0xFFFFFFFF;
1150 pNv->PGRAPH[0x0170/4] = 0x10010100;
1151 pNv->PGRAPH[0x0710/4] = 0xFFFFFFFF;
1152 pNv->PGRAPH[0x0720/4] = 0x00000001;
1154 pNv->PGRAPH[0x0810/4] = 0x00000000;
1155 pNv->PGRAPH[0x0608/4] = 0xFFFFFFFF;
1157 pNv->PGRAPH[0x0080/4] = 0xFFFFFFFF;
1158 pNv->PGRAPH[0x0080/4] = 0x00000000;
1160 pNv->PGRAPH[0x0140/4] = 0x00000000;
1161 pNv->PGRAPH[0x0100/4] = 0xFFFFFFFF;
1162 pNv->PGRAPH[0x0144/4] = 0x10010100;
1163 pNv->PGRAPH[0x0714/4] = 0xFFFFFFFF;
1164 pNv->PGRAPH[0x0720/4] = 0x00000001;
1165 pNv->PGRAPH[0x0710/4] &= 0x0007ff00;
1166 pNv->PGRAPH[0x0710/4] |= 0x00020100;
1168 if(pNv->Architecture == NV_ARCH_10) {
1169 pNv->PGRAPH[0x0084/4] = 0x00118700;
1170 pNv->PGRAPH[0x0088/4] = 0x24E00810;
1171 pNv->PGRAPH[0x008C/4] = 0x55DE0030;
1173 for(i = 0; i < 32; i++)
1174 pNv->PGRAPH[(0x0B00/4) + i] = pNv->PFB[(0x0240/4) + i];
1176 pNv->PGRAPH[0x640/4] = 0;
1177 pNv->PGRAPH[0x644/4] = 0;
1178 pNv->PGRAPH[0x684/4] = pNv->FbMapSize - 1;
1179 pNv->PGRAPH[0x688/4] = pNv->FbMapSize - 1;
1181 pNv->PGRAPH[0x0810/4] = 0x00000000;
1182 pNv->PGRAPH[0x0608/4] = 0xFFFFFFFF;
1184 if(pNv->Architecture >= NV_ARCH_40) {
1185 pNv->PGRAPH[0x0084/4] = 0x401287c0;
1186 pNv->PGRAPH[0x008C/4] = 0x60de8051;
1187 pNv->PGRAPH[0x0090/4] = 0x00008000;
1188 pNv->PGRAPH[0x0610/4] = 0x00be3c5f;
1190 j = pNv->REGS[0x1540/4] & 0xff;
1192 for(i = 0; !(j & 1); j >>= 1, i++);
1193 pNv->PGRAPH[0x5000/4] = i;
1196 if((pNv->Chipset & 0xfff0) == 0x0040) {
1197 pNv->PGRAPH[0x09b0/4] = 0x83280fff;
1198 pNv->PGRAPH[0x09b4/4] = 0x000000a0;
1200 pNv->PGRAPH[0x0820/4] = 0x83280eff;
1201 pNv->PGRAPH[0x0824/4] = 0x000000a0;
1204 switch(pNv->Chipset & 0xfff0) {
1207 pNv->PGRAPH[0x09b8/4] = 0x0078e366;
1208 pNv->PGRAPH[0x09bc/4] = 0x0000014c;
1209 pNv->PFB[0x033C/4] &= 0xffff7fff;
1213 pNv->PGRAPH[0x0828/4] = 0x007596ff;
1214 pNv->PGRAPH[0x082C/4] = 0x00000108;
1220 pNv->PMC[0x1700/4] = pNv->PFB[0x020C/4];
1221 pNv->PMC[0x1704/4] = 0;
1222 pNv->PMC[0x1708/4] = 0;
1223 pNv->PMC[0x170C/4] = pNv->PFB[0x020C/4];
1224 pNv->PGRAPH[0x0860/4] = 0;
1225 pNv->PGRAPH[0x0864/4] = 0;
1226 pNv->PRAMDAC[0x0608/4] |= 0x00100000;
1229 pNv->PGRAPH[0x0828/4] = 0x0072cb77;
1230 pNv->PGRAPH[0x082C/4] = 0x00000108;
1233 pNv->PGRAPH[0x0860/4] = 0;
1234 pNv->PGRAPH[0x0864/4] = 0;
1235 pNv->PRAMDAC[0x0608/4] |= 0x00100000;
1240 pNv->PRAMDAC[0x0608/4] |= 0x00100000;
1241 pNv->PGRAPH[0x0828/4] = 0x07830610;
1242 pNv->PGRAPH[0x082C/4] = 0x0000016A;
1248 pNv->PGRAPH[0x0b38/4] = 0x2ffff800;
1249 pNv->PGRAPH[0x0b3c/4] = 0x00006000;
1250 pNv->PGRAPH[0x032C/4] = 0x01000000;
1251 pNv->PGRAPH[0x0220/4] = 0x00001200;
1253 if(pNv->Architecture == NV_ARCH_30) {
1254 pNv->PGRAPH[0x0084/4] = 0x40108700;
1255 pNv->PGRAPH[0x0890/4] = 0x00140000;
1256 pNv->PGRAPH[0x008C/4] = 0xf00e0431;
1257 pNv->PGRAPH[0x0090/4] = 0x00008000;
1258 pNv->PGRAPH[0x0610/4] = 0xf04b1f36;
1259 pNv->PGRAPH[0x0B80/4] = 0x1002d888;
1260 pNv->PGRAPH[0x0B88/4] = 0x62ff007f;
1262 pNv->PGRAPH[0x0084/4] = 0x00118700;
1263 pNv->PGRAPH[0x008C/4] = 0xF20E0431;
1264 pNv->PGRAPH[0x0090/4] = 0x00000000;
1265 pNv->PGRAPH[0x009C/4] = 0x00000040;
1267 if((pNv->Chipset & 0x0ff0) >= 0x0250) {
1268 pNv->PGRAPH[0x0890/4] = 0x00080000;
1269 pNv->PGRAPH[0x0610/4] = 0x304B1FB6;
1270 pNv->PGRAPH[0x0B80/4] = 0x18B82880;
1271 pNv->PGRAPH[0x0B84/4] = 0x44000000;
1272 pNv->PGRAPH[0x0098/4] = 0x40000080;
1273 pNv->PGRAPH[0x0B88/4] = 0x000000ff;
1275 pNv->PGRAPH[0x0880/4] = 0x00080000;
1276 pNv->PGRAPH[0x0094/4] = 0x00000005;
1277 pNv->PGRAPH[0x0B80/4] = 0x45CAA208;
1278 pNv->PGRAPH[0x0B84/4] = 0x24000000;
1279 pNv->PGRAPH[0x0098/4] = 0x00000040;
1280 pNv->PGRAPH[0x0750/4] = 0x00E00038;
1281 pNv->PGRAPH[0x0754/4] = 0x00000030;
1282 pNv->PGRAPH[0x0750/4] = 0x00E10038;
1283 pNv->PGRAPH[0x0754/4] = 0x00000030;
1287 if((pNv->Architecture < NV_ARCH_40) ||
1288 ((pNv->Chipset & 0xfff0) == 0x0040))
1290 for(i = 0; i < 32; i++) {
1291 pNv->PGRAPH[(0x0900/4) + i] = pNv->PFB[(0x0240/4) + i];
1292 pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0240/4) + i];
1295 if(((pNv->Chipset & 0xfff0) == 0x0090) ||
1296 ((pNv->Chipset & 0xfff0) == 0x01D0) ||
1297 ((pNv->Chipset & 0xfff0) == 0x0290) ||
1298 ((pNv->Chipset & 0xfff0) == 0x0390) ||
1299 ((pNv->Chipset & 0xfff0) == 0x03D0))
1301 for(i = 0; i < 60; i++) {
1302 pNv->PGRAPH[(0x0D00/4) + i] = pNv->PFB[(0x0600/4) + i];
1303 pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0600/4) + i];
1306 for(i = 0; i < 48; i++) {
1307 pNv->PGRAPH[(0x0900/4) + i] = pNv->PFB[(0x0600/4) + i];
1308 if(((pNv->Chipset & 0xfff0) != 0x0160) &&
1309 ((pNv->Chipset & 0xfff0) != 0x0220) &&
1310 ((pNv->Chipset & 0xfff0) != 0x0240))
1312 pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0600/4) + i];
1318 if(pNv->Architecture >= NV_ARCH_40) {
1319 if((pNv->Chipset & 0xfff0) == 0x0040) {
1320 pNv->PGRAPH[0x09A4/4] = pNv->PFB[0x0200/4];
1321 pNv->PGRAPH[0x09A8/4] = pNv->PFB[0x0204/4];
1322 pNv->PGRAPH[0x69A4/4] = pNv->PFB[0x0200/4];
1323 pNv->PGRAPH[0x69A8/4] = pNv->PFB[0x0204/4];
1325 pNv->PGRAPH[0x0820/4] = 0;
1326 pNv->PGRAPH[0x0824/4] = 0;
1327 pNv->PGRAPH[0x0864/4] = pNv->FbMapSize - 1;
1328 pNv->PGRAPH[0x0868/4] = pNv->FbMapSize - 1;
1330 if(((pNv->Chipset & 0xfff0) == 0x0090) ||
1331 ((pNv->Chipset & 0xfff0) == 0x01D0) ||
1332 ((pNv->Chipset & 0xfff0) == 0x0290) ||
1333 ((pNv->Chipset & 0xfff0) == 0x0390))
1335 pNv->PGRAPH[0x0DF0/4] = pNv->PFB[0x0200/4];
1336 pNv->PGRAPH[0x0DF4/4] = pNv->PFB[0x0204/4];
1338 pNv->PGRAPH[0x09F0/4] = pNv->PFB[0x0200/4];
1339 pNv->PGRAPH[0x09F4/4] = pNv->PFB[0x0204/4];
1341 pNv->PGRAPH[0x69F0/4] = pNv->PFB[0x0200/4];
1342 pNv->PGRAPH[0x69F4/4] = pNv->PFB[0x0204/4];
1344 pNv->PGRAPH[0x0840/4] = 0;
1345 pNv->PGRAPH[0x0844/4] = 0;
1346 pNv->PGRAPH[0x08a0/4] = pNv->FbMapSize - 1;
1347 pNv->PGRAPH[0x08a4/4] = pNv->FbMapSize - 1;
1350 pNv->PGRAPH[0x09A4/4] = pNv->PFB[0x0200/4];
1351 pNv->PGRAPH[0x09A8/4] = pNv->PFB[0x0204/4];
1352 pNv->PGRAPH[0x0750/4] = 0x00EA0000;
1353 pNv->PGRAPH[0x0754/4] = pNv->PFB[0x0200/4];
1354 pNv->PGRAPH[0x0750/4] = 0x00EA0004;
1355 pNv->PGRAPH[0x0754/4] = pNv->PFB[0x0204/4];
1357 pNv->PGRAPH[0x0820/4] = 0;
1358 pNv->PGRAPH[0x0824/4] = 0;
1359 pNv->PGRAPH[0x0864/4] = pNv->FbMapSize - 1;
1360 pNv->PGRAPH[0x0868/4] = pNv->FbMapSize - 1;
1363 pNv->PGRAPH[0x0B20/4] = 0x00000000;
1364 pNv->PGRAPH[0x0B04/4] = 0xFFFFFFFF;
1367 pNv->PGRAPH[0x053C/4] = 0;
1368 pNv->PGRAPH[0x0540/4] = 0;
1369 pNv->PGRAPH[0x0544/4] = 0x00007FFF;
1370 pNv->PGRAPH[0x0548/4] = 0x00007FFF;
1372 pNv->PFIFO[0x0140] = 0x00000000;
1373 pNv->PFIFO[0x0141] = 0x00000001;
1374 pNv->PFIFO[0x0480] = 0x00000000;
1375 pNv->PFIFO[0x0494] = 0x00000000;
1376 if(pNv->Architecture >= NV_ARCH_40)
1377 pNv->PFIFO[0x0481] = 0x00010000;
1379 pNv->PFIFO[0x0481] = 0x00000100;
1380 pNv->PFIFO[0x0490] = 0x00000000;
1381 pNv->PFIFO[0x0491] = 0x00000000;
1382 if(pNv->Architecture >= NV_ARCH_40)
1383 pNv->PFIFO[0x048B] = 0x00001213;
1385 pNv->PFIFO[0x048B] = 0x00001209;
1386 pNv->PFIFO[0x0400] = 0x00000000;
1387 pNv->PFIFO[0x0414] = 0x00000000;
1388 pNv->PFIFO[0x0084] = 0x03000100;
1389 pNv->PFIFO[0x0085] = 0x00000110;
1390 pNv->PFIFO[0x0086] = 0x00000112;
1391 pNv->PFIFO[0x0143] = 0x0000FFFF;
1392 pNv->PFIFO[0x0496] = 0x0000FFFF;
1393 pNv->PFIFO[0x0050] = 0x00000000;
1394 pNv->PFIFO[0x0040] = 0xFFFFFFFF;
1395 pNv->PFIFO[0x0415] = 0x00000001;
1396 pNv->PFIFO[0x048C] = 0x00000000;
1397 pNv->PFIFO[0x04A0] = 0x00000000;
1398 #if X_BYTE_ORDER == X_BIG_ENDIAN
1399 pNv->PFIFO[0x0489] = 0x800F0078;
1401 pNv->PFIFO[0x0489] = 0x000F0078;
1403 pNv->PFIFO[0x0488] = 0x00000001;
1404 pNv->PFIFO[0x0480] = 0x00000001;
1405 pNv->PFIFO[0x0494] = 0x00000001;
1406 pNv->PFIFO[0x0495] = 0x00000001;
1407 pNv->PFIFO[0x0140] = 0x00000001;
1409 if(pNv->Architecture >= NV_ARCH_10) {
1411 pNv->PCRTC0[0x0860/4] = state->head;
1412 pNv->PCRTC0[0x2860/4] = state->head2;
1414 pNv->PRAMDAC[0x0404/4] |= (1 << 25);
1416 pNv->PMC[0x8704/4] = 1;
1417 pNv->PMC[0x8140/4] = 0;
1418 pNv->PMC[0x8920/4] = 0;
1419 pNv->PMC[0x8924/4] = 0;
1420 pNv->PMC[0x8908/4] = pNv->FbMapSize - 1;
1421 pNv->PMC[0x890C/4] = pNv->FbMapSize - 1;
1422 pNv->PMC[0x1588/4] = 0;
1424 pNv->PCRTC[0x0810/4] = state->cursorConfig;
1425 pNv->PCRTC[0x0830/4] = state->displayV - 3;
1426 pNv->PCRTC[0x0834/4] = state->displayV - 1;
1428 if(pNv->FlatPanel) {
1429 if((pNv->Chipset & 0x0ff0) == 0x0110) {
1430 pNv->PRAMDAC[0x0528/4] = state->dither;
1433 pNv->PRAMDAC[0x083C/4] = state->dither;
1436 VGA_WR08(pNv->PCIO, 0x03D4, 0x53);
1437 VGA_WR08(pNv->PCIO, 0x03D5, state->timingH);
1438 VGA_WR08(pNv->PCIO, 0x03D4, 0x54);
1439 VGA_WR08(pNv->PCIO, 0x03D5, state->timingV);
1440 VGA_WR08(pNv->PCIO, 0x03D4, 0x21);
1441 VGA_WR08(pNv->PCIO, 0x03D5, 0xfa);
1444 VGA_WR08(pNv->PCIO, 0x03D4, 0x41);
1445 VGA_WR08(pNv->PCIO, 0x03D5, state->extra);
1448 VGA_WR08(pNv->PCIO, 0x03D4, 0x19);
1449 VGA_WR08(pNv->PCIO, 0x03D5, state->repaint0);
1450 VGA_WR08(pNv->PCIO, 0x03D4, 0x1A);
1451 VGA_WR08(pNv->PCIO, 0x03D5, state->repaint1);
1452 VGA_WR08(pNv->PCIO, 0x03D4, 0x25);
1453 VGA_WR08(pNv->PCIO, 0x03D5, state->screen);
1454 VGA_WR08(pNv->PCIO, 0x03D4, 0x28);
1455 VGA_WR08(pNv->PCIO, 0x03D5, state->pixel);
1456 VGA_WR08(pNv->PCIO, 0x03D4, 0x2D);
1457 VGA_WR08(pNv->PCIO, 0x03D5, state->horiz);
1458 VGA_WR08(pNv->PCIO, 0x03D4, 0x1C);
1459 VGA_WR08(pNv->PCIO, 0x03D5, state->fifo);
1460 VGA_WR08(pNv->PCIO, 0x03D4, 0x1B);
1461 VGA_WR08(pNv->PCIO, 0x03D5, state->arbitration0);
1462 VGA_WR08(pNv->PCIO, 0x03D4, 0x20);
1463 VGA_WR08(pNv->PCIO, 0x03D5, state->arbitration1);
1464 if(pNv->Architecture >= NV_ARCH_30) {
1465 VGA_WR08(pNv->PCIO, 0x03D4, 0x47);
1466 VGA_WR08(pNv->PCIO, 0x03D5, state->arbitration1 >> 8);
1468 VGA_WR08(pNv->PCIO, 0x03D4, 0x30);
1469 VGA_WR08(pNv->PCIO, 0x03D5, state->cursor0);
1470 VGA_WR08(pNv->PCIO, 0x03D4, 0x31);
1471 VGA_WR08(pNv->PCIO, 0x03D5, state->cursor1);
1472 VGA_WR08(pNv->PCIO, 0x03D4, 0x2F);
1473 VGA_WR08(pNv->PCIO, 0x03D5, state->cursor2);
1474 VGA_WR08(pNv->PCIO, 0x03D4, 0x39);
1475 VGA_WR08(pNv->PCIO, 0x03D5, state->interlace);
1477 if(!pNv->FlatPanel) {
1478 pNv->PRAMDAC0[0x050C/4] = state->pllsel;
1479 pNv->PRAMDAC0[0x0508/4] = state->vpll;
1481 pNv->PRAMDAC0[0x0520/4] = state->vpll2;
1482 if(pNv->twoStagePLL) {
1483 pNv->PRAMDAC0[0x0578/4] = state->vpllB;
1484 pNv->PRAMDAC0[0x057C/4] = state->vpll2B;
1487 pNv->PRAMDAC[0x0848/4] = state->scale;
1488 pNv->PRAMDAC[0x0828/4] = state->crtcSync;
1490 pNv->PRAMDAC[0x0600/4] = state->general;
1492 pNv->PCRTC[0x0140/4] = 0;
1493 pNv->PCRTC[0x0100/4] = 1;
1495 pNv->CurrentState = state;
1498 void NVUnloadStateExt
1501 RIVA_HW_STATE *state
1504 VGA_WR08(pNv->PCIO, 0x03D4, 0x19);
1505 state->repaint0 = VGA_RD08(pNv->PCIO, 0x03D5);
1506 VGA_WR08(pNv->PCIO, 0x03D4, 0x1A);
1507 state->repaint1 = VGA_RD08(pNv->PCIO, 0x03D5);
1508 VGA_WR08(pNv->PCIO, 0x03D4, 0x25);
1509 state->screen = VGA_RD08(pNv->PCIO, 0x03D5);
1510 VGA_WR08(pNv->PCIO, 0x03D4, 0x28);
1511 state->pixel = VGA_RD08(pNv->PCIO, 0x03D5);
1512 VGA_WR08(pNv->PCIO, 0x03D4, 0x2D);
1513 state->horiz = VGA_RD08(pNv->PCIO, 0x03D5);
1514 VGA_WR08(pNv->PCIO, 0x03D4, 0x1C);
1515 state->fifo = VGA_RD08(pNv->PCIO, 0x03D5);
1516 VGA_WR08(pNv->PCIO, 0x03D4, 0x1B);
1517 state->arbitration0 = VGA_RD08(pNv->PCIO, 0x03D5);
1518 VGA_WR08(pNv->PCIO, 0x03D4, 0x20);
1519 state->arbitration1 = VGA_RD08(pNv->PCIO, 0x03D5);
1520 if(pNv->Architecture >= NV_ARCH_30) {
1521 VGA_WR08(pNv->PCIO, 0x03D4, 0x47);
1522 state->arbitration1 |= (VGA_RD08(pNv->PCIO, 0x03D5) & 1) << 8;
1524 VGA_WR08(pNv->PCIO, 0x03D4, 0x30);
1525 state->cursor0 = VGA_RD08(pNv->PCIO, 0x03D5);
1526 VGA_WR08(pNv->PCIO, 0x03D4, 0x31);
1527 state->cursor1 = VGA_RD08(pNv->PCIO, 0x03D5);
1528 VGA_WR08(pNv->PCIO, 0x03D4, 0x2F);
1529 state->cursor2 = VGA_RD08(pNv->PCIO, 0x03D5);
1530 VGA_WR08(pNv->PCIO, 0x03D4, 0x39);
1531 state->interlace = VGA_RD08(pNv->PCIO, 0x03D5);
1532 state->vpll = pNv->PRAMDAC0[0x0508/4];
1534 state->vpll2 = pNv->PRAMDAC0[0x0520/4];
1535 if(pNv->twoStagePLL) {
1536 state->vpllB = pNv->PRAMDAC0[0x0578/4];
1537 state->vpll2B = pNv->PRAMDAC0[0x057C/4];
1539 state->pllsel = pNv->PRAMDAC0[0x050C/4];
1540 state->general = pNv->PRAMDAC[0x0600/4];
1541 state->scale = pNv->PRAMDAC[0x0848/4];
1542 state->config = pNv->PFB[0x0200/4];
1544 if(pNv->Architecture >= NV_ARCH_10) {
1546 state->head = pNv->PCRTC0[0x0860/4];
1547 state->head2 = pNv->PCRTC0[0x2860/4];
1548 VGA_WR08(pNv->PCIO, 0x03D4, 0x44);
1549 state->crtcOwner = VGA_RD08(pNv->PCIO, 0x03D5);
1551 VGA_WR08(pNv->PCIO, 0x03D4, 0x41);
1552 state->extra = VGA_RD08(pNv->PCIO, 0x03D5);
1553 state->cursorConfig = pNv->PCRTC[0x0810/4];
1555 if((pNv->Chipset & 0x0ff0) == 0x0110) {
1556 state->dither = pNv->PRAMDAC[0x0528/4];
1559 state->dither = pNv->PRAMDAC[0x083C/4];
1562 if(pNv->FlatPanel) {
1563 VGA_WR08(pNv->PCIO, 0x03D4, 0x53);
1564 state->timingH = VGA_RD08(pNv->PCIO, 0x03D5);
1565 VGA_WR08(pNv->PCIO, 0x03D4, 0x54);
1566 state->timingV = VGA_RD08(pNv->PCIO, 0x03D5);
1570 if(pNv->FlatPanel) {
1571 state->crtcSync = pNv->PRAMDAC[0x0828/4];
1575 void NVSetStartAddress (
1580 pNv->PCRTC[0x800/4] = start;