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 $ */
43 #include "nv_include.h"
45 uint8_t nvReadVGA(NVPtr pNv, uint8_t index)
47 volatile const uint8_t *ptr = pNv->cur_head ? pNv->PCIO1 : pNv->PCIO0;
48 VGA_WR08(ptr, 0x03D4, index);
49 return VGA_RD08(ptr, 0x03D5);
52 void nvWriteVGA(NVPtr pNv, uint8_t index, uint8_t data)
54 volatile const uint8_t *ptr = pNv->cur_head ? pNv->PCIO1 : pNv->PCIO0;
55 VGA_WR08(ptr, 0x03D4, index);
56 VGA_WR08(ptr, 0x03D5, data);
59 CARD32 nvReadRAMDAC(NVPtr pNv, uint8_t head, uint32_t ramdac_reg)
61 volatile const void *ptr = head ? pNv->PRAMDAC1 : pNv->PRAMDAC0;
62 return MMIO_IN32(ptr, ramdac_reg);
65 void nvWriteRAMDAC(NVPtr pNv, uint8_t head, uint32_t ramdac_reg, CARD32 val)
67 volatile const void *ptr = head ? pNv->PRAMDAC1 : pNv->PRAMDAC0;
68 MMIO_OUT32(ptr, ramdac_reg, val);
71 #define nvReadRAMDAC0(pNv, reg) nvReadRAMDAC(pNv, 0, reg)
72 #define nvWriteRAMDAC0(pNv, reg, val) nvWriteRAMDAC(pNv, 0, reg, val)
74 #define nvReadCurRAMDAC(pNv, reg) nvReadRAMDAC(pNv, pNv->cur_head, reg)
76 #define nvWriteCurRAMDAC(pNv, reg, val) nvWriteRAMDAC(pNv, pNv->cur_head, reg, val)
85 nvWriteVGA(pNv, 0x1f, Lock ? 0x99 : 0x57 );
87 cr11 = nvReadVGA(pNv, 0x11);
88 if(Lock) cr11 |= 0x80;
90 nvWriteVGA(pNv, 0x11, cr11);
93 int NVShowHideCursor (
98 int current = pNv->CurrentState->cursor1;
100 pNv->CurrentState->cursor1 = (pNv->CurrentState->cursor1 & 0xFE) |
103 nvWriteVGA(pNv, 0x31, pNv->CurrentState->cursor1);
105 if(pNv->Architecture == NV_ARCH_40) { /* HW bug */
106 volatile CARD32 curpos = nvReadCurRAMDAC(pNv, NV_RAMDAC_CURSOR_POS);
107 nvWriteCurRAMDAC(pNv, NV_RAMDAC_CURSOR_POS, curpos);
110 return (current & 0x01);
113 /****************************************************************************\
115 * The video arbitration routines calculate some "magic" numbers. Fixes *
116 * the snow seen when accessing the framebuffer without it. *
117 * It just works (I hope). *
119 \****************************************************************************/
124 int graphics_burst_size;
125 int video_burst_size;
146 int graphics_burst_size;
147 int video_burst_size;
167 static void nvGetClocks(NVPtr pNv, unsigned int *MClk, unsigned int *NVClk)
169 unsigned int pll, N, M, MB, NB, P;
171 if(pNv->Architecture >= NV_ARCH_40) {
172 pll = pNv->PMC[0x4020/4];
173 P = (pll >> 16) & 0x07;
174 pll = pNv->PMC[0x4024/4];
176 N = (pll >> 8) & 0xFF;
177 if(((pNv->Chipset & 0xfff0) == CHIPSET_G71) ||
178 ((pNv->Chipset & 0xfff0) == CHIPSET_G73))
183 MB = (pll >> 16) & 0xFF;
184 NB = (pll >> 24) & 0xFF;
186 *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
188 pll = pNv->PMC[0x4000/4];
189 P = (pll >> 16) & 0x07;
190 pll = pNv->PMC[0x4004/4];
192 N = (pll >> 8) & 0xFF;
193 MB = (pll >> 16) & 0xFF;
194 NB = (pll >> 24) & 0xFF;
196 *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
198 if(pNv->twoStagePLL) {
199 pll = nvReadRAMDAC0(pNv, 0x0504);
201 N = (pll >> 8) & 0xFF;
202 P = (pll >> 16) & 0x0F;
203 pll = nvReadRAMDAC0(pNv, 0x0574);
204 if(pll & 0x80000000) {
206 NB = (pll >> 8) & 0xFF;
211 *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
213 pll = nvReadRAMDAC0(pNv, 0x0500);
215 N = (pll >> 8) & 0xFF;
216 P = (pll >> 16) & 0x0F;
217 pll = nvReadRAMDAC0(pNv, 0x0570);
218 if(pll & 0x80000000) {
220 NB = (pll >> 8) & 0xFF;
225 *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
227 if(((pNv->Chipset & 0x0ff0) == CHIPSET_NV30) ||
228 ((pNv->Chipset & 0x0ff0) == CHIPSET_NV35))
230 pll = nvReadRAMDAC0(pNv, 0x504);
232 N = (pll >> 8) & 0xFF;
233 P = (pll >> 16) & 0x07;
234 if(pll & 0x00000080) {
235 MB = (pll >> 4) & 0x07;
236 NB = (pll >> 19) & 0x1f;
241 *MClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
243 pll = nvReadRAMDAC0(pNv, 0x500);
245 N = (pll >> 8) & 0xFF;
246 P = (pll >> 16) & 0x07;
247 if(pll & 0x00000080) {
248 MB = (pll >> 4) & 0x07;
249 NB = (pll >> 19) & 0x1f;
254 *NVClk = ((N * NB * pNv->CrystalFreqKHz) / (M * MB)) >> P;
256 pll = nvReadRAMDAC0(pNv, 0x504);
258 N = (pll >> 8) & 0xFF;
259 P = (pll >> 16) & 0x0F;
260 *MClk = (N * pNv->CrystalFreqKHz / M) >> P;
262 pll = nvReadRAMDAC0(pNv, 0x500);
264 N = (pll >> 8) & 0xFF;
265 P = (pll >> 16) & 0x0F;
266 *NVClk = (N * pNv->CrystalFreqKHz / M) >> P;
270 ErrorF("NVClock = %i MHz, MEMClock = %i MHz\n", *NVClk/1000, *MClk/1000);
275 static void nv4CalcArbitration (
280 int data, pagemiss, cas,width, video_enable, bpp;
281 int nvclks, mclks, pclks, vpagemiss, crtpagemiss, vbs;
282 int found, mclk_extra, mclk_loop, cbs, m1, p1;
283 int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
284 int us_m, us_n, us_p, video_drain_rate, crtc_drain_rate;
285 int vpm_us, us_video, vlwm, video_fill_us, cpm_us, us_crt,clwm;
288 pclk_freq = arb->pclk_khz;
289 mclk_freq = arb->mclk_khz;
290 nvclk_freq = arb->nvclk_khz;
291 pagemiss = arb->mem_page_miss;
292 cas = arb->mem_latency;
293 width = arb->memory_width >> 6;
294 video_enable = arb->enable_video;
296 mp_enable = arb->enable_mp;
327 mclk_loop = mclks+mclk_extra;
328 us_m = mclk_loop *1000*1000 / mclk_freq;
329 us_n = nvclks*1000*1000 / nvclk_freq;
330 us_p = nvclks*1000*1000 / pclk_freq;
333 video_drain_rate = pclk_freq * 2;
334 crtc_drain_rate = pclk_freq * bpp/8;
338 vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
339 if (nvclk_freq * 2 > mclk_freq * width)
340 video_fill_us = cbs*1000*1000 / 16 / nvclk_freq ;
342 video_fill_us = cbs*1000*1000 / (8 * width) / mclk_freq;
343 us_video = vpm_us + us_m + us_n + us_p + video_fill_us;
344 vlwm = us_video * video_drain_rate/(1000*1000);
347 if (vlwm > 128) vbs = 64;
348 if (vlwm > (256-64)) vbs = 32;
349 if (nvclk_freq * 2 > mclk_freq * width)
350 video_fill_us = vbs *1000*1000/ 16 / nvclk_freq ;
352 video_fill_us = vbs*1000*1000 / (8 * width) / mclk_freq;
353 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
360 clwm = us_crt * crtc_drain_rate/(1000*1000);
365 crtc_drain_rate = pclk_freq * bpp/8;
368 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
369 us_crt = cpm_us + us_m + us_n + us_p ;
370 clwm = us_crt * crtc_drain_rate/(1000*1000);
373 m1 = clwm + cbs - 512;
374 p1 = m1 * pclk_freq / mclk_freq;
376 if ((p1 < m1) && (m1 > 0))
380 if (mclk_extra ==0) found = 1;
383 else if (video_enable)
385 if ((clwm > 511) || (vlwm > 255))
389 if (mclk_extra ==0) found = 1;
399 if (mclk_extra ==0) found = 1;
403 if (clwm < 384) clwm = 384;
404 if (vlwm < 128) vlwm = 128;
406 fifo->graphics_lwm = data;
407 fifo->graphics_burst_size = 128;
408 data = (int)((vlwm+15));
409 fifo->video_lwm = data;
410 fifo->video_burst_size = vbs;
414 static void nv4UpdateArbitrationSettings (
422 nv4_fifo_info fifo_data;
423 nv4_sim_state sim_data;
424 unsigned int MClk, NVClk, cfg1;
426 nvGetClocks(pNv, &MClk, &NVClk);
428 cfg1 = pNv->PFB[0x00000204/4];
429 sim_data.pix_bpp = (char)pixelDepth;
430 sim_data.enable_video = 0;
431 sim_data.enable_mp = 0;
432 sim_data.memory_width = (pNv->PEXTDEV[0x0000/4] & 0x10) ? 128 : 64;
433 sim_data.mem_latency = (char)cfg1 & 0x0F;
434 sim_data.mem_aligned = 1;
435 sim_data.mem_page_miss = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
436 sim_data.gr_during_vid = 0;
437 sim_data.pclk_khz = VClk;
438 sim_data.mclk_khz = MClk;
439 sim_data.nvclk_khz = NVClk;
440 nv4CalcArbitration(&fifo_data, &sim_data);
443 int b = fifo_data.graphics_burst_size >> 4;
445 while (b >>= 1) (*burst)++;
446 *lwm = fifo_data.graphics_lwm >> 3;
450 static void nv10CalcArbitration (
451 nv10_fifo_info *fifo,
455 int data, pagemiss, width, video_enable, bpp;
456 int nvclks, mclks, pclks, vpagemiss, crtpagemiss;
458 int found, mclk_extra, mclk_loop, cbs, m1;
459 int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
460 int us_m, us_m_min, us_n, us_p, crtc_drain_rate;
462 int vpm_us, us_video, cpm_us, us_crt,clwm;
464 int m2us, us_pipe_min, p1clk, p2;
466 int us_min_mclk_extra;
469 pclk_freq = arb->pclk_khz; /* freq in KHz */
470 mclk_freq = arb->mclk_khz;
471 nvclk_freq = arb->nvclk_khz;
472 pagemiss = arb->mem_page_miss;
473 width = arb->memory_width/64;
474 video_enable = arb->enable_video;
476 mp_enable = arb->enable_mp;
481 pclks = 4; /* lwm detect. */
483 nvclks = 3; /* lwm -> sync. */
484 nvclks += 2; /* fbi bus cycles (1 req + 1 busy) */
486 mclks = 1; /* 2 edge sync. may be very close to edge so just put one. */
488 mclks += 1; /* arb_hp_req */
489 mclks += 5; /* ap_hp_req tiling pipeline */
491 mclks += 2; /* tc_req latency fifo */
492 mclks += 2; /* fb_cas_n_ memory request to fbio block */
493 mclks += 7; /* sm_d_rdv data returned from fbio block */
495 /* fb.rd.d.Put_gc need to accumulate 256 bits for read */
496 if (arb->memory_type == 0)
497 if (arb->memory_width == 64) /* 64 bit bus */
502 if (arb->memory_width == 64) /* 64 bit bus */
507 if ((!video_enable) && (arb->memory_width == 128))
509 mclk_extra = (bpp == 32) ? 31 : 42; /* Margin of error */
514 mclk_extra = (bpp == 32) ? 8 : 4; /* Margin of error */
515 /* mclk_extra = 4; */ /* Margin of error */
519 nvclks += 1; /* 2 edge sync. may be very close to edge so just put one. */
520 nvclks += 1; /* fbi_d_rdv_n */
521 nvclks += 1; /* Fbi_d_rdata */
522 nvclks += 1; /* crtfifo load */
525 mclks+=4; /* Mp can get in with a burst of 8. */
526 /* Extra clocks determined by heuristics */
534 mclk_loop = mclks+mclk_extra;
535 us_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
536 us_m_min = mclks * 1000*1000 / mclk_freq; /* Minimum Mclk latency in us */
537 us_min_mclk_extra = min_mclk_extra *1000*1000 / mclk_freq;
538 us_n = nvclks*1000*1000 / nvclk_freq;/* nvclk latency in us */
539 us_p = pclks*1000*1000 / pclk_freq;/* nvclk latency in us */
540 us_pipe_min = us_m_min + us_n + us_p;
542 vus_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
545 crtc_drain_rate = pclk_freq * bpp/8; /* MB/s */
547 vpagemiss = 1; /* self generating page miss */
548 vpagemiss += 1; /* One higher priority before */
550 crtpagemiss = 2; /* self generating page miss */
552 crtpagemiss += 1; /* if MA0 conflict */
554 vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
556 us_video = vpm_us + vus_m; /* Video has separate read return path */
558 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
560 us_video /* Wait for video */
561 +cpm_us /* CRT Page miss */
562 +us_m + us_n +us_p /* other latency */
565 clwm = us_crt * crtc_drain_rate/(1000*1000);
566 clwm++; /* fixed point <= float_point - 1. Fixes that */
568 crtc_drain_rate = pclk_freq * bpp/8; /* bpp * pclk/8 */
570 crtpagemiss = 1; /* self generating page miss */
571 crtpagemiss += 1; /* MA0 page miss */
573 crtpagemiss += 1; /* if MA0 conflict */
574 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
575 us_crt = cpm_us + us_m + us_n + us_p ;
576 clwm = us_crt * crtc_drain_rate/(1000*1000);
577 clwm++; /* fixed point <= float_point - 1. Fixes that */
579 /* Finally, a heuristic check when width == 64 bits */
581 nvclk_fill = nvclk_freq * 8;
582 if(crtc_drain_rate * 100 >= nvclk_fill * 102)
583 clwm = 0xfff; /*Large number to fail */
585 else if(crtc_drain_rate * 100 >= nvclk_fill * 98) {
598 clwm_rnd_down = ((int)clwm/8)*8;
599 if (clwm_rnd_down < clwm)
602 m1 = clwm + cbs - 1024; /* Amount of overfill */
603 m2us = us_pipe_min + us_min_mclk_extra;
605 /* pclk cycles to drain */
606 p1clk = m2us * pclk_freq/(1000*1000);
607 p2 = p1clk * bpp / 8; /* bytes drained. */
609 if((p2 < m1) && (m1 > 0)) {
612 if(min_mclk_extra == 0) {
614 found = 1; /* Can't adjust anymore! */
616 cbs = cbs/2; /* reduce the burst size */
622 if (clwm > 1023){ /* Have some margin */
625 if(min_mclk_extra == 0)
626 found = 1; /* Can't adjust anymore! */
632 if(clwm < (1024-cbs+8)) clwm = 1024-cbs+8;
634 /* printf("CRT LWM: %f bytes, prog: 0x%x, bs: 256\n", clwm, data ); */
635 fifo->graphics_lwm = data; fifo->graphics_burst_size = cbs;
637 fifo->video_lwm = 1024; fifo->video_burst_size = 512;
641 static void nv10UpdateArbitrationSettings (
649 nv10_fifo_info fifo_data;
650 nv10_sim_state sim_data;
651 unsigned int MClk, NVClk, cfg1;
653 nvGetClocks(pNv, &MClk, &NVClk);
655 cfg1 = pNv->PFB[0x0204/4];
656 sim_data.pix_bpp = (char)pixelDepth;
657 sim_data.enable_video = 1;
658 sim_data.enable_mp = 0;
659 sim_data.memory_type = (pNv->PFB[0x0200/4] & 0x01) ? 1 : 0;
660 sim_data.memory_width = (pNv->PEXTDEV[0x0000/4] & 0x10) ? 128 : 64;
661 sim_data.mem_latency = (char)cfg1 & 0x0F;
662 sim_data.mem_aligned = 1;
663 sim_data.mem_page_miss = (char)(((cfg1>>4) &0x0F) + ((cfg1>>31) & 0x01));
664 sim_data.gr_during_vid = 0;
665 sim_data.pclk_khz = VClk;
666 sim_data.mclk_khz = MClk;
667 sim_data.nvclk_khz = NVClk;
668 nv10CalcArbitration(&fifo_data, &sim_data);
669 if (fifo_data.valid) {
670 int b = fifo_data.graphics_burst_size >> 4;
672 while (b >>= 1) (*burst)++;
673 *lwm = fifo_data.graphics_lwm >> 3;
678 static void nv30UpdateArbitrationSettings (
684 unsigned int MClk, NVClk;
685 unsigned int fifo_size, burst_size, graphics_lwm;
689 graphics_lwm = fifo_size - burst_size;
691 nvGetClocks(pNv, &MClk, &NVClk);
695 while(burst_size >>= 1) (*burst)++;
696 *lwm = graphics_lwm >> 3;
699 static void nForceUpdateArbitrationSettings (
707 nv10_fifo_info fifo_data;
708 nv10_sim_state sim_data;
709 unsigned int M, N, P, pll, MClk, NVClk, memctrl;
711 if((pNv->Chipset & 0x0FF0) == CHIPSET_NFORCE) {
712 unsigned int uMClkPostDiv;
714 uMClkPostDiv = (pciReadLong(pciTag(0, 0, 3), 0x6C) >> 8) & 0xf;
715 if(!uMClkPostDiv) uMClkPostDiv = 4;
716 MClk = 400000 / uMClkPostDiv;
718 MClk = pciReadLong(pciTag(0, 0, 5), 0x4C) / 1000;
721 pll = nvReadRAMDAC0(pNv, 0x500);
722 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
723 NVClk = (N * pNv->CrystalFreqKHz / M) >> P;
724 sim_data.pix_bpp = (char)pixelDepth;
725 sim_data.enable_video = 0;
726 sim_data.enable_mp = 0;
727 sim_data.memory_type = (pciReadLong(pciTag(0, 0, 1), 0x7C) >> 12) & 1;
728 sim_data.memory_width = 64;
730 memctrl = pciReadLong(pciTag(0, 0, 3), 0x00) >> 16;
732 if((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) {
735 dimm[0] = (pciReadLong(pciTag(0, 0, 2), 0x40) >> 8) & 0x4F;
736 dimm[1] = (pciReadLong(pciTag(0, 0, 2), 0x44) >> 8) & 0x4F;
737 dimm[2] = (pciReadLong(pciTag(0, 0, 2), 0x48) >> 8) & 0x4F;
739 if((dimm[0] + dimm[1]) != dimm[2]) {
741 "your nForce DIMMs are not arranged in optimal banks!\n");
745 sim_data.mem_latency = 3;
746 sim_data.mem_aligned = 1;
747 sim_data.mem_page_miss = 10;
748 sim_data.gr_during_vid = 0;
749 sim_data.pclk_khz = VClk;
750 sim_data.mclk_khz = MClk;
751 sim_data.nvclk_khz = NVClk;
752 nv10CalcArbitration(&fifo_data, &sim_data);
755 int b = fifo_data.graphics_burst_size >> 4;
757 while (b >>= 1) (*burst)++;
758 *lwm = fifo_data.graphics_lwm >> 3;
763 /****************************************************************************\
765 * RIVA Mode State Routines *
767 \****************************************************************************/
770 * Calculate the Video Clock parameters for the PLL.
772 static void CalcVClock (
779 unsigned lowM, highM;
780 unsigned DeltaNew, DeltaOld;
784 DeltaOld = 0xFFFFFFFF;
786 VClk = (unsigned)clockIn;
788 if (pNv->CrystalFreqKHz == 13500) {
796 for (P = 0; P <= 4; P++) {
798 if ((Freq >= 128000) && (Freq <= 350000)) {
799 for (M = lowM; M <= highM; M++) {
800 N = ((VClk << P) * M) / pNv->CrystalFreqKHz;
802 Freq = ((pNv->CrystalFreqKHz * N) / M) >> P;
804 DeltaNew = Freq - VClk;
806 DeltaNew = VClk - Freq;
807 if (DeltaNew < DeltaOld) {
808 *pllOut = (P << 16) | (N << 8) | M;
818 static void CalcVClock2Stage (
826 unsigned DeltaNew, DeltaOld;
830 DeltaOld = 0xFFFFFFFF;
832 *pllBOut = 0x80000401; /* fixed at x4 for now */
834 VClk = (unsigned)clockIn;
836 for (P = 0; P <= 6; P++) {
838 if ((Freq >= 400000) && (Freq <= 1000000)) {
839 for (M = 1; M <= 13; M++) {
840 N = ((VClk << P) * M) / (pNv->CrystalFreqKHz << 2);
841 if((N >= 5) && (N <= 255)) {
842 Freq = (((pNv->CrystalFreqKHz << 2) * N) / M) >> P;
844 DeltaNew = Freq - VClk;
846 DeltaNew = VClk - Freq;
847 if (DeltaNew < DeltaOld) {
848 *pllOut = (P << 16) | (N << 8) | M;
859 * Calculate extended mode parameters (SVGA) and save in a
860 * mode state structure.
862 void NVCalcStateExt (
864 RIVA_HW_STATE *state,
873 int pixelDepth, VClk;
877 * Save mode parameters.
879 state->bpp = bpp; /* this is not bitsPerPixel, it's 8,15,16,32 */
880 state->width = width;
881 state->height = height;
883 * Extended RIVA registers.
885 pixelDepth = (bpp + 1)/8;
887 CalcVClock2Stage(dotClock, &VClk, &state->pll, &state->pllB, pNv);
889 CalcVClock(dotClock, &VClk, &state->pll, pNv);
891 switch (pNv->Architecture)
894 nv4UpdateArbitrationSettings(VClk,
896 &(state->arbitration0),
897 &(state->arbitration1),
899 state->cursor0 = 0x00;
900 state->cursor1 = 0xbC;
901 if (flags & V_DBLSCAN)
903 state->cursor2 = 0x00000000;
904 state->pllsel = 0x10000700;
905 state->config = 0x00001114;
906 state->general = bpp == 16 ? 0x00101100 : 0x00100100;
907 state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
913 if(((pNv->Chipset & 0xfff0) == CHIPSET_C51) ||
914 ((pNv->Chipset & 0xfff0) == CHIPSET_C512))
916 state->arbitration0 = 128;
917 state->arbitration1 = 0x0480;
919 if(((pNv->Chipset & 0xffff) == CHIPSET_NFORCE) ||
920 ((pNv->Chipset & 0xffff) == CHIPSET_NFORCE2))
922 nForceUpdateArbitrationSettings(VClk,
924 &(state->arbitration0),
925 &(state->arbitration1),
927 } else if(pNv->Architecture < NV_ARCH_30) {
928 nv10UpdateArbitrationSettings(VClk,
930 &(state->arbitration0),
931 &(state->arbitration1),
934 nv30UpdateArbitrationSettings(pNv,
935 &(state->arbitration0),
936 &(state->arbitration1));
938 CursorStart = pNv->Cursor->offset - pNv->VRAMPhysical;
939 state->cursor0 = 0x80 | (CursorStart >> 17);
940 state->cursor1 = (CursorStart >> 11) << 2;
941 state->cursor2 = CursorStart >> 24;
942 if (flags & V_DBLSCAN)
944 state->pllsel = 0x10000700;
945 state->config = pNv->PFB[0x00000200/4];
946 state->general = bpp == 16 ? 0x00101100 : 0x00100100;
947 state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
951 if(bpp != 8) /* DirectColor */
952 state->general |= 0x00000030;
954 state->repaint0 = (((width / 8) * pixelDepth) & 0x700) >> 3;
955 state->pixel = (pixelDepth > 2) ? 3 : pixelDepth;
959 void NVLoadStateExt (
964 NVPtr pNv = NVPTR(pScrn);
969 pNv->PMC[0x0140/4] = 0x00000000;
970 pNv->PMC[0x0200/4] = 0xFFFF00FF;
971 pNv->PMC[0x0200/4] = 0xFFFFFFFF;
973 pNv->PTIMER[0x0200] = 0x00000008;
974 pNv->PTIMER[0x0210] = 0x00000003;
975 /*TODO: DRM handle PTIMER interrupts */
976 pNv->PTIMER[0x0140] = 0x00000000;
977 pNv->PTIMER[0x0100] = 0xFFFFFFFF;
980 /* it seems those regions are equivalent to the radeon's SURFACEs. needs to go in-kernel just like the SURFACEs */
981 if(pNv->Architecture == NV_ARCH_04) {
982 pNv->PFB[0x0200/4] = state->config;
984 if((pNv->Architecture < NV_ARCH_40) ||
985 ((pNv->Chipset & 0xfff0) == CHIPSET_NV40))
987 for(i = 0; i < 8; i++) {
988 pNv->PFB[(0x0240 + (i * 0x10))/4] = 0;
989 pNv->PFB[(0x0244 + (i * 0x10))/4] = pNv->VRAMPhysicalSize - 1;
994 if(((pNv->Chipset & 0xfff0) == CHIPSET_G70) ||
995 ((pNv->Chipset & 0xfff0) == CHIPSET_G71) ||
996 ((pNv->Chipset & 0xfff0) == CHIPSET_G72) ||
997 ((pNv->Chipset & 0xfff0) == CHIPSET_G73) ||
998 ((pNv->Chipset & 0xfff0) == CHIPSET_C512))
1003 for(i = 0; i < regions; i++) {
1004 pNv->PFB[(0x0600 + (i * 0x10))/4] = 0;
1005 pNv->PFB[(0x0604 + (i * 0x10))/4] = pNv->VRAMPhysicalSize - 1;
1008 /* end of surfaces */
1010 if(pNv->Architecture < NV_ARCH_10) {
1011 if((pNv->Chipset & 0x0fff) == CHIPSET_NV04) {
1012 /*XXX: RAMIN access here, find out what it's for.
1013 * The DRM is handling RAMIN now
1015 pNv->PRAMIN[0x0824] |= 0x00020000;
1016 pNv->PRAMIN[0x0826] += pNv->VRAMPhysical;
1018 pNv->PGRAPH[0x0080/4] = 0x000001FF;
1019 pNv->PGRAPH[0x0080/4] = 0x1230C000;
1020 pNv->PGRAPH[0x0084/4] = 0x72111101;
1021 pNv->PGRAPH[0x0088/4] = 0x11D5F071;
1022 pNv->PGRAPH[0x008C/4] = 0x0004FF31;
1023 pNv->PGRAPH[0x008C/4] = 0x4004FF31;
1026 pNv->PGRAPH[0x0140/4] = 0x00000000;
1027 pNv->PGRAPH[0x0100/4] = 0xFFFFFFFF;
1029 pNv->PGRAPH[0x0170/4] = 0x10010100;
1030 pNv->PGRAPH[0x0710/4] = 0xFFFFFFFF;
1031 pNv->PGRAPH[0x0720/4] = 0x00000001;
1033 pNv->PGRAPH[0x0810/4] = 0x00000000;
1034 pNv->PGRAPH[0x0608/4] = 0xFFFFFFFF;
1036 pNv->PGRAPH[0x0080/4] = 0xFFFFFFFF;
1037 pNv->PGRAPH[0x0080/4] = 0x00000000;
1040 pNv->PGRAPH[0x0140/4] = 0x00000000;
1041 pNv->PGRAPH[0x0100/4] = 0xFFFFFFFF;
1043 pNv->PGRAPH[0x0144/4] = 0x10010100;
1044 pNv->PGRAPH[0x0714/4] = 0xFFFFFFFF;
1045 pNv->PGRAPH[0x0720/4] = 0x00000001;
1046 pNv->PGRAPH[0x0710/4] &= 0x0007ff00;
1047 pNv->PGRAPH[0x0710/4] |= 0x00020100;
1049 if(pNv->Architecture == NV_ARCH_10) {
1050 pNv->PGRAPH[0x0084/4] = 0x00118700;
1051 pNv->PGRAPH[0x0088/4] = 0x24E00810;
1052 pNv->PGRAPH[0x008C/4] = 0x55DE0030;
1054 /* nv10 second surfaces */
1055 /* this is a copy of the surfaces. What is it for ? */
1056 for(i = 0; i < 32; i++)
1057 pNv->PGRAPH[(0x0B00/4) + i] = pNv->PFB[(0x0240/4) + i];
1058 /* end of nv10 second surfaces */
1060 pNv->PGRAPH[0x640/4] = 0;
1061 pNv->PGRAPH[0x644/4] = 0;
1062 pNv->PGRAPH[0x684/4] = pNv->VRAMPhysicalSize - 1;
1063 pNv->PGRAPH[0x688/4] = pNv->VRAMPhysicalSize - 1;
1065 pNv->PGRAPH[0x0810/4] = 0x00000000;
1066 pNv->PGRAPH[0x0608/4] = 0xFFFFFFFF;
1068 if(pNv->Architecture >= NV_ARCH_40) {
1069 pNv->PGRAPH[0x0084/4] = 0x401287c0;
1070 pNv->PGRAPH[0x008C/4] = 0x60de8051;
1071 pNv->PGRAPH[0x0090/4] = 0x00008000;
1072 pNv->PGRAPH[0x0610/4] = 0x00be3c5f;
1074 j = pNv->REGS[0x1540/4] & 0xff;
1076 for(i = 0; !(j & 1); j >>= 1, i++);
1077 pNv->PGRAPH[0x5000/4] = i;
1080 if((pNv->Chipset & 0xfff0) == CHIPSET_NV40) {
1081 pNv->PGRAPH[0x09b0/4] = 0x83280fff;
1082 pNv->PGRAPH[0x09b4/4] = 0x000000a0;
1084 pNv->PGRAPH[0x0820/4] = 0x83280eff;
1085 pNv->PGRAPH[0x0824/4] = 0x000000a0;
1088 switch(pNv->Chipset & 0xfff0) {
1091 pNv->PGRAPH[0x09b8/4] = 0x0078e366;
1092 pNv->PGRAPH[0x09bc/4] = 0x0000014c;
1093 pNv->PFB[0x033C/4] &= 0xffff7fff;
1097 pNv->PGRAPH[0x0828/4] = 0x007596ff;
1098 pNv->PGRAPH[0x082C/4] = 0x00000108;
1104 pNv->PMC[0x1700/4] = pNv->PFB[0x020C/4];
1105 pNv->PMC[0x1704/4] = 0;
1106 pNv->PMC[0x1708/4] = 0;
1107 pNv->PMC[0x170C/4] = pNv->PFB[0x020C/4];
1108 pNv->PGRAPH[0x0860/4] = 0;
1109 pNv->PGRAPH[0x0864/4] = 0;
1110 temp = nvReadCurRAMDAC(pNv, 0x608);
1111 nvWriteCurRAMDAC(pNv, 0x608, temp | 0x00100000);
1114 pNv->PGRAPH[0x0828/4] = 0x0072cb77;
1115 pNv->PGRAPH[0x082C/4] = 0x00000108;
1118 pNv->PGRAPH[0x0860/4] = 0;
1119 pNv->PGRAPH[0x0864/4] = 0;
1120 temp = nvReadCurRAMDAC(pNv, 0x608);
1121 nvWriteCurRAMDAC(pNv, 0x608, temp | 0x00100000);
1126 temp = nvReadCurRAMDAC(pNv, 0x608);
1127 nvWriteCurRAMDAC(pNv, 0x608, temp | 0x00100000);
1128 pNv->PGRAPH[0x0828/4] = 0x07830610;
1129 pNv->PGRAPH[0x082C/4] = 0x0000016A;
1135 pNv->PGRAPH[0x0b38/4] = 0x2ffff800;
1136 pNv->PGRAPH[0x0b3c/4] = 0x00006000;
1137 pNv->PGRAPH[0x032C/4] = 0x01000000;
1139 if(pNv->Architecture == NV_ARCH_30) {
1140 pNv->PGRAPH[0x0084/4] = 0x40108700;
1141 pNv->PGRAPH[0x0890/4] = 0x00140000;
1142 pNv->PGRAPH[0x008C/4] = 0xf00e0431;
1143 pNv->PGRAPH[0x0090/4] = 0x00008000;
1144 pNv->PGRAPH[0x0610/4] = 0xf04b1f36;
1145 pNv->PGRAPH[0x0B80/4] = 0x1002d888;
1146 pNv->PGRAPH[0x0B88/4] = 0x62ff007f;
1148 pNv->PGRAPH[0x0084/4] = 0x00118700;
1149 pNv->PGRAPH[0x008C/4] = 0xF20E0431;
1150 pNv->PGRAPH[0x0090/4] = 0x00000000;
1151 pNv->PGRAPH[0x009C/4] = 0x00000040;
1153 if((pNv->Chipset & 0x0ff0) >= CHIPSET_NV25) {
1154 pNv->PGRAPH[0x0890/4] = 0x00080000;
1155 pNv->PGRAPH[0x0610/4] = 0x304B1FB6;
1156 pNv->PGRAPH[0x0B80/4] = 0x18B82880;
1157 pNv->PGRAPH[0x0B84/4] = 0x44000000;
1158 pNv->PGRAPH[0x0098/4] = 0x40000080;
1159 pNv->PGRAPH[0x0B88/4] = 0x000000ff;
1161 pNv->PGRAPH[0x0880/4] = 0x00080000;
1162 pNv->PGRAPH[0x0094/4] = 0x00000005;
1163 pNv->PGRAPH[0x0B80/4] = 0x45CAA208;
1164 pNv->PGRAPH[0x0B84/4] = 0x24000000;
1165 pNv->PGRAPH[0x0098/4] = 0x00000040;
1166 pNv->PGRAPH[0x0750/4] = 0x00E00038;
1167 pNv->PGRAPH[0x0754/4] = 0x00000030;
1168 pNv->PGRAPH[0x0750/4] = 0x00E10038;
1169 pNv->PGRAPH[0x0754/4] = 0x00000030;
1173 /* begin nv20+ secondr surfaces */
1174 /* again, a copy of the surfaces. */
1175 if((pNv->Architecture < NV_ARCH_40) ||
1176 ((pNv->Chipset & 0xfff0) == CHIPSET_NV40))
1178 for(i = 0; i < 32; i++) {
1179 pNv->PGRAPH[(0x0900/4) + i] = pNv->PFB[(0x0240/4) + i];
1180 pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0240/4) + i];
1183 if(((pNv->Chipset & 0xfff0) == CHIPSET_G70) ||
1184 ((pNv->Chipset & 0xfff0) == CHIPSET_G71) ||
1185 ((pNv->Chipset & 0xfff0) == CHIPSET_G72) ||
1186 ((pNv->Chipset & 0xfff0) == CHIPSET_G73) ||
1187 ((pNv->Chipset & 0xfff0) == CHIPSET_C512))
1189 for(i = 0; i < 60; i++) {
1190 pNv->PGRAPH[(0x0D00/4) + i] = pNv->PFB[(0x0600/4) + i];
1191 pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0600/4) + i];
1194 for(i = 0; i < 48; i++) {
1195 pNv->PGRAPH[(0x0900/4) + i] = pNv->PFB[(0x0600/4) + i];
1196 if(((pNv->Chipset & 0xfff0) != CHIPSET_NV44) &&
1197 ((pNv->Chipset & 0xfff0) != CHIPSET_NV44A) &&
1198 ((pNv->Chipset & 0xfff0) != CHIPSET_C51))
1200 pNv->PGRAPH[(0x6900/4) + i] = pNv->PFB[(0x0600/4) + i];
1205 /* end nv20+ second surfaces */
1207 /* begin RAM config */
1208 if(pNv->Architecture >= NV_ARCH_40) {
1209 if((pNv->Chipset & 0xfff0) == CHIPSET_NV40) {
1210 pNv->PGRAPH[0x09A4/4] = pNv->PFB[0x0200/4];
1211 pNv->PGRAPH[0x09A8/4] = pNv->PFB[0x0204/4];
1212 pNv->PGRAPH[0x69A4/4] = pNv->PFB[0x0200/4];
1213 pNv->PGRAPH[0x69A8/4] = pNv->PFB[0x0204/4];
1215 pNv->PGRAPH[0x0820/4] = 0;
1216 pNv->PGRAPH[0x0824/4] = 0;
1217 pNv->PGRAPH[0x0864/4] = pNv->VRAMPhysicalSize - 1;
1218 pNv->PGRAPH[0x0868/4] = pNv->VRAMPhysicalSize - 1;
1220 if(((pNv->Chipset & 0xfff0) == CHIPSET_G70) ||
1221 ((pNv->Chipset & 0xfff0) == CHIPSET_G71) ||
1222 ((pNv->Chipset & 0xfff0) == CHIPSET_G72) ||
1223 ((pNv->Chipset & 0xfff0) == CHIPSET_G73))
1225 pNv->PGRAPH[0x0DF0/4] = pNv->PFB[0x0200/4];
1226 pNv->PGRAPH[0x0DF4/4] = pNv->PFB[0x0204/4];
1228 pNv->PGRAPH[0x09F0/4] = pNv->PFB[0x0200/4];
1229 pNv->PGRAPH[0x09F4/4] = pNv->PFB[0x0204/4];
1231 pNv->PGRAPH[0x69F0/4] = pNv->PFB[0x0200/4];
1232 pNv->PGRAPH[0x69F4/4] = pNv->PFB[0x0204/4];
1234 pNv->PGRAPH[0x0840/4] = 0;
1235 pNv->PGRAPH[0x0844/4] = 0;
1236 pNv->PGRAPH[0x08a0/4] = pNv->VRAMPhysicalSize - 1;
1237 pNv->PGRAPH[0x08a4/4] = pNv->VRAMPhysicalSize - 1;
1240 pNv->PGRAPH[0x09A4/4] = pNv->PFB[0x0200/4];
1241 pNv->PGRAPH[0x09A8/4] = pNv->PFB[0x0204/4];
1242 pNv->PGRAPH[0x0750/4] = 0x00EA0000;
1243 pNv->PGRAPH[0x0754/4] = pNv->PFB[0x0200/4];
1244 pNv->PGRAPH[0x0750/4] = 0x00EA0004;
1245 pNv->PGRAPH[0x0754/4] = pNv->PFB[0x0204/4];
1247 pNv->PGRAPH[0x0820/4] = 0;
1248 pNv->PGRAPH[0x0824/4] = 0;
1249 pNv->PGRAPH[0x0864/4] = pNv->VRAMPhysicalSize - 1;
1250 pNv->PGRAPH[0x0868/4] = pNv->VRAMPhysicalSize - 1;
1252 /* end of RAM config */
1254 pNv->PGRAPH[0x0B20/4] = 0x00000000;
1255 pNv->PGRAPH[0x0B04/4] = 0xFFFFFFFF;
1259 /* begin clipping values */
1260 pNv->PGRAPH[0x053C/4] = 0;
1261 pNv->PGRAPH[0x0540/4] = 0;
1262 pNv->PGRAPH[0x0544/4] = 0x00007FFF;
1263 pNv->PGRAPH[0x0548/4] = 0x00007FFF;
1264 /* end of clipping values */
1266 /* Seems we have to reinit some/all of the FIFO regs on a mode switch */
1267 drmCommandNone(pNv->drm_fd, DRM_NOUVEAU_PFIFO_REINIT);
1269 if(pNv->Architecture >= NV_ARCH_10) {
1271 pNv->PCRTC0[0x0860/4] = state->head;
1272 pNv->PCRTC0[0x2860/4] = state->head2;
1274 temp = nvReadCurRAMDAC(pNv, 0x404);
1275 nvWriteCurRAMDAC(pNv, 0x404, temp | (1 << 25));
1277 pNv->PMC[0x8704/4] = 1;
1278 pNv->PMC[0x8140/4] = 0;
1279 pNv->PMC[0x8920/4] = 0;
1280 pNv->PMC[0x8924/4] = 0;
1281 pNv->PMC[0x8908/4] = pNv->VRAMPhysicalSize - 1;
1282 pNv->PMC[0x890C/4] = pNv->VRAMPhysicalSize - 1;
1283 pNv->PMC[0x1588/4] = 0;
1285 pNv->PCRTC[0x0810/4] = state->cursorConfig;
1286 pNv->PCRTC[0x0830/4] = state->displayV - 3;
1287 pNv->PCRTC[0x0834/4] = state->displayV - 1;
1289 if(pNv->FlatPanel) {
1290 if((pNv->Chipset & 0x0ff0) == CHIPSET_NV11) {
1291 nvWriteCurRAMDAC(pNv, 0x528, state->dither);
1294 nvWriteCurRAMDAC(pNv, 0x83C, state->dither);
1297 nvWriteVGA(pNv, 0x53, state->timingH);
1298 nvWriteVGA(pNv, 0x54, state->timingV);
1299 nvWriteVGA(pNv, 0x21, 0xfa);
1302 nvWriteVGA(pNv, 0x41, state->extra);
1305 nvWriteVGA(pNv, 0x19, state->repaint0);
1306 nvWriteVGA(pNv, 0x1A, state->repaint1);
1307 nvWriteVGA(pNv, 0x25, state->screen);
1308 nvWriteVGA(pNv, 0x28, state->pixel);
1309 nvWriteVGA(pNv, 0x2D, state->horiz);
1310 nvWriteVGA(pNv, 0x1C, state->fifo);
1311 nvWriteVGA(pNv, 0x1B, state->arbitration0);
1312 nvWriteVGA(pNv, 0x20, state->arbitration1);
1313 if(pNv->Architecture >= NV_ARCH_30) {
1314 nvWriteVGA(pNv, 0x47, state->arbitration1 >> 8);
1317 nvWriteVGA(pNv, 0x30, state->cursor0);
1318 nvWriteVGA(pNv, 0x31, state->cursor1);
1319 nvWriteVGA(pNv, 0x2F, state->cursor2);
1320 nvWriteVGA(pNv, 0x39, state->interlace);
1322 if(!pNv->FlatPanel) {
1323 nvWriteRAMDAC0(pNv, 0x50C, state->pllsel);
1324 nvWriteRAMDAC0(pNv, 0x508, state->vpll);
1326 nvWriteRAMDAC0(pNv, 0x520, state->vpll2);
1327 if(pNv->twoStagePLL) {
1328 nvWriteRAMDAC0(pNv, 0x578, state->vpllB);
1329 nvWriteRAMDAC0(pNv, 0x57C, state->vpll2B);
1332 nvWriteCurRAMDAC(pNv, 0x848, state->scale);
1333 nvWriteCurRAMDAC(pNv, 0x828, state->crtcSync);
1335 nvWriteCurRAMDAC(pNv, 0x600, state->general);
1337 pNv->PCRTC[0x0140/4] = 0;
1338 pNv->PCRTC[0x0100/4] = 1;
1340 pNv->CurrentState = state;
1343 void NVUnloadStateExt
1346 RIVA_HW_STATE *state
1349 state->repaint0 = nvReadVGA(pNv, 0x19);
1350 state->repaint1 = nvReadVGA(pNv, 0x1A);
1351 state->screen = nvReadVGA(pNv, 0x25);
1352 state->pixel = nvReadVGA(pNv, 0x28);
1353 state->horiz = nvReadVGA(pNv, 0x2D);
1354 state->fifo = nvReadVGA(pNv, 0x1C);
1355 state->arbitration0 = nvReadVGA(pNv, 0x1B);
1356 state->arbitration1 = nvReadVGA(pNv, 0x20);
1357 if(pNv->Architecture >= NV_ARCH_30) {
1358 state->arbitration1 |= (nvReadVGA(pNv, 0x47) & 1) << 8;
1360 state->cursor0 = nvReadVGA(pNv, 0x30);
1361 state->cursor1 = nvReadVGA(pNv, 0x31);
1362 state->cursor2 = nvReadVGA(pNv, 0x2F);
1363 state->interlace = nvReadVGA(pNv, 0x39);
1365 state->vpll = nvReadRAMDAC0(pNv, 0x0508);
1367 state->vpll2 = nvReadRAMDAC0(pNv, 0x0520);
1368 if(pNv->twoStagePLL) {
1369 state->vpllB = nvReadRAMDAC0(pNv, 0x0578);
1370 state->vpll2B = nvReadRAMDAC0(pNv, 0x057C);
1372 state->pllsel = nvReadRAMDAC0(pNv, 0x050C);
1373 state->general = nvReadCurRAMDAC(pNv, 0x0600);
1374 state->scale = nvReadCurRAMDAC(pNv, 0x0848);
1375 state->config = pNv->PFB[0x0200/4];
1377 if(pNv->Architecture >= NV_ARCH_10) {
1379 state->head = pNv->PCRTC0[0x0860/4];
1380 state->head2 = pNv->PCRTC0[0x2860/4];
1381 state->crtcOwner = nvReadVGA(pNv, 0x44);
1383 state->extra = nvReadVGA(pNv, 0x41);
1385 state->cursorConfig = pNv->PCRTC[0x0810/4];
1387 if((pNv->Chipset & 0x0ff0) == CHIPSET_NV11) {
1388 state->dither = nvReadCurRAMDAC(pNv, 0x0528);
1391 state->dither = nvReadCurRAMDAC(pNv, 0x083C);
1394 if(pNv->FlatPanel) {
1395 state->timingH = nvReadVGA(pNv, 0x53);
1396 state->timingV = nvReadVGA(pNv, 0x54);
1400 if(pNv->FlatPanel) {
1401 state->crtcSync = nvReadCurRAMDAC(pNv, 0x0828);
1405 void NVSetStartAddress (
1410 pNv->PCRTC[0x800/4] = start;