1 /***************************************************************************\
3 |* Copyright 1993-1999 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-1999 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 \***************************************************************************/
41 * GPL licensing note -- nVidia is allowing a liberal interpretation of
42 * the documentation restriction above, to merely say that this nVidia's
43 * copyright and disclaimer should be included with all code derived
44 * from this source. -- Jeff Garzik <jgarzik@pobox.com>, 01/Nov/99
47 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/riva_hw.c,v 1.33 2002/08/05 20:47:06 mvojkovi Exp $ */
49 #include <linux/pci.h>
50 #include <linux/pci_ids.h>
56 * This file is an OS-agnostic file used to make RIVA 128 and RIVA TNT
57 * operate identically (except TNT has more memory and better 3D quality.
64 return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x000006B0/4] & 0x01));
71 return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
78 return ((chip->Rop->FifoFree < chip->FifoEmptyCount) || (chip->PGRAPH[0x00000700/4] & 0x01));
81 static void vgaLockUnlock
88 VGA_WR08(chip->PCIO, 0x3D4, 0x11);
89 cr11 = VGA_RD08(chip->PCIO, 0x3D5);
90 if(Lock) cr11 |= 0x80;
92 VGA_WR08(chip->PCIO, 0x3D5, cr11);
94 static void nv3LockUnlock
100 VGA_WR08(chip->PVIO, 0x3C4, 0x06);
101 VGA_WR08(chip->PVIO, 0x3C5, Lock ? 0x99 : 0x57);
102 vgaLockUnlock(chip, Lock);
104 static void nv4LockUnlock
110 VGA_WR08(chip->PCIO, 0x3D4, 0x1F);
111 VGA_WR08(chip->PCIO, 0x3D5, Lock ? 0x99 : 0x57);
112 vgaLockUnlock(chip, Lock);
115 static int ShowHideCursor
122 cursor = chip->CurrentState->cursor1;
123 chip->CurrentState->cursor1 = (chip->CurrentState->cursor1 & 0xFE) |
125 VGA_WR08(chip->PCIO, 0x3D4, 0x31);
126 VGA_WR08(chip->PCIO, 0x3D5, chip->CurrentState->cursor1);
127 return (cursor & 0x01);
130 /****************************************************************************\
132 * The video arbitration routines calculate some "magic" numbers. Fixes *
133 * the snow seen when accessing the framebuffer without it. *
134 * It just works (I hope). *
136 \****************************************************************************/
138 #define DEFAULT_GR_LWM 100
139 #define DEFAULT_VID_LWM 100
140 #define DEFAULT_GR_BURST_SIZE 256
141 #define DEFAULT_VID_BURST_SIZE 128
146 #define GFIFO_SIZE 320
147 #define GFIFO_SIZE_128 256
148 #define MFIFO_SIZE 120
149 #define VFIFO_SIZE 256
150 #define ABS(a) (a>0?a:-a)
159 int wcmocc, wcgocc, wcvocc, wcvlwm, wcglwm;
177 int graphics_burst_size;
178 int video_burst_size;
179 int graphics_hi_priority;
180 int media_hi_priority;
200 int graphics_burst_size;
201 int video_burst_size;
220 int graphics_burst_size;
221 int video_burst_size;
238 static int nv3_iterate(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_arb_info *ainfo)
242 int vfsize, mfsize, gfsize;
243 int mburst_size = 32;
244 int mmisses, gmisses, vmisses;
246 int vlwm, glwm, mlwm;
260 if (ainfo->gburst_size == 128) max_gfsize = GFIFO_SIZE_128;
261 else max_gfsize = GFIFO_SIZE;
262 max_gfsize = GFIFO_SIZE;
267 if (ainfo->wcvocc > ainfo->vocc) ainfo->wcvocc = ainfo->vocc;
268 if (ainfo->wcvlwm > vlwm) ainfo->wcvlwm = vlwm ;
269 ns = 1000000 * ainfo->vburst_size/(state->memory_width/8)/state->mclk_khz;
270 vfsize = ns * ainfo->vdrain_rate / 1000000;
271 vfsize = ainfo->wcvlwm - ainfo->vburst_size + vfsize;
273 if (state->enable_mp)
275 if (ainfo->wcmocc > ainfo->mocc) ainfo->wcmocc = ainfo->mocc;
279 if (ainfo->wcglwm > glwm) ainfo->wcglwm = glwm ;
280 if (ainfo->wcgocc > ainfo->gocc) ainfo->wcgocc = ainfo->gocc;
281 ns = 1000000 * (ainfo->gburst_size/(state->memory_width/8))/state->mclk_khz;
282 gfsize = (ns * (long) ainfo->gdrain_rate)/1000000;
283 gfsize = ainfo->wcglwm - ainfo->gburst_size + gfsize;
286 if (!state->gr_during_vid && ainfo->vid_en)
287 if (ainfo->vid_en && (ainfo->vocc < 0) && !ainfo->vid_only_once)
289 else if (ainfo->mocc < 0)
291 else if (ainfo->gocc< ainfo->by_gfacc)
294 else switch (ainfo->priority)
297 if (ainfo->vid_en && ainfo->vocc<0 && !ainfo->vid_only_once)
299 else if (ainfo->gr_en && ainfo->gocc<0 && !ainfo->gr_only_once)
301 else if (ainfo->mocc<0)
306 if (ainfo->gr_en && ainfo->gocc<0 && !ainfo->gr_only_once)
308 else if (ainfo->vid_en && ainfo->vocc<0 && !ainfo->vid_only_once)
310 else if (ainfo->mocc<0)
317 else if (ainfo->gr_en && ainfo->gocc<0 && !ainfo->gr_only_once)
319 else if (ainfo->vid_en && ainfo->vocc<0 && !ainfo->vid_only_once)
330 if (last==cur) misses = 0;
331 else if (ainfo->first_vacc) misses = vmisses;
333 ainfo->first_vacc = 0;
336 ns = 1000000 * (vmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz;
337 vlwm = ns * ainfo->vdrain_rate/ 1000000;
338 vlwm = ainfo->vocc - vlwm;
340 ns = 1000000*(misses*state->mem_page_miss + ainfo->vburst_size)/(state->memory_width/8)/state->mclk_khz;
341 ainfo->vocc = ainfo->vocc + ainfo->vburst_size - ns*ainfo->vdrain_rate/1000000;
342 ainfo->gocc = ainfo->gocc - ns*ainfo->gdrain_rate/1000000;
343 ainfo->mocc = ainfo->mocc - ns*ainfo->mdrain_rate/1000000;
346 if (last==cur) misses = 0;
347 else if (ainfo->first_gacc) misses = gmisses;
349 ainfo->first_gacc = 0;
352 ns = 1000000*(gmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz ;
353 glwm = ns * ainfo->gdrain_rate/1000000;
354 glwm = ainfo->gocc - glwm;
356 ns = 1000000*(misses*state->mem_page_miss + ainfo->gburst_size/(state->memory_width/8))/state->mclk_khz;
357 ainfo->vocc = ainfo->vocc + 0 - ns*ainfo->vdrain_rate/1000000;
358 ainfo->gocc = ainfo->gocc + ainfo->gburst_size - ns*ainfo->gdrain_rate/1000000;
359 ainfo->mocc = ainfo->mocc + 0 - ns*ainfo->mdrain_rate/1000000;
362 if (last==cur) misses = 0;
363 else if (ainfo->first_macc) misses = mmisses;
365 ainfo->first_macc = 0;
366 ns = 1000000*(misses*state->mem_page_miss + mburst_size/(state->memory_width/8))/state->mclk_khz;
367 ainfo->vocc = ainfo->vocc + 0 - ns*ainfo->vdrain_rate/1000000;
368 ainfo->gocc = ainfo->gocc + 0 - ns*ainfo->gdrain_rate/1000000;
369 ainfo->mocc = ainfo->mocc + mburst_size - ns*ainfo->mdrain_rate/1000000;
374 ainfo->converged = 0;
377 ns = 1000000*ainfo->gburst_size/(state->memory_width/8)/state->mclk_khz;
378 tmp = ns * ainfo->gdrain_rate/1000000;
379 if (ABS(ainfo->gburst_size) + ((ABS(ainfo->wcglwm) + 16 ) & ~0x7) - tmp > max_gfsize)
381 ainfo->converged = 0;
384 ns = 1000000*ainfo->vburst_size/(state->memory_width/8)/state->mclk_khz;
385 tmp = ns * ainfo->vdrain_rate/1000000;
386 if (ABS(ainfo->vburst_size) + (ABS(ainfo->wcvlwm + 32) & ~0xf) - tmp> VFIFO_SIZE)
388 ainfo->converged = 0;
391 if (ABS(ainfo->gocc) > max_gfsize)
393 ainfo->converged = 0;
396 if (ABS(ainfo->vocc) > VFIFO_SIZE)
398 ainfo->converged = 0;
401 if (ABS(ainfo->mocc) > MFIFO_SIZE)
403 ainfo->converged = 0;
406 if (ABS(vfsize) > VFIFO_SIZE)
408 ainfo->converged = 0;
411 if (ABS(gfsize) > max_gfsize)
413 ainfo->converged = 0;
416 if (ABS(mfsize) > MFIFO_SIZE)
418 ainfo->converged = 0;
423 static char nv3_arb(nv3_fifo_info * res_info, nv3_sim_state * state, nv3_arb_info *ainfo)
425 long ens, vns, mns, gns;
426 int mmisses, gmisses, vmisses, eburst_size, mburst_size;
430 refresh_cycle = 2*(state->mclk_khz/state->pclk_khz) + 5;
432 if (state->mem_aligned) gmisses = 2;
435 eburst_size = state->memory_width * 1;
437 gns = 1000000 * (gmisses*state->mem_page_miss + state->mem_latency)/state->mclk_khz;
438 ainfo->by_gfacc = gns*ainfo->gdrain_rate/1000000;
444 ainfo->engine_en = 1;
445 ainfo->converged = 1;
446 if (ainfo->engine_en)
448 ens = 1000000*(state->mem_page_miss + eburst_size/(state->memory_width/8) +refresh_cycle)/state->mclk_khz;
449 ainfo->mocc = state->enable_mp ? 0-ens*ainfo->mdrain_rate/1000000 : 0;
450 ainfo->vocc = ainfo->vid_en ? 0-ens*ainfo->vdrain_rate/1000000 : 0;
451 ainfo->gocc = ainfo->gr_en ? 0-ens*ainfo->gdrain_rate/1000000 : 0;
453 ainfo->first_vacc = 1;
454 ainfo->first_gacc = 1;
455 ainfo->first_macc = 1;
456 nv3_iterate(res_info, state,ainfo);
458 if (state->enable_mp)
460 mns = 1000000 * (mmisses*state->mem_page_miss + mburst_size/(state->memory_width/8) + refresh_cycle)/state->mclk_khz;
461 ainfo->mocc = state->enable_mp ? 0 : mburst_size - mns*ainfo->mdrain_rate/1000000;
462 ainfo->vocc = ainfo->vid_en ? 0 : 0- mns*ainfo->vdrain_rate/1000000;
463 ainfo->gocc = ainfo->gr_en ? 0: 0- mns*ainfo->gdrain_rate/1000000;
465 ainfo->first_vacc = 1;
466 ainfo->first_gacc = 1;
467 ainfo->first_macc = 0;
468 nv3_iterate(res_info, state,ainfo);
472 ainfo->first_vacc = 1;
473 ainfo->first_gacc = 0;
474 ainfo->first_macc = 1;
475 gns = 1000000*(gmisses*state->mem_page_miss + ainfo->gburst_size/(state->memory_width/8) + refresh_cycle)/state->mclk_khz;
476 ainfo->gocc = ainfo->gburst_size - gns*ainfo->gdrain_rate/1000000;
477 ainfo->vocc = ainfo->vid_en? 0-gns*ainfo->vdrain_rate/1000000 : 0;
478 ainfo->mocc = state->enable_mp ? 0-gns*ainfo->mdrain_rate/1000000: 0;
479 ainfo->cur = GRAPHICS;
480 nv3_iterate(res_info, state,ainfo);
484 ainfo->first_vacc = 0;
485 ainfo->first_gacc = 1;
486 ainfo->first_macc = 1;
487 vns = 1000000*(vmisses*state->mem_page_miss + ainfo->vburst_size/(state->memory_width/8) + refresh_cycle)/state->mclk_khz;
488 ainfo->vocc = ainfo->vburst_size - vns*ainfo->vdrain_rate/1000000;
489 ainfo->gocc = ainfo->gr_en? (0-vns*ainfo->gdrain_rate/1000000) : 0;
490 ainfo->mocc = state->enable_mp? 0-vns*ainfo->mdrain_rate/1000000 :0 ;
492 nv3_iterate(res_info, state, ainfo);
494 if (ainfo->converged)
496 res_info->graphics_lwm = (int)ABS(ainfo->wcglwm) + 16;
497 res_info->video_lwm = (int)ABS(ainfo->wcvlwm) + 32;
498 res_info->graphics_burst_size = ainfo->gburst_size;
499 res_info->video_burst_size = ainfo->vburst_size;
500 res_info->graphics_hi_priority = (ainfo->priority == GRAPHICS);
501 res_info->media_hi_priority = (ainfo->priority == MPORT);
502 if (res_info->video_lwm > 160)
504 res_info->graphics_lwm = 256;
505 res_info->video_lwm = 128;
506 res_info->graphics_burst_size = 64;
507 res_info->video_burst_size = 64;
508 res_info->graphics_hi_priority = 0;
509 res_info->media_hi_priority = 0;
510 ainfo->converged = 0;
513 if (res_info->video_lwm > 128)
515 res_info->video_lwm = 128;
521 res_info->graphics_lwm = 256;
522 res_info->video_lwm = 128;
523 res_info->graphics_burst_size = 64;
524 res_info->video_burst_size = 64;
525 res_info->graphics_hi_priority = 0;
526 res_info->media_hi_priority = 0;
530 static char nv3_get_param(nv3_fifo_info *res_info, nv3_sim_state * state, nv3_arb_info *ainfo)
535 for (p=0; p < 2; p++)
537 for (g=128 ; g > 32; g= g>> 1)
539 for (v=128; v >=32; v = v>> 1)
542 ainfo->gburst_size = g;
543 ainfo->vburst_size = v;
544 done = nv3_arb(res_info, state,ainfo);
545 if (done && (g==128))
546 if ((res_info->graphics_lwm + g) > 256)
557 static void nv3CalcArbitration
559 nv3_fifo_info * res_info,
560 nv3_sim_state * state
563 nv3_fifo_info save_info;
565 char res_gr, res_vid;
568 ainfo.vid_en = state->enable_video;
569 ainfo.vid_only_once = 0;
570 ainfo.gr_only_once = 0;
571 ainfo.gdrain_rate = (int) state->pclk_khz * (state->pix_bpp/8);
572 ainfo.vdrain_rate = (int) state->pclk_khz * 2;
573 if (state->video_scale != 0)
574 ainfo.vdrain_rate = ainfo.vdrain_rate/state->video_scale;
575 ainfo.mdrain_rate = 33000;
576 res_info->rtl_values = 0;
577 if (!state->gr_during_vid && state->enable_video)
579 ainfo.gr_only_once = 1;
581 ainfo.gdrain_rate = 0;
582 res_vid = nv3_get_param(res_info, state, &ainfo);
583 res_vid = ainfo.converged;
584 save_info.video_lwm = res_info->video_lwm;
585 save_info.video_burst_size = res_info->video_burst_size;
587 ainfo.vid_only_once = 1;
589 ainfo.gdrain_rate = (int) state->pclk_khz * (state->pix_bpp/8);
590 ainfo.vdrain_rate = 0;
591 res_gr = nv3_get_param(res_info, state, &ainfo);
592 res_gr = ainfo.converged;
593 res_info->video_lwm = save_info.video_lwm;
594 res_info->video_burst_size = save_info.video_burst_size;
595 res_info->valid = res_gr & res_vid;
599 if (!ainfo.gr_en) ainfo.gdrain_rate = 0;
600 if (!ainfo.vid_en) ainfo.vdrain_rate = 0;
601 res_gr = nv3_get_param(res_info, state, &ainfo);
602 res_info->valid = ainfo.converged;
605 static void nv3UpdateArbitrationSettings
614 nv3_fifo_info fifo_data;
615 nv3_sim_state sim_data;
616 unsigned int M, N, P, pll, MClk;
618 pll = chip->PRAMDAC0[0x00000504/4];
619 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
620 MClk = (N * chip->CrystalFreqKHz / M) >> P;
621 sim_data.pix_bpp = (char)pixelDepth;
622 sim_data.enable_video = 0;
623 sim_data.enable_mp = 0;
624 sim_data.video_scale = 1;
625 sim_data.memory_width = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
626 sim_data.memory_width = 128;
628 sim_data.mem_latency = 9;
629 sim_data.mem_aligned = 1;
630 sim_data.mem_page_miss = 11;
631 sim_data.gr_during_vid = 0;
632 sim_data.pclk_khz = VClk;
633 sim_data.mclk_khz = MClk;
634 nv3CalcArbitration(&fifo_data, &sim_data);
637 int b = fifo_data.graphics_burst_size >> 4;
639 while (b >>= 1) (*burst)++;
640 *lwm = fifo_data.graphics_lwm >> 3;
648 static void nv4CalcArbitration
654 int data, pagemiss, cas,width, video_enable, color_key_enable, bpp, align;
655 int nvclks, mclks, pclks, vpagemiss, crtpagemiss, vbs;
656 int found, mclk_extra, mclk_loop, cbs, m1, p1;
657 int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
658 int us_m, us_n, us_p, video_drain_rate, crtc_drain_rate;
659 int vpm_us, us_video, vlwm, video_fill_us, cpm_us, us_crt,clwm;
663 pclk_freq = arb->pclk_khz;
664 mclk_freq = arb->mclk_khz;
665 nvclk_freq = arb->nvclk_khz;
666 pagemiss = arb->mem_page_miss;
667 cas = arb->mem_latency;
668 width = arb->memory_width >> 6;
669 video_enable = arb->enable_video;
670 color_key_enable = arb->gr_during_vid;
672 align = arb->mem_aligned;
673 mp_enable = arb->enable_mp;
704 mclk_loop = mclks+mclk_extra;
705 us_m = mclk_loop *1000*1000 / mclk_freq;
706 us_n = nvclks*1000*1000 / nvclk_freq;
707 us_p = nvclks*1000*1000 / pclk_freq;
710 video_drain_rate = pclk_freq * 2;
711 crtc_drain_rate = pclk_freq * bpp/8;
715 vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
716 if (nvclk_freq * 2 > mclk_freq * width)
717 video_fill_us = cbs*1000*1000 / 16 / nvclk_freq ;
719 video_fill_us = cbs*1000*1000 / (8 * width) / mclk_freq;
720 us_video = vpm_us + us_m + us_n + us_p + video_fill_us;
721 vlwm = us_video * video_drain_rate/(1000*1000);
724 if (vlwm > 128) vbs = 64;
725 if (vlwm > (256-64)) vbs = 32;
726 if (nvclk_freq * 2 > mclk_freq * width)
727 video_fill_us = vbs *1000*1000/ 16 / nvclk_freq ;
729 video_fill_us = vbs*1000*1000 / (8 * width) / mclk_freq;
730 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
737 clwm = us_crt * crtc_drain_rate/(1000*1000);
742 crtc_drain_rate = pclk_freq * bpp/8;
745 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
746 us_crt = cpm_us + us_m + us_n + us_p ;
747 clwm = us_crt * crtc_drain_rate/(1000*1000);
750 m1 = clwm + cbs - 512;
751 p1 = m1 * pclk_freq / mclk_freq;
753 if ((p1 < m1) && (m1 > 0))
757 if (mclk_extra ==0) found = 1;
760 else if (video_enable)
762 if ((clwm > 511) || (vlwm > 255))
766 if (mclk_extra ==0) found = 1;
776 if (mclk_extra ==0) found = 1;
782 if (clwm < 384) clwm = 384;
783 if (vlwm < 128) vlwm = 128;
785 fifo->graphics_lwm = data;
786 fifo->graphics_burst_size = 128;
787 data = (int)((vlwm+15));
788 fifo->video_lwm = data;
789 fifo->video_burst_size = vbs;
792 static void nv4UpdateArbitrationSettings
801 nv4_fifo_info fifo_data;
802 nv4_sim_state sim_data;
803 unsigned int M, N, P, pll, MClk, NVClk, cfg1;
805 pll = chip->PRAMDAC0[0x00000504/4];
806 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
807 MClk = (N * chip->CrystalFreqKHz / M) >> P;
808 pll = chip->PRAMDAC0[0x00000500/4];
809 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
810 NVClk = (N * chip->CrystalFreqKHz / M) >> P;
811 cfg1 = chip->PFB[0x00000204/4];
812 sim_data.pix_bpp = (char)pixelDepth;
813 sim_data.enable_video = 0;
814 sim_data.enable_mp = 0;
815 sim_data.memory_width = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
816 sim_data.mem_latency = (char)cfg1 & 0x0F;
817 sim_data.mem_aligned = 1;
818 sim_data.mem_page_miss = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
819 sim_data.gr_during_vid = 0;
820 sim_data.pclk_khz = VClk;
821 sim_data.mclk_khz = MClk;
822 sim_data.nvclk_khz = NVClk;
823 nv4CalcArbitration(&fifo_data, &sim_data);
826 int b = fifo_data.graphics_burst_size >> 4;
828 while (b >>= 1) (*burst)++;
829 *lwm = fifo_data.graphics_lwm >> 3;
832 static void nv10CalcArbitration
834 nv10_fifo_info *fifo,
838 int data, pagemiss, cas,width, video_enable, color_key_enable, bpp, align;
839 int nvclks, mclks, pclks, vpagemiss, crtpagemiss, vbs;
840 int nvclk_fill, us_extra;
841 int found, mclk_extra, mclk_loop, cbs, m1;
842 int mclk_freq, pclk_freq, nvclk_freq, mp_enable;
843 int us_m, us_m_min, us_n, us_p, video_drain_rate, crtc_drain_rate;
844 int vus_m, vus_n, vus_p;
845 int vpm_us, us_video, vlwm, cpm_us, us_crt,clwm;
847 int craw, m2us, us_pipe, us_pipe_min, vus_pipe, p1clk, p2;
848 int pclks_2_top_fifo, min_mclk_extra;
849 int us_min_mclk_extra;
852 pclk_freq = arb->pclk_khz; /* freq in KHz */
853 mclk_freq = arb->mclk_khz;
854 nvclk_freq = arb->nvclk_khz;
855 pagemiss = arb->mem_page_miss;
856 cas = arb->mem_latency;
857 width = arb->memory_width/64;
858 video_enable = arb->enable_video;
859 color_key_enable = arb->gr_during_vid;
861 align = arb->mem_aligned;
862 mp_enable = arb->enable_mp;
869 pclks = 4; /* lwm detect. */
871 nvclks = 3; /* lwm -> sync. */
872 nvclks += 2; /* fbi bus cycles (1 req + 1 busy) */
874 mclks = 1; /* 2 edge sync. may be very close to edge so just put one. */
876 mclks += 1; /* arb_hp_req */
877 mclks += 5; /* ap_hp_req tiling pipeline */
879 mclks += 2; /* tc_req latency fifo */
880 mclks += 2; /* fb_cas_n_ memory request to fbio block */
881 mclks += 7; /* sm_d_rdv data returned from fbio block */
883 /* fb.rd.d.Put_gc need to accumulate 256 bits for read */
884 if (arb->memory_type == 0)
885 if (arb->memory_width == 64) /* 64 bit bus */
890 if (arb->memory_width == 64) /* 64 bit bus */
895 if ((!video_enable) && (arb->memory_width == 128))
897 mclk_extra = (bpp == 32) ? 31 : 42; /* Margin of error */
902 mclk_extra = (bpp == 32) ? 8 : 4; /* Margin of error */
903 /* mclk_extra = 4; */ /* Margin of error */
907 nvclks += 1; /* 2 edge sync. may be very close to edge so just put one. */
908 nvclks += 1; /* fbi_d_rdv_n */
909 nvclks += 1; /* Fbi_d_rdata */
910 nvclks += 1; /* crtfifo load */
913 mclks+=4; /* Mp can get in with a burst of 8. */
914 /* Extra clocks determined by heuristics */
922 mclk_loop = mclks+mclk_extra;
923 us_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
924 us_m_min = mclks * 1000*1000 / mclk_freq; /* Minimum Mclk latency in us */
925 us_min_mclk_extra = min_mclk_extra *1000*1000 / mclk_freq;
926 us_n = nvclks*1000*1000 / nvclk_freq;/* nvclk latency in us */
927 us_p = pclks*1000*1000 / pclk_freq;/* nvclk latency in us */
928 us_pipe = us_m + us_n + us_p;
929 us_pipe_min = us_m_min + us_n + us_p;
932 vus_m = mclk_loop *1000*1000 / mclk_freq; /* Mclk latency in us */
933 vus_n = (4)*1000*1000 / nvclk_freq;/* nvclk latency in us */
934 vus_p = 0*1000*1000 / pclk_freq;/* pclk latency in us */
935 vus_pipe = vus_m + vus_n + vus_p;
938 video_drain_rate = pclk_freq * 4; /* MB/s */
939 crtc_drain_rate = pclk_freq * bpp/8; /* MB/s */
941 vpagemiss = 1; /* self generating page miss */
942 vpagemiss += 1; /* One higher priority before */
944 crtpagemiss = 2; /* self generating page miss */
946 crtpagemiss += 1; /* if MA0 conflict */
948 vpm_us = (vpagemiss * pagemiss)*1000*1000/mclk_freq;
950 us_video = vpm_us + vus_m; /* Video has separate read return path */
952 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
954 us_video /* Wait for video */
955 +cpm_us /* CRT Page miss */
956 +us_m + us_n +us_p /* other latency */
959 clwm = us_crt * crtc_drain_rate/(1000*1000);
960 clwm++; /* fixed point <= float_point - 1. Fixes that */
962 crtc_drain_rate = pclk_freq * bpp/8; /* bpp * pclk/8 */
964 crtpagemiss = 1; /* self generating page miss */
965 crtpagemiss += 1; /* MA0 page miss */
967 crtpagemiss += 1; /* if MA0 conflict */
968 cpm_us = crtpagemiss * pagemiss *1000*1000/ mclk_freq;
969 us_crt = cpm_us + us_m + us_n + us_p ;
970 clwm = us_crt * crtc_drain_rate/(1000*1000);
971 clwm++; /* fixed point <= float_point - 1. Fixes that */
975 // Another concern, only for high pclks so don't do this
977 // What happens if the latency to fetch the cbs is so large that
978 // fifo empties. In that case we need to have an alternate clwm value
979 // based off the total burst fetch
981 us_crt = (cbs * 1000 * 1000)/ (8*width)/mclk_freq ;
982 us_crt = us_crt + us_m + us_n + us_p + (4 * 1000 * 1000)/mclk_freq;
983 clwm_mt = us_crt * crtc_drain_rate/(1000*1000);
988 /* Finally, a heuristic check when width == 64 bits */
990 nvclk_fill = nvclk_freq * 8;
991 if(crtc_drain_rate * 100 >= nvclk_fill * 102)
992 clwm = 0xfff; /*Large number to fail */
994 else if(crtc_drain_rate * 100 >= nvclk_fill * 98) {
997 us_extra = (cbs * 1000 * 1000)/ (8*width)/mclk_freq ;
1008 clwm_rnd_down = ((int)clwm/8)*8;
1009 if (clwm_rnd_down < clwm)
1012 m1 = clwm + cbs - 1024; /* Amount of overfill */
1013 m2us = us_pipe_min + us_min_mclk_extra;
1014 pclks_2_top_fifo = (1024-clwm)/(8*width);
1016 /* pclk cycles to drain */
1017 p1clk = m2us * pclk_freq/(1000*1000);
1018 p2 = p1clk * bpp / 8; /* bytes drained. */
1020 if((p2 < m1) && (m1 > 0)) {
1023 if(min_mclk_extra == 0) {
1025 found = 1; /* Can't adjust anymore! */
1027 cbs = cbs/2; /* reduce the burst size */
1033 if (clwm > 1023){ /* Have some margin */
1036 if(min_mclk_extra == 0)
1037 found = 1; /* Can't adjust anymore! */
1044 if(clwm < (1024-cbs+8)) clwm = 1024-cbs+8;
1046 /* printf("CRT LWM: %f bytes, prog: 0x%x, bs: 256\n", clwm, data ); */
1047 fifo->graphics_lwm = data; fifo->graphics_burst_size = cbs;
1049 /* printf("VID LWM: %f bytes, prog: 0x%x, bs: %d\n, ", vlwm, data, vbs ); */
1050 fifo->video_lwm = 1024; fifo->video_burst_size = 512;
1053 static void nv10UpdateArbitrationSettings
1056 unsigned pixelDepth,
1062 nv10_fifo_info fifo_data;
1063 nv10_sim_state sim_data;
1064 unsigned int M, N, P, pll, MClk, NVClk, cfg1;
1066 pll = chip->PRAMDAC0[0x00000504/4];
1067 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
1068 MClk = (N * chip->CrystalFreqKHz / M) >> P;
1069 pll = chip->PRAMDAC0[0x00000500/4];
1070 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
1071 NVClk = (N * chip->CrystalFreqKHz / M) >> P;
1072 cfg1 = chip->PFB[0x00000204/4];
1073 sim_data.pix_bpp = (char)pixelDepth;
1074 sim_data.enable_video = 0;
1075 sim_data.enable_mp = 0;
1076 sim_data.memory_type = (chip->PFB[0x00000200/4] & 0x01) ? 1 : 0;
1077 sim_data.memory_width = (chip->PEXTDEV[0x00000000/4] & 0x10) ? 128 : 64;
1078 sim_data.mem_latency = (char)cfg1 & 0x0F;
1079 sim_data.mem_aligned = 1;
1080 sim_data.mem_page_miss = (char)(((cfg1 >> 4) &0x0F) + ((cfg1 >> 31) & 0x01));
1081 sim_data.gr_during_vid = 0;
1082 sim_data.pclk_khz = VClk;
1083 sim_data.mclk_khz = MClk;
1084 sim_data.nvclk_khz = NVClk;
1085 nv10CalcArbitration(&fifo_data, &sim_data);
1086 if (fifo_data.valid)
1088 int b = fifo_data.graphics_burst_size >> 4;
1090 while (b >>= 1) (*burst)++;
1091 *lwm = fifo_data.graphics_lwm >> 3;
1095 static void nForceUpdateArbitrationSettings
1098 unsigned pixelDepth,
1104 nv10_fifo_info fifo_data;
1105 nv10_sim_state sim_data;
1106 unsigned int M, N, P, pll, MClk, NVClk;
1107 unsigned int uMClkPostDiv;
1108 struct pci_dev *dev;
1110 dev = pci_find_slot(0, 3);
1111 pci_read_config_dword(dev, 0x6C, &uMClkPostDiv);
1112 uMClkPostDiv = (uMClkPostDiv >> 8) & 0xf;
1114 if(!uMClkPostDiv) uMClkPostDiv = 4;
1115 MClk = 400000 / uMClkPostDiv;
1117 pll = chip->PRAMDAC0[0x00000500/4];
1118 M = (pll >> 0) & 0xFF; N = (pll >> 8) & 0xFF; P = (pll >> 16) & 0x0F;
1119 NVClk = (N * chip->CrystalFreqKHz / M) >> P;
1120 sim_data.pix_bpp = (char)pixelDepth;
1121 sim_data.enable_video = 0;
1122 sim_data.enable_mp = 0;
1124 dev = pci_find_slot(0, 1);
1125 pci_read_config_dword(dev, 0x7C, &sim_data.memory_type);
1126 sim_data.memory_type = (sim_data.memory_type >> 12) & 1;
1128 sim_data.memory_width = 64;
1129 sim_data.mem_latency = 3;
1130 sim_data.mem_aligned = 1;
1131 sim_data.mem_page_miss = 10;
1132 sim_data.gr_during_vid = 0;
1133 sim_data.pclk_khz = VClk;
1134 sim_data.mclk_khz = MClk;
1135 sim_data.nvclk_khz = NVClk;
1136 nv10CalcArbitration(&fifo_data, &sim_data);
1137 if (fifo_data.valid)
1139 int b = fifo_data.graphics_burst_size >> 4;
1141 while (b >>= 1) (*burst)++;
1142 *lwm = fifo_data.graphics_lwm >> 3;
1146 /****************************************************************************\
1148 * RIVA Mode State Routines *
1150 \****************************************************************************/
1153 * Calculate the Video Clock parameters for the PLL.
1155 static int CalcVClock
1165 unsigned lowM, highM, highP;
1166 unsigned DeltaNew, DeltaOld;
1167 unsigned VClk, Freq;
1170 DeltaOld = 0xFFFFFFFF;
1172 VClk = (unsigned)clockIn;
1174 if (chip->CrystalFreqKHz == 13500)
1177 highM = 13 - (chip->Architecture == NV_ARCH_03);
1182 highM = 14 - (chip->Architecture == NV_ARCH_03);
1185 highP = 4 - (chip->Architecture == NV_ARCH_03);
1186 for (P = 0; P <= highP; P ++)
1189 if ((Freq >= 128000) && (Freq <= chip->MaxVClockFreqKHz))
1191 for (M = lowM; M <= highM; M++)
1193 N = (VClk << P) * M / chip->CrystalFreqKHz;
1195 Freq = (chip->CrystalFreqKHz * N / M) >> P;
1197 DeltaNew = Freq - VClk;
1199 DeltaNew = VClk - Freq;
1200 if (DeltaNew < DeltaOld)
1206 DeltaOld = DeltaNew;
1212 return (DeltaOld != 0xFFFFFFFF);
1215 * Calculate extended mode parameters (SVGA) and save in a
1216 * mode state structure.
1218 static void CalcStateExt
1221 RIVA_HW_STATE *state,
1229 int pixelDepth, VClk, m, n, p;
1231 * Save mode parameters.
1233 state->bpp = bpp; /* this is not bitsPerPixel, it's 8,15,16,32 */
1234 state->width = width;
1235 state->height = height;
1237 * Extended RIVA registers.
1239 pixelDepth = (bpp + 1)/8;
1240 CalcVClock(dotClock, &VClk, &m, &n, &p, chip);
1242 switch (chip->Architecture)
1245 nv3UpdateArbitrationSettings(VClk,
1247 &(state->arbitration0),
1248 &(state->arbitration1),
1250 state->cursor0 = 0x00;
1251 state->cursor1 = 0x78;
1252 state->cursor2 = 0x00000000;
1253 state->pllsel = 0x10010100;
1254 state->config = ((width + 31)/32)
1255 | (((pixelDepth > 2) ? 3 : pixelDepth) << 8)
1257 state->general = 0x00100100;
1258 state->repaint1 = hDisplaySize < 1280 ? 0x06 : 0x02;
1261 nv4UpdateArbitrationSettings(VClk,
1263 &(state->arbitration0),
1264 &(state->arbitration1),
1266 state->cursor0 = 0x00;
1267 state->cursor1 = 0xFC;
1268 state->cursor2 = 0x00000000;
1269 state->pllsel = 0x10000700;
1270 state->config = 0x00001114;
1271 state->general = bpp == 16 ? 0x00101100 : 0x00100100;
1272 state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1276 if((chip->Chipset == NV_CHIP_IGEFORCE2) ||
1277 (chip->Chipset == NV_CHIP_0x01F0))
1279 nForceUpdateArbitrationSettings(VClk,
1281 &(state->arbitration0),
1282 &(state->arbitration1),
1285 nv10UpdateArbitrationSettings(VClk,
1287 &(state->arbitration0),
1288 &(state->arbitration1),
1291 state->cursor0 = 0x80 | (chip->CursorStart >> 17);
1292 state->cursor1 = (chip->CursorStart >> 11) << 2;
1293 state->cursor2 = chip->CursorStart >> 24;
1294 state->pllsel = 0x10000700;
1295 state->config = chip->PFB[0x00000200/4];
1296 state->general = bpp == 16 ? 0x00101100 : 0x00100100;
1297 state->repaint1 = hDisplaySize < 1280 ? 0x04 : 0x00;
1301 /* Paul Richards: below if block borks things in kernel for some reason */
1302 /* if((bpp != 8) && (chip->Architecture != NV_ARCH_03))
1303 state->general |= 0x00000030; */
1305 state->vpll = (p << 16) | (n << 8) | m;
1306 state->repaint0 = (((width/8)*pixelDepth) & 0x700) >> 3;
1307 state->pixel = pixelDepth > 2 ? 3 : pixelDepth;
1315 state->pitch3 = pixelDepth * width;
1318 * Load fixed function state and pre-calculated/stored state.
1320 #define LOAD_FIXED_STATE(tbl,dev) \
1321 for (i = 0; i < sizeof(tbl##Table##dev)/8; i++) \
1322 chip->dev[tbl##Table##dev[i][0]] = tbl##Table##dev[i][1]
1323 #define LOAD_FIXED_STATE_8BPP(tbl,dev) \
1324 for (i = 0; i < sizeof(tbl##Table##dev##_8BPP)/8; i++) \
1325 chip->dev[tbl##Table##dev##_8BPP[i][0]] = tbl##Table##dev##_8BPP[i][1]
1326 #define LOAD_FIXED_STATE_15BPP(tbl,dev) \
1327 for (i = 0; i < sizeof(tbl##Table##dev##_15BPP)/8; i++) \
1328 chip->dev[tbl##Table##dev##_15BPP[i][0]] = tbl##Table##dev##_15BPP[i][1]
1329 #define LOAD_FIXED_STATE_16BPP(tbl,dev) \
1330 for (i = 0; i < sizeof(tbl##Table##dev##_16BPP)/8; i++) \
1331 chip->dev[tbl##Table##dev##_16BPP[i][0]] = tbl##Table##dev##_16BPP[i][1]
1332 #define LOAD_FIXED_STATE_32BPP(tbl,dev) \
1333 for (i = 0; i < sizeof(tbl##Table##dev##_32BPP)/8; i++) \
1334 chip->dev[tbl##Table##dev##_32BPP[i][0]] = tbl##Table##dev##_32BPP[i][1]
1335 static void UpdateFifoState
1342 switch (chip->Architecture)
1345 LOAD_FIXED_STATE(nv4,FIFO);
1347 chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
1352 * Initialize state for the RivaTriangle3D05 routines.
1354 LOAD_FIXED_STATE(nv10tri05,PGRAPH);
1355 LOAD_FIXED_STATE(nv10,FIFO);
1357 chip->Tri05 = (RivaTexturedTriangle05 *)&(chip->FIFO[0x0000E000/4]);
1361 static void LoadStateExt
1364 RIVA_HW_STATE *state
1370 * Load HW fixed function state.
1372 LOAD_FIXED_STATE(Riva,PMC);
1373 LOAD_FIXED_STATE(Riva,PTIMER);
1374 switch (chip->Architecture)
1378 * Make sure frame buffer config gets set before loading PRAMIN.
1380 chip->PFB[0x00000200/4] = state->config;
1381 LOAD_FIXED_STATE(nv3,PFIFO);
1382 LOAD_FIXED_STATE(nv3,PRAMIN);
1383 LOAD_FIXED_STATE(nv3,PGRAPH);
1388 LOAD_FIXED_STATE_15BPP(nv3,PRAMIN);
1389 LOAD_FIXED_STATE_15BPP(nv3,PGRAPH);
1390 chip->Tri03 = (RivaTexturedTriangle03 *)&(chip->FIFO[0x0000E000/4]);
1394 LOAD_FIXED_STATE_32BPP(nv3,PRAMIN);
1395 LOAD_FIXED_STATE_32BPP(nv3,PGRAPH);
1400 LOAD_FIXED_STATE_8BPP(nv3,PRAMIN);
1401 LOAD_FIXED_STATE_8BPP(nv3,PGRAPH);
1405 for (i = 0x00000; i < 0x00800; i++)
1406 chip->PRAMIN[0x00000502 + i] = (i << 12) | 0x03;
1407 chip->PGRAPH[0x00000630/4] = state->offset0;
1408 chip->PGRAPH[0x00000634/4] = state->offset1;
1409 chip->PGRAPH[0x00000638/4] = state->offset2;
1410 chip->PGRAPH[0x0000063C/4] = state->offset3;
1411 chip->PGRAPH[0x00000650/4] = state->pitch0;
1412 chip->PGRAPH[0x00000654/4] = state->pitch1;
1413 chip->PGRAPH[0x00000658/4] = state->pitch2;
1414 chip->PGRAPH[0x0000065C/4] = state->pitch3;
1418 * Make sure frame buffer config gets set before loading PRAMIN.
1420 chip->PFB[0x00000200/4] = state->config;
1421 LOAD_FIXED_STATE(nv4,PFIFO);
1422 LOAD_FIXED_STATE(nv4,PRAMIN);
1423 LOAD_FIXED_STATE(nv4,PGRAPH);
1427 LOAD_FIXED_STATE_15BPP(nv4,PRAMIN);
1428 LOAD_FIXED_STATE_15BPP(nv4,PGRAPH);
1429 chip->Tri03 = (RivaTexturedTriangle03 *)&(chip->FIFO[0x0000E000/4]);
1432 LOAD_FIXED_STATE_16BPP(nv4,PRAMIN);
1433 LOAD_FIXED_STATE_16BPP(nv4,PGRAPH);
1434 chip->Tri03 = (RivaTexturedTriangle03 *)&(chip->FIFO[0x0000E000/4]);
1438 LOAD_FIXED_STATE_32BPP(nv4,PRAMIN);
1439 LOAD_FIXED_STATE_32BPP(nv4,PGRAPH);
1444 LOAD_FIXED_STATE_8BPP(nv4,PRAMIN);
1445 LOAD_FIXED_STATE_8BPP(nv4,PGRAPH);
1449 chip->PGRAPH[0x00000640/4] = state->offset0;
1450 chip->PGRAPH[0x00000644/4] = state->offset1;
1451 chip->PGRAPH[0x00000648/4] = state->offset2;
1452 chip->PGRAPH[0x0000064C/4] = state->offset3;
1453 chip->PGRAPH[0x00000670/4] = state->pitch0;
1454 chip->PGRAPH[0x00000674/4] = state->pitch1;
1455 chip->PGRAPH[0x00000678/4] = state->pitch2;
1456 chip->PGRAPH[0x0000067C/4] = state->pitch3;
1460 if(chip->twoHeads) {
1461 VGA_WR08(chip->PCIO, 0x03D4, 0x44);
1462 VGA_WR08(chip->PCIO, 0x03D5, state->crtcOwner);
1463 chip->LockUnlock(chip, 0);
1466 LOAD_FIXED_STATE(nv10,PFIFO);
1467 LOAD_FIXED_STATE(nv10,PRAMIN);
1468 LOAD_FIXED_STATE(nv10,PGRAPH);
1472 LOAD_FIXED_STATE_15BPP(nv10,PRAMIN);
1473 LOAD_FIXED_STATE_15BPP(nv10,PGRAPH);
1474 chip->Tri03 = (RivaTexturedTriangle03 *)&(chip->FIFO[0x0000E000/4]);
1477 LOAD_FIXED_STATE_16BPP(nv10,PRAMIN);
1478 LOAD_FIXED_STATE_16BPP(nv10,PGRAPH);
1479 chip->Tri03 = (RivaTexturedTriangle03 *)&(chip->FIFO[0x0000E000/4]);
1483 LOAD_FIXED_STATE_32BPP(nv10,PRAMIN);
1484 LOAD_FIXED_STATE_32BPP(nv10,PGRAPH);
1489 LOAD_FIXED_STATE_8BPP(nv10,PRAMIN);
1490 LOAD_FIXED_STATE_8BPP(nv10,PGRAPH);
1495 if(chip->Architecture == NV_ARCH_10) {
1496 chip->PGRAPH[0x00000640/4] = state->offset0;
1497 chip->PGRAPH[0x00000644/4] = state->offset1;
1498 chip->PGRAPH[0x00000648/4] = state->offset2;
1499 chip->PGRAPH[0x0000064C/4] = state->offset3;
1500 chip->PGRAPH[0x00000670/4] = state->pitch0;
1501 chip->PGRAPH[0x00000674/4] = state->pitch1;
1502 chip->PGRAPH[0x00000678/4] = state->pitch2;
1503 chip->PGRAPH[0x0000067C/4] = state->pitch3;
1504 chip->PGRAPH[0x00000680/4] = state->pitch3;
1506 chip->PGRAPH[0x00000820/4] = state->offset0;
1507 chip->PGRAPH[0x00000824/4] = state->offset1;
1508 chip->PGRAPH[0x00000828/4] = state->offset2;
1509 chip->PGRAPH[0x0000082C/4] = state->offset3;
1510 chip->PGRAPH[0x00000850/4] = state->pitch0;
1511 chip->PGRAPH[0x00000854/4] = state->pitch1;
1512 chip->PGRAPH[0x00000858/4] = state->pitch2;
1513 chip->PGRAPH[0x0000085C/4] = state->pitch3;
1514 chip->PGRAPH[0x00000860/4] = state->pitch3;
1515 chip->PGRAPH[0x00000864/4] = state->pitch3;
1516 chip->PGRAPH[0x000009A4/4] = chip->PFB[0x00000200/4];
1517 chip->PGRAPH[0x000009A8/4] = chip->PFB[0x00000204/4];
1519 if(chip->twoHeads) {
1520 chip->PCRTC0[0x00000860/4] = state->head;
1521 chip->PCRTC0[0x00002860/4] = state->head2;
1523 chip->PRAMDAC[0x00000404/4] |= (1 << 25);
1525 chip->PMC[0x00008704/4] = 1;
1526 chip->PMC[0x00008140/4] = 0;
1527 chip->PMC[0x00008920/4] = 0;
1528 chip->PMC[0x00008924/4] = 0;
1529 chip->PMC[0x00008908/4] = 0x01ffffff;
1530 chip->PMC[0x0000890C/4] = 0x01ffffff;
1531 chip->PMC[0x00001588/4] = 0;
1533 chip->PFB[0x00000240/4] = 0;
1534 chip->PFB[0x00000244/4] = 0;
1535 chip->PFB[0x00000248/4] = 0;
1536 chip->PFB[0x0000024C/4] = 0;
1537 chip->PFB[0x00000250/4] = 0;
1538 chip->PFB[0x00000254/4] = 0;
1539 chip->PFB[0x00000258/4] = 0;
1540 chip->PFB[0x0000025C/4] = 0;
1542 chip->PGRAPH[0x00000B00/4] = chip->PFB[0x00000240/4];
1543 chip->PGRAPH[0x00000B04/4] = chip->PFB[0x00000244/4];
1544 chip->PGRAPH[0x00000B08/4] = chip->PFB[0x00000248/4];
1545 chip->PGRAPH[0x00000B0C/4] = chip->PFB[0x0000024C/4];
1546 chip->PGRAPH[0x00000B10/4] = chip->PFB[0x00000250/4];
1547 chip->PGRAPH[0x00000B14/4] = chip->PFB[0x00000254/4];
1548 chip->PGRAPH[0x00000B18/4] = chip->PFB[0x00000258/4];
1549 chip->PGRAPH[0x00000B1C/4] = chip->PFB[0x0000025C/4];
1550 chip->PGRAPH[0x00000B20/4] = chip->PFB[0x00000260/4];
1551 chip->PGRAPH[0x00000B24/4] = chip->PFB[0x00000264/4];
1552 chip->PGRAPH[0x00000B28/4] = chip->PFB[0x00000268/4];
1553 chip->PGRAPH[0x00000B2C/4] = chip->PFB[0x0000026C/4];
1554 chip->PGRAPH[0x00000B30/4] = chip->PFB[0x00000270/4];
1555 chip->PGRAPH[0x00000B34/4] = chip->PFB[0x00000274/4];
1556 chip->PGRAPH[0x00000B38/4] = chip->PFB[0x00000278/4];
1557 chip->PGRAPH[0x00000B3C/4] = chip->PFB[0x0000027C/4];
1558 chip->PGRAPH[0x00000B40/4] = chip->PFB[0x00000280/4];
1559 chip->PGRAPH[0x00000B44/4] = chip->PFB[0x00000284/4];
1560 chip->PGRAPH[0x00000B48/4] = chip->PFB[0x00000288/4];
1561 chip->PGRAPH[0x00000B4C/4] = chip->PFB[0x0000028C/4];
1562 chip->PGRAPH[0x00000B50/4] = chip->PFB[0x00000290/4];
1563 chip->PGRAPH[0x00000B54/4] = chip->PFB[0x00000294/4];
1564 chip->PGRAPH[0x00000B58/4] = chip->PFB[0x00000298/4];
1565 chip->PGRAPH[0x00000B5C/4] = chip->PFB[0x0000029C/4];
1566 chip->PGRAPH[0x00000B60/4] = chip->PFB[0x000002A0/4];
1567 chip->PGRAPH[0x00000B64/4] = chip->PFB[0x000002A4/4];
1568 chip->PGRAPH[0x00000B68/4] = chip->PFB[0x000002A8/4];
1569 chip->PGRAPH[0x00000B6C/4] = chip->PFB[0x000002AC/4];
1570 chip->PGRAPH[0x00000B70/4] = chip->PFB[0x000002B0/4];
1571 chip->PGRAPH[0x00000B74/4] = chip->PFB[0x000002B4/4];
1572 chip->PGRAPH[0x00000B78/4] = chip->PFB[0x000002B8/4];
1573 chip->PGRAPH[0x00000B7C/4] = chip->PFB[0x000002BC/4];
1574 chip->PGRAPH[0x00000F40/4] = 0x10000000;
1575 chip->PGRAPH[0x00000F44/4] = 0x00000000;
1576 chip->PGRAPH[0x00000F50/4] = 0x00000040;
1577 chip->PGRAPH[0x00000F54/4] = 0x00000008;
1578 chip->PGRAPH[0x00000F50/4] = 0x00000200;
1579 for (i = 0; i < (3*16); i++)
1580 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1581 chip->PGRAPH[0x00000F50/4] = 0x00000040;
1582 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1583 chip->PGRAPH[0x00000F50/4] = 0x00000800;
1584 for (i = 0; i < (16*16); i++)
1585 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1586 chip->PGRAPH[0x00000F40/4] = 0x30000000;
1587 chip->PGRAPH[0x00000F44/4] = 0x00000004;
1588 chip->PGRAPH[0x00000F50/4] = 0x00006400;
1589 for (i = 0; i < (59*4); i++)
1590 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1591 chip->PGRAPH[0x00000F50/4] = 0x00006800;
1592 for (i = 0; i < (47*4); i++)
1593 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1594 chip->PGRAPH[0x00000F50/4] = 0x00006C00;
1595 for (i = 0; i < (3*4); i++)
1596 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1597 chip->PGRAPH[0x00000F50/4] = 0x00007000;
1598 for (i = 0; i < (19*4); i++)
1599 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1600 chip->PGRAPH[0x00000F50/4] = 0x00007400;
1601 for (i = 0; i < (12*4); i++)
1602 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1603 chip->PGRAPH[0x00000F50/4] = 0x00007800;
1604 for (i = 0; i < (12*4); i++)
1605 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1606 chip->PGRAPH[0x00000F50/4] = 0x00004400;
1607 for (i = 0; i < (8*4); i++)
1608 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1609 chip->PGRAPH[0x00000F50/4] = 0x00000000;
1610 for (i = 0; i < 16; i++)
1611 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1612 chip->PGRAPH[0x00000F50/4] = 0x00000040;
1613 for (i = 0; i < 4; i++)
1614 chip->PGRAPH[0x00000F54/4] = 0x00000000;
1616 chip->PCRTC[0x00000810/4] = state->cursorConfig;
1618 if(chip->flatPanel) {
1619 if((chip->Chipset & 0x0ff0) == 0x0110) {
1620 chip->PRAMDAC[0x0528/4] = state->dither;
1622 if((chip->Chipset & 0x0ff0) >= 0x0170) {
1623 chip->PRAMDAC[0x083C/4] = state->dither;
1626 VGA_WR08(chip->PCIO, 0x03D4, 0x53);
1627 VGA_WR08(chip->PCIO, 0x03D5, 0);
1628 VGA_WR08(chip->PCIO, 0x03D4, 0x54);
1629 VGA_WR08(chip->PCIO, 0x03D5, 0);
1630 VGA_WR08(chip->PCIO, 0x03D4, 0x21);
1631 VGA_WR08(chip->PCIO, 0x03D5, 0xfa);
1634 VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1635 VGA_WR08(chip->PCIO, 0x03D5, state->extra);
1637 LOAD_FIXED_STATE(Riva,FIFO);
1638 UpdateFifoState(chip);
1640 * Load HW mode state.
1642 VGA_WR08(chip->PCIO, 0x03D4, 0x19);
1643 VGA_WR08(chip->PCIO, 0x03D5, state->repaint0);
1644 VGA_WR08(chip->PCIO, 0x03D4, 0x1A);
1645 VGA_WR08(chip->PCIO, 0x03D5, state->repaint1);
1646 VGA_WR08(chip->PCIO, 0x03D4, 0x25);
1647 VGA_WR08(chip->PCIO, 0x03D5, state->screen);
1648 VGA_WR08(chip->PCIO, 0x03D4, 0x28);
1649 VGA_WR08(chip->PCIO, 0x03D5, state->pixel);
1650 VGA_WR08(chip->PCIO, 0x03D4, 0x2D);
1651 VGA_WR08(chip->PCIO, 0x03D5, state->horiz);
1652 VGA_WR08(chip->PCIO, 0x03D4, 0x1B);
1653 VGA_WR08(chip->PCIO, 0x03D5, state->arbitration0);
1654 VGA_WR08(chip->PCIO, 0x03D4, 0x20);
1655 VGA_WR08(chip->PCIO, 0x03D5, state->arbitration1);
1656 VGA_WR08(chip->PCIO, 0x03D4, 0x30);
1657 VGA_WR08(chip->PCIO, 0x03D5, state->cursor0);
1658 VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1659 VGA_WR08(chip->PCIO, 0x03D5, state->cursor1);
1660 VGA_WR08(chip->PCIO, 0x03D4, 0x2F);
1661 VGA_WR08(chip->PCIO, 0x03D5, state->cursor2);
1662 VGA_WR08(chip->PCIO, 0x03D4, 0x39);
1663 VGA_WR08(chip->PCIO, 0x03D5, state->interlace);
1665 if(!chip->flatPanel) {
1666 chip->PRAMDAC0[0x00000508/4] = state->vpll;
1667 chip->PRAMDAC0[0x0000050C/4] = state->pllsel;
1669 chip->PRAMDAC0[0x00000520/4] = state->vpll2;
1671 chip->PRAMDAC[0x00000848/4] = state->scale;
1673 chip->PRAMDAC[0x00000600/4] = state->general;
1676 * Turn off VBlank enable and reset.
1678 chip->PCRTC[0x00000140/4] = 0;
1679 chip->PCRTC[0x00000100/4] = chip->VBlankBit;
1681 * Set interrupt enable.
1683 chip->PMC[0x00000140/4] = chip->EnableIRQ & 0x01;
1685 * Set current state pointer.
1687 chip->CurrentState = state;
1689 * Reset FIFO free and empty counts.
1691 chip->FifoFreeCount = 0;
1692 /* Free count from first subchannel */
1693 chip->FifoEmptyCount = chip->Rop->FifoFree;
1695 static void UnloadStateExt
1698 RIVA_HW_STATE *state
1702 * Save current HW state.
1704 VGA_WR08(chip->PCIO, 0x03D4, 0x19);
1705 state->repaint0 = VGA_RD08(chip->PCIO, 0x03D5);
1706 VGA_WR08(chip->PCIO, 0x03D4, 0x1A);
1707 state->repaint1 = VGA_RD08(chip->PCIO, 0x03D5);
1708 VGA_WR08(chip->PCIO, 0x03D4, 0x25);
1709 state->screen = VGA_RD08(chip->PCIO, 0x03D5);
1710 VGA_WR08(chip->PCIO, 0x03D4, 0x28);
1711 state->pixel = VGA_RD08(chip->PCIO, 0x03D5);
1712 VGA_WR08(chip->PCIO, 0x03D4, 0x2D);
1713 state->horiz = VGA_RD08(chip->PCIO, 0x03D5);
1714 VGA_WR08(chip->PCIO, 0x03D4, 0x1B);
1715 state->arbitration0 = VGA_RD08(chip->PCIO, 0x03D5);
1716 VGA_WR08(chip->PCIO, 0x03D4, 0x20);
1717 state->arbitration1 = VGA_RD08(chip->PCIO, 0x03D5);
1718 VGA_WR08(chip->PCIO, 0x03D4, 0x30);
1719 state->cursor0 = VGA_RD08(chip->PCIO, 0x03D5);
1720 VGA_WR08(chip->PCIO, 0x03D4, 0x31);
1721 state->cursor1 = VGA_RD08(chip->PCIO, 0x03D5);
1722 VGA_WR08(chip->PCIO, 0x03D4, 0x2F);
1723 state->cursor2 = VGA_RD08(chip->PCIO, 0x03D5);
1724 VGA_WR08(chip->PCIO, 0x03D4, 0x39);
1725 state->interlace = VGA_RD08(chip->PCIO, 0x03D5);
1726 state->vpll = chip->PRAMDAC0[0x00000508/4];
1727 state->vpll2 = chip->PRAMDAC0[0x00000520/4];
1728 state->pllsel = chip->PRAMDAC0[0x0000050C/4];
1729 state->general = chip->PRAMDAC[0x00000600/4];
1730 state->scale = chip->PRAMDAC[0x00000848/4];
1731 state->config = chip->PFB[0x00000200/4];
1732 switch (chip->Architecture)
1735 state->offset0 = chip->PGRAPH[0x00000630/4];
1736 state->offset1 = chip->PGRAPH[0x00000634/4];
1737 state->offset2 = chip->PGRAPH[0x00000638/4];
1738 state->offset3 = chip->PGRAPH[0x0000063C/4];
1739 state->pitch0 = chip->PGRAPH[0x00000650/4];
1740 state->pitch1 = chip->PGRAPH[0x00000654/4];
1741 state->pitch2 = chip->PGRAPH[0x00000658/4];
1742 state->pitch3 = chip->PGRAPH[0x0000065C/4];
1745 state->offset0 = chip->PGRAPH[0x00000640/4];
1746 state->offset1 = chip->PGRAPH[0x00000644/4];
1747 state->offset2 = chip->PGRAPH[0x00000648/4];
1748 state->offset3 = chip->PGRAPH[0x0000064C/4];
1749 state->pitch0 = chip->PGRAPH[0x00000670/4];
1750 state->pitch1 = chip->PGRAPH[0x00000674/4];
1751 state->pitch2 = chip->PGRAPH[0x00000678/4];
1752 state->pitch3 = chip->PGRAPH[0x0000067C/4];
1756 state->offset0 = chip->PGRAPH[0x00000640/4];
1757 state->offset1 = chip->PGRAPH[0x00000644/4];
1758 state->offset2 = chip->PGRAPH[0x00000648/4];
1759 state->offset3 = chip->PGRAPH[0x0000064C/4];
1760 state->pitch0 = chip->PGRAPH[0x00000670/4];
1761 state->pitch1 = chip->PGRAPH[0x00000674/4];
1762 state->pitch2 = chip->PGRAPH[0x00000678/4];
1763 state->pitch3 = chip->PGRAPH[0x0000067C/4];
1764 if(chip->twoHeads) {
1765 state->head = chip->PCRTC0[0x00000860/4];
1766 state->head2 = chip->PCRTC0[0x00002860/4];
1767 VGA_WR08(chip->PCIO, 0x03D4, 0x44);
1768 state->crtcOwner = VGA_RD08(chip->PCIO, 0x03D5);
1770 VGA_WR08(chip->PCIO, 0x03D4, 0x41);
1771 state->extra = VGA_RD08(chip->PCIO, 0x03D5);
1772 state->cursorConfig = chip->PCRTC[0x00000810/4];
1774 if((chip->Chipset & 0x0ff0) == 0x0110) {
1775 state->dither = chip->PRAMDAC[0x0528/4];
1777 if((chip->Chipset & 0x0ff0) >= 0x0170) {
1778 state->dither = chip->PRAMDAC[0x083C/4];
1783 static void SetStartAddress
1789 chip->PCRTC[0x800/4] = start;
1792 static void SetStartAddress3
1798 int offset = start >> 2;
1799 int pan = (start & 3) << 1;
1803 * Unlock extended registers.
1805 chip->LockUnlock(chip, 0);
1807 * Set start address.
1809 VGA_WR08(chip->PCIO, 0x3D4, 0x0D); VGA_WR08(chip->PCIO, 0x3D5, offset);
1811 VGA_WR08(chip->PCIO, 0x3D4, 0x0C); VGA_WR08(chip->PCIO, 0x3D5, offset);
1813 VGA_WR08(chip->PCIO, 0x3D4, 0x19); tmp = VGA_RD08(chip->PCIO, 0x3D5);
1814 VGA_WR08(chip->PCIO, 0x3D5, (offset & 0x01F) | (tmp & ~0x1F));
1815 VGA_WR08(chip->PCIO, 0x3D4, 0x2D); tmp = VGA_RD08(chip->PCIO, 0x3D5);
1816 VGA_WR08(chip->PCIO, 0x3D5, (offset & 0x60) | (tmp & ~0x60));
1818 * 4 pixel pan register.
1820 offset = VGA_RD08(chip->PCIO, chip->IO + 0x0A);
1821 VGA_WR08(chip->PCIO, 0x3C0, 0x13);
1822 VGA_WR08(chip->PCIO, 0x3C0, pan);
1824 static void nv3SetSurfaces2D
1831 RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1833 RIVA_FIFO_FREE(*chip,Tri03,5);
1834 chip->FIFO[0x00003800] = 0x80000003;
1835 Surface->Offset = surf0;
1836 chip->FIFO[0x00003800] = 0x80000004;
1837 Surface->Offset = surf1;
1838 chip->FIFO[0x00003800] = 0x80000013;
1840 static void nv4SetSurfaces2D
1847 RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1849 chip->FIFO[0x00003800] = 0x80000003;
1850 Surface->Offset = surf0;
1851 chip->FIFO[0x00003800] = 0x80000004;
1852 Surface->Offset = surf1;
1853 chip->FIFO[0x00003800] = 0x80000014;
1855 static void nv10SetSurfaces2D
1862 RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1864 chip->FIFO[0x00003800] = 0x80000003;
1865 Surface->Offset = surf0;
1866 chip->FIFO[0x00003800] = 0x80000004;
1867 Surface->Offset = surf1;
1868 chip->FIFO[0x00003800] = 0x80000014;
1870 static void nv3SetSurfaces3D
1877 RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1879 RIVA_FIFO_FREE(*chip,Tri03,5);
1880 chip->FIFO[0x00003800] = 0x80000005;
1881 Surface->Offset = surf0;
1882 chip->FIFO[0x00003800] = 0x80000006;
1883 Surface->Offset = surf1;
1884 chip->FIFO[0x00003800] = 0x80000013;
1886 static void nv4SetSurfaces3D
1893 RivaSurface *Surface = (RivaSurface *)&(chip->FIFO[0x0000E000/4]);
1895 chip->FIFO[0x00003800] = 0x80000005;
1896 Surface->Offset = surf0;
1897 chip->FIFO[0x00003800] = 0x80000006;
1898 Surface->Offset = surf1;
1899 chip->FIFO[0x00003800] = 0x80000014;
1901 static void nv10SetSurfaces3D
1908 RivaSurface3D *Surfaces3D = (RivaSurface3D *)&(chip->FIFO[0x0000E000/4]);
1910 RIVA_FIFO_FREE(*chip,Tri03,4);
1911 chip->FIFO[0x00003800] = 0x80000007;
1912 Surfaces3D->RenderBufferOffset = surf0;
1913 Surfaces3D->ZBufferOffset = surf1;
1914 chip->FIFO[0x00003800] = 0x80000014;
1917 /****************************************************************************\
1919 * Probe RIVA Chip Configuration *
1921 \****************************************************************************/
1923 static void nv3GetConfig
1929 * Fill in chip configuration.
1931 if (chip->PFB[0x00000000/4] & 0x00000020)
1933 if (((chip->PMC[0x00000000/4] & 0xF0) == 0x20)
1934 && ((chip->PMC[0x00000000/4] & 0x0F) >= 0x02))
1939 chip->RamBandwidthKBytesPerSec = 800000;
1940 switch (chip->PFB[0x00000000/4] & 0x03)
1943 chip->RamAmountKBytes = 1024 * 4;
1946 chip->RamAmountKBytes = 1024 * 2;
1949 chip->RamAmountKBytes = 1024 * 8;
1955 chip->RamBandwidthKBytesPerSec = 1000000;
1956 chip->RamAmountKBytes = 1024 * 8;
1964 chip->RamBandwidthKBytesPerSec = 1000000;
1965 switch (chip->PFB[0x00000000/4] & 0x00000003)
1968 chip->RamAmountKBytes = 1024 * 8;
1971 chip->RamAmountKBytes = 1024 * 4;
1974 chip->RamAmountKBytes = 1024 * 2;
1978 chip->CrystalFreqKHz = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
1979 chip->CURSOR = &(chip->PRAMIN[0x00008000/4 - 0x0800/4]);
1980 chip->VBlankBit = 0x00000100;
1981 chip->MaxVClockFreqKHz = 256000;
1983 * Set chip functions.
1985 chip->Busy = nv3Busy;
1986 chip->ShowHideCursor = ShowHideCursor;
1987 chip->CalcStateExt = CalcStateExt;
1988 chip->LoadStateExt = LoadStateExt;
1989 chip->UnloadStateExt = UnloadStateExt;
1990 chip->SetStartAddress = SetStartAddress3;
1991 chip->SetSurfaces2D = nv3SetSurfaces2D;
1992 chip->SetSurfaces3D = nv3SetSurfaces3D;
1993 chip->LockUnlock = nv3LockUnlock;
1995 static void nv4GetConfig
2001 * Fill in chip configuration.
2003 if (chip->PFB[0x00000000/4] & 0x00000100)
2005 chip->RamAmountKBytes = ((chip->PFB[0x00000000/4] >> 12) & 0x0F) * 1024 * 2
2010 switch (chip->PFB[0x00000000/4] & 0x00000003)
2013 chip->RamAmountKBytes = 1024 * 32;
2016 chip->RamAmountKBytes = 1024 * 4;
2019 chip->RamAmountKBytes = 1024 * 8;
2023 chip->RamAmountKBytes = 1024 * 16;
2027 switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
2030 chip->RamBandwidthKBytesPerSec = 800000;
2033 chip->RamBandwidthKBytesPerSec = 1000000;
2036 chip->CrystalFreqKHz = (chip->PEXTDEV[0x00000000/4] & 0x00000040) ? 14318 : 13500;
2037 chip->CURSOR = &(chip->PRAMIN[0x00010000/4 - 0x0800/4]);
2038 chip->VBlankBit = 0x00000001;
2039 chip->MaxVClockFreqKHz = 350000;
2041 * Set chip functions.
2043 chip->Busy = nv4Busy;
2044 chip->ShowHideCursor = ShowHideCursor;
2045 chip->CalcStateExt = CalcStateExt;
2046 chip->LoadStateExt = LoadStateExt;
2047 chip->UnloadStateExt = UnloadStateExt;
2048 chip->SetStartAddress = SetStartAddress;
2049 chip->SetSurfaces2D = nv4SetSurfaces2D;
2050 chip->SetSurfaces3D = nv4SetSurfaces3D;
2051 chip->LockUnlock = nv4LockUnlock;
2053 static void nv10GetConfig
2056 unsigned int chipset
2059 struct pci_dev* dev;
2063 /* turn on big endian register access */
2064 chip->PMC[0x00000004/4] = 0x01000001;
2068 * Fill in chip configuration.
2070 if(chipset == NV_CHIP_IGEFORCE2) {
2071 dev = pci_find_slot(0, 1);
2072 pci_read_config_dword(dev, 0x7C, &amt);
2073 chip->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024;
2074 } else if(chipset == NV_CHIP_0x01F0) {
2075 dev = pci_find_slot(0, 1);
2076 pci_read_config_dword(dev, 0x84, &amt);
2077 chip->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024;
2079 switch ((chip->PFB[0x0000020C/4] >> 20) & 0x000000FF)
2082 chip->RamAmountKBytes = 1024 * 2;
2085 chip->RamAmountKBytes = 1024 * 4;
2088 chip->RamAmountKBytes = 1024 * 8;
2091 chip->RamAmountKBytes = 1024 * 16;
2094 chip->RamAmountKBytes = 1024 * 32;
2097 chip->RamAmountKBytes = 1024 * 64;
2100 chip->RamAmountKBytes = 1024 * 128;
2103 chip->RamAmountKBytes = 1024 * 16;
2107 switch ((chip->PFB[0x00000000/4] >> 3) & 0x00000003)
2110 chip->RamBandwidthKBytesPerSec = 800000;
2113 chip->RamBandwidthKBytesPerSec = 1000000;
2116 chip->CrystalFreqKHz = (chip->PEXTDEV[0x0000/4] & (1 << 6)) ? 14318 :
2119 switch (chipset & 0x0ff0) {
2125 if(chip->PEXTDEV[0x0000/4] & (1 << 22))
2126 chip->CrystalFreqKHz = 27000;
2132 chip->CursorStart = (chip->RamAmountKBytes - 128) * 1024;
2133 chip->CURSOR = NULL; /* can't set this here */
2134 chip->VBlankBit = 0x00000001;
2135 chip->MaxVClockFreqKHz = 350000;
2137 * Set chip functions.
2139 chip->Busy = nv10Busy;
2140 chip->ShowHideCursor = ShowHideCursor;
2141 chip->CalcStateExt = CalcStateExt;
2142 chip->LoadStateExt = LoadStateExt;
2143 chip->UnloadStateExt = UnloadStateExt;
2144 chip->SetStartAddress = SetStartAddress;
2145 chip->SetSurfaces2D = nv10SetSurfaces2D;
2146 chip->SetSurfaces3D = nv10SetSurfaces3D;
2147 chip->LockUnlock = nv4LockUnlock;
2149 switch(chipset & 0x0ff0) {
2156 chip->twoHeads = TRUE;
2159 chip->twoHeads = FALSE;
2166 unsigned int chipset
2170 * Save this so future SW know whats it's dealing with.
2172 chip->Version = RIVA_SW_VERSION;
2174 * Chip specific configuration.
2176 switch (chip->Architecture)
2186 nv10GetConfig(chip, chipset);
2191 chip->Chipset = chipset;
2193 * Fill in FIFO pointers.
2195 chip->Rop = (RivaRop *)&(chip->FIFO[0x00000000/4]);
2196 chip->Clip = (RivaClip *)&(chip->FIFO[0x00002000/4]);
2197 chip->Patt = (RivaPattern *)&(chip->FIFO[0x00004000/4]);
2198 chip->Pixmap = (RivaPixmap *)&(chip->FIFO[0x00006000/4]);
2199 chip->Blt = (RivaScreenBlt *)&(chip->FIFO[0x00008000/4]);
2200 chip->Bitmap = (RivaBitmap *)&(chip->FIFO[0x0000A000/4]);
2201 chip->Line = (RivaLine *)&(chip->FIFO[0x0000C000/4]);
2202 chip->Tri03 = (RivaTexturedTriangle03 *)&(chip->FIFO[0x0000E000/4]);