33 #define CHIPSET_NFORCE 0x01a0
34 #define CHIPSET_NFORCE2 0x01f0
94 if (nv_device(drm->
device)->chipset == 0x11) {
105 if (nv_device(drm->
device)->chipset == 0x11) {
116 if (nv_two_heads(dev))
121 NVVgaSeqReset(dev, head,
true);
126 NVVgaSeqReset(dev, head,
false);
142 pllvals->
log2P = (pll1 >> 16) & 0x7;
143 pllvals->
N2 = pllvals->
M2 = 1;
145 if (reg1 <= 0x405c) {
146 pllvals->
NM1 = pll2 & 0xffff;
148 if (!(pll1 & 0x1100))
149 pllvals->
NM2 = pll2 >> 16;
151 pllvals->
NM1 = pll1 & 0xffff;
153 pllvals->
NM2 = pll2 & 0xffff;
154 else if (nv_device(drm->
device)->chipset == 0x30 || nv_device(drm->
device)->chipset == 0x35) {
157 pllvals->
M2 = (pll1 >> 4) & 0x7;
158 pllvals->
N2 = ((pll1 >> 21) & 0x18) |
159 ((pll1 >> 19) & 0x7);
177 if (ret || !(reg1 = pll_lim.
reg))
180 pll1 = nv_rd32(device, reg1);
182 pll2 = nv_rd32(device, reg1 + 4);
183 else if (nv_two_reg_pll(dev)) {
186 pll2 = nv_rd32(device, reg2);
201 nouveau_hw_decode_pll(dev, reg1, pll1, pll2, pllvals);
210 if (!pv->
M1 || !pv->
M2)
230 return 400000 / mpllP;
268 if (
pv.M1 >= pll_lim.vco1.min_m &&
pv.M1 <= pll_lim.vco1.max_m &&
269 pv.N1 >= pll_lim.vco1.min_n &&
pv.N1 <= pll_lim.vco1.max_n &&
270 pv.log2P <= pll_lim.max_p)
273 NV_WARN(drm,
"VPLL %d outwith limits, attempting to fix\n", head + 1);
276 pv.M1 = pll_lim.vco1.max_m;
277 pv.N1 = pll_lim.vco1.min_n;
278 pv.log2P = pll_lim.max_p_usable;
286 static void nouveau_vga_font_io(
struct drm_device *dev,
288 bool save,
unsigned plane)
294 for (i = 0; i < 16384; i++) {
314 if (nv_two_heads(dev))
317 NVSetEnablePalette(dev, 0,
true);
319 NVSetEnablePalette(dev, 0,
false);
324 NV_INFO(drm,
"%sing VGA fonts\n", save ?
"Sav" :
"Restor");
329 NV_ERROR(drm,
"Failed to map VRAM, "
330 "cannot save/restore VGA fonts.\n");
334 if (nv_two_heads(dev))
352 for (plane = 0; plane < 4; plane++)
353 nouveau_vga_font_io(dev, iovram, save, plane);
363 if (nv_two_heads(dev))
375 rd_cio_state(
struct drm_device *dev,
int head,
378 crtcstate->
CRTC[
index] = NVReadVgaCrtc(dev, head, index);
382 wr_cio_state(
struct drm_device *dev,
int head,
385 NVWriteVgaCrtc(dev, head, index, crtcstate->
CRTC[index]);
389 nv_save_state_ramdac(
struct drm_device *dev,
int head,
396 if (nv_device(drm->
device)->card_type >= NV_10)
401 if (nv_two_heads(dev))
403 if (nv_device(drm->
device)->chipset == 0x11)
408 if (nv_gf4_disp_arch(dev))
410 if (nv_device(drm->
device)->chipset >= 0x30)
422 for (i = 0; i < 7; i++) {
425 regp->
fp_horiz_regs[
i] = NVReadRAMDAC(dev, head, ramdac_reg + 0x20);
428 if (nv_gf4_disp_arch(dev)) {
430 for (i = 0; i < 3; i++) {
438 if (!nv_gf4_disp_arch(dev) && head == 0) {
449 if (nv_gf4_disp_arch(dev))
452 if (nv_device(drm->
device)->card_type == NV_40) {
457 for (i = 0; i < 38; i++)
458 regp->
ctv_regs[i] = NVReadRAMDAC(dev, head,
464 nv_load_state_ramdac(
struct drm_device *dev,
int head,
473 if (nv_device(drm->
device)->card_type >= NV_10)
478 if (nv_two_heads(dev))
480 if (nv_device(drm->
device)->chipset == 0x11)
485 if (nv_gf4_disp_arch(dev))
487 if (nv_device(drm->
device)->chipset >= 0x30)
499 for (i = 0; i < 7; i++) {
502 NVWriteRAMDAC(dev, head, ramdac_reg, regp->
fp_vert_regs[i]);
503 NVWriteRAMDAC(dev, head, ramdac_reg + 0x20, regp->
fp_horiz_regs[i]);
506 if (nv_gf4_disp_arch(dev)) {
508 for (i = 0; i < 3; i++) {
521 if (nv_gf4_disp_arch(dev))
524 if (nv_device(drm->
device)->card_type == NV_40) {
529 for (i = 0; i < 38; i++)
530 NVWriteRAMDAC(dev, head,
536 nv_save_state_vga(
struct drm_device *dev,
int head,
544 for (i = 0; i < 25; i++)
545 rd_cio_state(dev, head, regp, i);
547 NVSetEnablePalette(dev, head,
true);
548 for (i = 0; i < 21; i++)
549 regp->
Attribute[i] = NVReadVgaAttr(dev, head, i);
550 NVSetEnablePalette(dev, head,
false);
552 for (i = 0; i < 9; i++)
555 for (i = 0; i < 5; i++)
560 nv_load_state_vga(
struct drm_device *dev,
int head,
568 for (i = 0; i < 5; i++)
571 nv_lock_vga_crtc_base(dev, head,
false);
572 for (i = 0; i < 25; i++)
573 wr_cio_state(dev, head, regp, i);
574 nv_lock_vga_crtc_base(dev, head,
true);
576 for (i = 0; i < 9; i++)
579 NVSetEnablePalette(dev, head,
true);
580 for (i = 0; i < 21; i++)
581 NVWriteVgaAttr(dev, head, i, regp->
Attribute[i]);
582 NVSetEnablePalette(dev, head,
false);
586 nv_save_state_ext(
struct drm_device *dev,
int head,
605 if (nv_device(drm->
device)->card_type >= NV_20)
608 if (nv_device(drm->
device)->card_type >= NV_30)
609 rd_cio_state(dev, head, regp, 0x9f);
617 if (nv_device(drm->
device)->card_type >= NV_10) {
621 if (nv_device(drm->
device)->card_type >= NV_30)
624 if (nv_device(drm->
device)->card_type == NV_40)
627 if (nv_two_heads(dev))
636 if (nv_device(drm->
device)->card_type >= NV_10) {
643 if (nv_gf4_disp_arch(dev)) {
648 for (i = 0; i < 0x10; i++)
649 regp->
CR58[i] = NVReadVgaCrtc5758(dev, head, i);
661 nv_load_state_ext(
struct drm_device *dev,
int head,
671 if (nv_device(drm->
device)->card_type >= NV_10) {
672 if (nv_two_heads(dev))
693 if (nv_device(drm->
device)->card_type >= NV_30)
696 if (nv_device(drm->
device)->card_type == NV_40) {
719 if (nv_device(drm->
device)->card_type >= NV_20)
722 if (nv_device(drm->
device)->card_type >= NV_30)
723 wr_cio_state(dev, head, regp, 0x9f);
729 if (nv_device(drm->
device)->card_type == NV_40)
730 nv_fix_nv40_hw_cursor(dev, head);
735 if (nv_device(drm->
device)->card_type >= NV_10) {
742 if (nv_gf4_disp_arch(dev)) {
743 if (nv_device(drm->
device)->card_type == NV_10) {
754 for (i = 0; i < 0x10; i++)
755 NVWriteVgaCrtc5758(dev, head, i, regp->
CR58[i]);
767 nv_save_state_palette(
struct drm_device *dev,
int head,
777 for (i = 0; i < 768; i++) {
782 NVSetEnablePalette(dev, head,
false);
796 for (i = 0; i < 768; i++) {
801 NVSetEnablePalette(dev, head,
false);
809 if (nv_device(drm->
device)->chipset == 0x11)
811 nouveau_hw_fix_bad_vpll(dev, head);
812 nv_save_state_ramdac(dev, head, state);
813 nv_save_state_vga(dev, head, state);
814 nv_save_state_palette(dev, head, state);
815 nv_save_state_ext(dev, head, state);
821 NVVgaProtect(dev, head,
true);
822 nv_load_state_ramdac(dev, head, state);
823 nv_load_state_ext(dev, head, state);
825 nv_load_state_vga(dev, head, state);
826 NVVgaProtect(dev, head,
false);