~ubuntu-branches/ubuntu/trusty/xserver-xorg-video-nouveau/trusty

« back to all changes in this revision

Viewing changes to src/nv_driver.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2009-03-27 20:41:22 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090327204122-wk0ufg9p0l245gmf
Tags: 1:0.0.10~git+20090327+f1907dc-0ubuntu1
* New upstream snapshot.  Standing FFe is (LP: #346621).
  - New snapshot fixes crash in NoAccel code path (LP: #345530)
  - New snapshot fixes incorrect resolution after exit from some
    fullscreen applications, such as Battle for Westnoth (LP: #323619)
  - f1907dc... nv50: add default modes to mode pool for LVDS panel
  - 7da6fdb... kms: fix bug which prevented getting edid from the kernel
  - f431e20... randr: fix crash when rotation requested
  - 36dedd0... kms: check for mm_enabled as an additional test for kms
    presence
  - a923bc1... nv50/xv: correct rendering to partically obscured windows
  - 01cee29... nv50: call NVSync() in CloseScreen() before restoring
    video mode
  - aa7c037... kms: implement AdjustFrame, should fix crash in fdo#24236
  - 61879b8... kms: drm_mode_modeinfo struct changed names at some point
  - 79306fc... dri: fail harder
  - da1ba93... device close doesn't belong in DRI close, can have DRM
    without DRI
  - 56b11c7... Fix mouse cursor disappearing when near top/left edge of
    screen.
  - 4067ab4... another ppc fix
  - 862dba8... more ppc..
  - 3063486... fix ppc build
  - d80fe78... Fix nouveau_hw_decode_pll on NV30/35.
  - 62aa81d... Some laptop mode finding fixes resulting from rh#487456
  - aa6edfa... randr12: name VGA CRTC fields
  - 7b7c44c... randr12: rename reg state members to follow reg names
  - 4ae6c22... randr12: name some FP flags, move some unrelated stuff
    out from nvreg.h
  - b50b49f... pre-nv50: use nvidia's names for PRAMDAC regs where known
  - a9df304... pre-nv50: use nvidia's names for PCRTC regs where known
  - 2c0710d... Separate maximum limits for encoder devices and i2c
    records, DCB_ prefixes
  - 0db27a6... Add DCB 1.5 entry from a GeForce2 Go reported by Martin
    Ketzer on the ML
  - 3e7fa97... dri: pass object handle instead of offset if using real mm
  - 88efe40... dri2: initial implementation, only with driver pixmaps
  - 675126e... kms: support framebuffer resize if driver pixmaps enabled
  - 8b354b9... kms: copy old fb to new fb on modeset
  - 6658403... Call NVEnterVT from NVScreenInit rather than duplicating it.
  - f59fef1... exa: fix multiple prepare/finish_access on a pixmap
  - 75a1c41... Wrap bios endian casting
  - 3666d73... Switch to using pll_vals struct for passing pll stuff around
  - a3dbc06... randr12: cull old unused pll code
  - 71c821b... Don't pointlessly overallocate cursor storage
  - 7284c07... randr12: nv10 hw cursor fixes/changes
  - bcc3a14... randr12: use nv0x cursor colour expansion funcs on later
    cards, unify argb paths
  - b21c807... randr12: store nv0x hw cursor image in VRAM
  - 3ea4b19... Kill pre-randr12 hwcursor code, and tidy randr12 hwcursor code
  - b988160... Remove calls to load ddc and i2c modules -- they're
    built-in since server 1.3
  - d5893ec... Hack around missing display table in rdivacky's GeForce
    7050 PV/nForce 630a
  - 369e1ef... Fix xserver shutdown for randr12 off
  - 8343d6b... Remove bios lvds parsing pxclk test; ddc_permitted is a
    sufficient condition
  - 8b56c69... Name some regs/values and reduce crtc reg struct size
  - 79d23d8... improve drm/dri initialisation code
  - bd14482... kms: cleanup set_property
  - 7a45592... kms: get current values for output properties on startup
  - 7095e89... kms: work around some xserver stupidity with DPMS
  - 8f9a580... Another DCB 1.5 entry (seen in rh#455194)
  - 9a71990... randr12: add output properties for digital vibrance and
    image sharpening
  - 678ddc2... randr12: functionate output properties creation
  - ed9bd88... kms: remove early-exit from gamma_set, the kernel side
    works now
  - 98c9e4e... kms: work around some bong hits with dpms
  - 88ae2c9... kms: implement dpms
  - 5269cc8... randr12: make props code slightly less awful to behold
  - 0b87c49... More robust PLL upclocking for old cards
  - cb237a3... bios/randr12: mode validation fixes (includes fix for #20298)
  - 9cfccd7... Handle failure to calculate pll values better
  - 1e99440... xv: return BadAlloc if destination pixmap is not put into
    EXA offscreen (#15792)
  - 77347da... Remove duplicated DCB parsing
  - 1b6cabe... Remove VBIOS access in parse_dcb_entry
  - 72fd0ae... randr12: no need to re-detect edid for lvds, it's not
    going away
  - ae981a8... nv50: some minor modesetting changes
  - 42f99e6... nv30/xv: restore original viewport/clipping after putimage
  - 56bb8f8... Allow parse_fp_mode_table for x86 cards that find
    themselves on ppc
  - 1c2f33e... Don't rely on the bios mobile feature bit for BMP biosen
    (#19986)
  - e436c7e... randr12: make treatment of CR4B more closely resemble
    blob's behaviour
  - c61102b... Parse bios fp mode during modesetting, removing extra alloc
  - 631e15a... Get dual_link and dithering bios info through lvds table
    parsing function
  - 2d43771... Call parse_lvds_manufacturer_table during modesetting
    only (#19986 partial fix)
  - ce8f5d7... Variety of LVDS script changes
  - 071d537... Read embedded bios edid only on demand
  - f04689c... move memset of fb after NVSave(), hopefully fix lost VGA fonts
  - 6961efb... kms: fix check for xf86drmMode.h
  - 76fa656... Detypedef bios_t, rename bios io functions, group various
    helper functions
  - 39c9d02... Move parsed DCB to bios structs, split into public and
    private parts
  - 275daaf... Split bios struct into struct for nv_bios.c, and exported
    public info struct
  - 8b3e966... Remove never updated bios opcodes 0x31, 0x5A and 0x73
  - ce9eb05... Trivial bios convenience variable changes
  - cfeef11... exa: forgot to check if EXA_SUPPORTS_PREPARE_AUX was defined
  - 37a85dc... exa: we support PREPARE_AUX
  - 1249fd2... Revert exa: support major version 3
  - 1c4a284... Rework PLL decoding in terms of pll_vals, save/restore
    pll_vals on vt switch
  - 81b4732... New common struct for pll values
  - adf2e35... Check whether NV_RAMDAC_580 has changed when setting PLLs
  - b7f99ae... exa: support major version 3
  - d91fc78... kms: fix resize func
  - 535498b... clear the scanout buffer on statup to avoid seeing
    garbage on-screen
  - 0227673... nv50/exa: properly align offset for mem_tile ioctl
  - e09f50e... bios/randr12: fix dual link TMDS (#20006)
  - b968db7... Return of bios: fix create_i2c_device for g80
  - 0a439ba... Parse DCB before running init
  - 870b6f0... Split parsing and init into separate functions
  - 0280a0c... Attempt to remove pNv and bios_t use in parsing the DCB
  - 9179c66... Variety of DCB enhancements
  - 317ca47... Revert bios: fix create_i2c_device for g80
  - 7b25a30... nv04: unbreak copy
  - 60c8bb1... default to autodetecting whether to enable the driver's
    kms paths
  - a31b1d0... exa: reimplement driver-controlled pixmaps
  - d97e993... exa: preparation for reintroducing driver-controlled pixmaps
  - 1e00c7d... shadowfb: clip copied regions to frontbuffer size.
  - efe2796... nv50: correct a poorly written comment
  - 2573c06... exa: remove exaWaitSync() call in nouveau_exa_pixmap_map()
  - 5000535... exa: don't need exaMarkSync on DFS, the operation will be
    done already
  - a7e7c55... xv: remove notifier usage
  - 8ecb8d5... exa: remove notifier waits in UTS/DFS
  - cfb884b... bios: add some more valid regs
  - ca72ca2... bios: fix create_i2c_device for g80
  - bbd7041... bios: implement opcode 0x76 (INIT_IO_CONDITION).
  - 5dd2cbe... exa: add nouveau_exa_pixmap_is_tiled
  - 15ccf72... randr12: anti-crash measures for #19854
  - 17e9d4b... randr12: use bios PLL setting routines for modesetting
  - e444e0e... Readability improvements for nv_hw.c and nvreg.h
  - f5ea66c... Pull in extras from CRTC PLL code to bios routines
  - 4166365... Pull out ramdac580 setting and powerctrl_1 shift code to
    separate functions
  - 8b70418... Miscellaneous fixes to bios PLL code
  - 01bb4c1... Make PROM score badly, out of available bios images, if
    checksum bad
  - 30848dd... randr12: bodge-in continuous timings when the scaler is
    in use (#19203)
  - 0387ac3... Allow reading of PROM and PCI rom on PPC (for people
    using x86 cards)
  - 6ad66c0... bios/randr12: be strict about when to use modes from bios
    vs modes from ddc
  - b5391eb... Simplify FP strapping semantics and trust bios parsing of
    use_straps_for_mode
  - 34c2b15... bios/randr12: misc (mainly lvds related) clarifications
    and cleanups
  - 98b8cad... Always allocate 2 hw cursors.
  - f109981... Fix a few warnings.
  - 691589d... Fix some cursor fallout, mostly in legacy code.
  - 945f0cb... kms: update drmmode_display
  - ba1f897... keep resources around after leavevt, far too problematic
  currently
* debian/rules
  + Remove stampdir/ on clean; fixes build-twice-in-a-row.
* debian/patches/01_include_snapshot_date
  + Generate snapshot-date in get-orig-source, and use it rather than
    git log to define NV_DRIVER_DATE
* debian/control
  + Remove reference to drm-modules-source package from long description.
    Ubuntu ships a DKMS-ified nouveau-kernel-source package, which makes
    this unnecessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include "nv_include.h"
26
26
 
 
27
#include "xorg-server.h"
27
28
#include "xf86int10.h"
28
 
 
29
29
#include "xf86drm.h"
30
30
 
31
31
/*
44
44
static void    NVLeaveVT(int scrnIndex, int flags);
45
45
static Bool    NVCloseScreen(int scrnIndex, ScreenPtr pScreen);
46
46
static Bool    NVSaveScreen(ScreenPtr pScreen, int mode);
 
47
static void    NVCloseDRM(ScrnInfoPtr);
47
48
 
48
49
/* Optional functions */
49
50
static Bool    NVSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
163
164
    NULL
164
165
};
165
166
 
166
 
static const char *ramdacSymbols[] = {
167
 
    "xf86CreateCursorInfoRec",
168
 
    "xf86DestroyCursorInfoRec",
169
 
    "xf86InitCursor",
170
 
    NULL
171
 
};
172
 
 
173
167
static const char *ddcSymbols[] = {
174
168
    "xf86PrintEDID",
175
169
    "xf86DoEDID_DDC2",
286
280
                 * might refer to.
287
281
                 */
288
282
                LoaderRefSymLists(vgahwSymbols, exaSymbols, fbSymbols,
289
 
                                ramdacSymbols, shadowSymbols, drmSymbols, 
 
283
                                shadowSymbols, drmSymbols,
290
284
                                i2cSymbols, ddcSymbols, vbeSymbols,
291
285
                                int10Symbols, NULL);
292
286
 
602
596
        ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
603
597
        NVPtr pNv = NVPTR(pScrn);
604
598
 
 
599
        if (pNv->kms_enable) {
 
600
                drmmode_adjust_frame(pScrn, x, y, flags);
 
601
        } else
605
602
        if (pNv->randr12_enable) {
606
603
                xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
607
604
                xf86CrtcPtr crtc = config->output[config->compat_output]->crtc;
665
662
 
666
663
        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVEnterVT is called.\n");
667
664
 
668
 
        NVMapMem(pScrn);
669
 
        if (pNv->Architecture >= NV_ARCH_50 && pNv->EXADriverPtr) {
670
 
                nouveau_bo_tile(pNv->FB, NOUVEAU_BO_VRAM | NOUVEAU_BO_TILED,
671
 
                                pNv->EXADriverPtr->offScreenBase,
672
 
                                pNv->EXADriverPtr->memorySize -
673
 
                                pNv->EXADriverPtr->offScreenBase);
 
665
        if (!pNv->NoAccel)
 
666
                NVAccelCommonInit(pScrn);
 
667
 
 
668
        if (!pNv->kms_enable) {
 
669
                /* Save current state, VGA fonts etc */
 
670
                NVSave(pScrn);
 
671
 
 
672
                /* Clear the framebuffer, we don't want to see garbage
 
673
                 * on-screen up until X decides to draw something
 
674
                 */
 
675
                nouveau_bo_map(pNv->FB, NOUVEAU_BO_WR);
 
676
                memset(pNv->FB->map, 0, NOUVEAU_ALIGN(pScrn->virtualX, 64) *
 
677
                       pScrn->virtualY * (pScrn->bitsPerPixel >> 3));
 
678
                nouveau_bo_unmap(pNv->FB);
 
679
 
 
680
                if (pNv->Architecture == NV_ARCH_50) {
 
681
                        if (!NV50AcquireDisplay(pScrn))
 
682
                                return FALSE;
 
683
                }
674
684
        }
675
685
 
676
 
        if (!pNv->kms_enable && pNv->randr12_enable)
677
 
                NVSave(pScrn);
678
 
 
679
686
        if (!pNv->randr12_enable) {
680
687
                if (!NVModeInit(pScrn, pScrn->currentMode))
681
688
                        return FALSE;
682
689
                NVAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
683
690
        } else {
684
 
                pScrn->vtSema = TRUE;
685
 
 
686
 
                if (!pNv->kms_enable && pNv->Architecture == NV_ARCH_50)
687
 
                        if (!NV50AcquireDisplay(pScrn))
688
 
                                return FALSE;
689
 
 
 
691
                pNv->allow_dpms = FALSE;
690
692
                if (!xf86SetDesiredModes(pScrn))
691
693
                        return FALSE;
692
 
        }
693
 
 
694
 
        if (!pNv->NoAccel) {
695
 
                NVInitDma(pScrn);
696
 
                NVAccelCommonInit(pScrn);
 
694
                pNv->allow_dpms = TRUE;
697
695
        }
698
696
 
699
697
        if (pNv->overlayAdaptor && pNv->Architecture != NV_ARCH_04)
716
714
        ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
717
715
        NVPtr pNv = NVPTR(pScrn);
718
716
 
719
 
        if (pNv->randr12_enable)
720
 
                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVLeaveVT is called.\n");
 
717
        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVLeaveVT is called.\n");
721
718
 
722
719
        NVSync(pScrn);
723
 
        NVAccelFree(pScrn);
724
 
        NVTakedownVideo(pScrn);
725
 
        NVTakedownDma(pScrn);
726
 
        NVUnmapMem(pScrn);
727
 
 
728
 
        if (pNv->kms_enable)
729
 
                return;
730
 
 
731
 
        if (pNv->Architecture == NV_ARCH_50) {
732
 
                NV50ReleaseDisplay(pScrn);
733
 
                return;
 
720
 
 
721
        if (!pNv->kms_enable) {
 
722
                if (pNv->Architecture < NV_ARCH_50)
 
723
                        NVRestore(pScrn);
 
724
                else
 
725
                        NV50ReleaseDisplay(pScrn);
734
726
        }
735
 
 
736
 
        NVRestore(pScrn);
737
727
}
738
728
 
739
729
static void 
775
765
        NVPtr pNv = NVPTR(pScrn);
776
766
 
777
767
        if (pScrn->vtSema) {
778
 
#ifdef XF86DRM_MODE
779
 
                if (pNv->kms_enable) {
780
 
                        NVSync(pScrn);
781
 
                } else
782
 
#endif
783
 
                if (pNv->Architecture == NV_ARCH_50) {
784
 
                        NV50ReleaseDisplay(pScrn);
785
 
                } else {
786
 
                        if (pNv->randr12_enable)
787
 
                                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVCloseScreen is called.\n");
788
 
                        NVSync(pScrn);
789
 
                        NVRestore(pScrn);
790
 
                }
 
768
                NVLeaveVT(scrnIndex, 0);
 
769
                pScrn->vtSema = FALSE;
791
770
        }
792
771
 
793
772
        NVAccelFree(pScrn);
796
775
        NVUnmapMem(pScrn);
797
776
 
798
777
        vgaHWUnmapMem(pScrn);
799
 
        NVDRICloseScreen(pScrn);
800
 
        xf86_cursors_fini(pScreen);
801
 
        if (pNv->CursorInfoRec)
802
 
                xf86DestroyCursorInfoRec(pNv->CursorInfoRec);
 
778
 
 
779
        if (!pNv->exa_driver_pixmaps)
 
780
                NVDRICloseScreen(pScrn);
 
781
#ifdef DRI2
 
782
        else
 
783
                nouveau_dri2_fini(pScreen);
 
784
#endif
 
785
 
 
786
        NVCloseDRM(pScrn);
 
787
 
 
788
        if (pNv->randr12_enable)
 
789
                xf86_cursors_fini(pScreen);
803
790
        if (pNv->ShadowPtr) {
804
791
                xfree(pNv->ShadowPtr);
805
792
                pNv->ShadowPtr = NULL;
884
871
 
885
872
Bool NVI2CInit(ScrnInfoPtr pScrn)
886
873
{
887
 
        NVPtr pNv = NVPTR(pScrn);
888
 
 
889
 
        if (xf86LoadSubModule(pScrn, "i2c") && xf86LoadSubModule(pScrn, "ddc")) {
890
 
                xf86LoaderReqSymLists(i2cSymbols,NULL);
891
 
                xf86LoaderReqSymLists(ddcSymbols, NULL);
892
 
 
893
 
                /* randr-1.2 clients have their DDCs initialized elsewhere */
894
 
                if (!pNv->randr12_enable)
895
 
                        return NVDACi2cInit(pScrn);
896
 
                return true;
897
 
        } else
898
 
                xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
899
 
                "Couldn't load i2c and ddc modules.  DDC probing can't be done\n");
900
 
        return false;
901
 
}
902
 
 
903
 
#ifdef XF86DRM_MODE
904
 
static bool nouveau_kernel_modesetting_enabled(ScrnInfoPtr pScrn)
905
 
{
906
 
#if XSERVER_LIBPCIACCESS
907
 
        struct pci_device *PciInfo;
908
 
#else
909
 
        pciVideoPtr PciInfo;
910
 
#endif
911
 
        EntityInfoPtr pEnt;
912
 
        char *busIdString;
913
 
        int ret;
914
 
 
915
 
        pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
916
 
        PciInfo = xf86GetPciInfoForEntity(pEnt->index);
917
 
 
918
 
        busIdString = DRICreatePCIBusID(PciInfo);
919
 
 
920
 
        ret = drmCheckModesettingSupported(busIdString);
921
 
        xfree(busIdString);
922
 
        if (ret)
923
 
                return FALSE;
924
 
 
925
 
        return TRUE;
926
 
}
927
 
#else
928
 
#define nouveau_kernel_modesetting_enabled(x) FALSE
929
 
#endif
930
 
 
931
 
static Bool NVPreInitDRI(ScrnInfoPtr pScrn)
932
 
{
933
 
        NVPtr pNv = NVPTR(pScrn);
934
 
 
935
 
        if (!NVDRIGetVersion(pScrn))
936
 
                return FALSE;
937
 
 
938
 
        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
939
 
                "[dri] Found DRI library version %d.%d.%d and kernel"
940
 
                " module version %d.%d.%d\n",
941
 
                pNv->pLibDRMVersion->version_major,
942
 
                pNv->pLibDRMVersion->version_minor,
943
 
                pNv->pLibDRMVersion->version_patchlevel,
944
 
                pNv->pKernelDRMVersion->version_major,
945
 
                pNv->pKernelDRMVersion->version_minor,
946
 
                pNv->pKernelDRMVersion->version_patchlevel);
947
 
 
 
874
        xf86LoaderReqSymLists(i2cSymbols,NULL);
 
875
        xf86LoaderReqSymLists(ddcSymbols, NULL);
 
876
 
 
877
        if (!NVPTR(pScrn)->randr12_enable)
 
878
                return NVDACi2cInit(pScrn);
948
879
        return TRUE;
949
880
}
950
881
 
970
901
        return FALSE;                                                       \
971
902
} while(0)
972
903
 
 
904
static void
 
905
NVCloseDRM(ScrnInfoPtr pScrn)
 
906
{
 
907
        NVPtr pNv = NVPTR(pScrn);
 
908
 
 
909
        nouveau_device_close(&pNv->dev);
 
910
}
 
911
 
 
912
static Bool
 
913
NVPreInitDRM(ScrnInfoPtr pScrn)
 
914
{
 
915
        NVPtr pNv = NVPTR(pScrn);
 
916
        drmVersion *version;
 
917
        char *bus_id;
 
918
        int ret;
 
919
 
 
920
        /* Load the kernel module, and open the DRM */
 
921
        bus_id = DRICreatePCIBusID(pNv->PciInfo);
 
922
        ret = DRIOpenDRMMaster(pScrn, SAREA_MAX, bus_id, "nouveau");
 
923
        if (!ret) {
 
924
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
925
                           "[drm] error opening the drm\n");
 
926
                xfree(bus_id);
 
927
                return FALSE;
 
928
        }
 
929
 
 
930
        /* Check the version reported by the kernel module.  In theory we
 
931
         * shouldn't have to do this, as libdrm_nouveau will do its own checks.
 
932
         * But, we're currently using the kernel patchlevel to also version
 
933
         * the DRI interface.
 
934
         */
 
935
        version = drmGetVersion(DRIMasterFD(pScrn));
 
936
        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 
937
                   "[drm] nouveau interface version: %d.%d.%d\n",
 
938
                   version->version_major, version->version_minor,
 
939
                   version->version_patchlevel);
 
940
 
 
941
        ret = !(version->version_patchlevel == NOUVEAU_DRM_HEADER_PATCHLEVEL);
 
942
        drmFree(version);
 
943
        if (ret) {
 
944
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
945
                           "[drm] wrong version, expecting 0.0.%d\n",
 
946
                           NOUVEAU_DRM_HEADER_PATCHLEVEL);
 
947
                xfree(bus_id);
 
948
                return FALSE;
 
949
        }
 
950
 
 
951
        /* Initialise libdrm_nouveau */
 
952
        ret = nouveau_device_open_existing(&pNv->dev, 1, DRIMasterFD(pScrn), 0);
 
953
        if (ret) {
 
954
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
955
                           "[drm] error creating device, setting NoAccel\n");
 
956
                xfree(bus_id);
 
957
                return FALSE;
 
958
        }
 
959
 
 
960
        /* Check if KMS is enabled before we do anything, we don't want to
 
961
         * go stomping on registers behind its back
 
962
         */
 
963
#ifdef XF86DRM_MODE
 
964
        pNv->kms_enable = !drmCheckModesettingSupported(bus_id);
 
965
 
 
966
        /* Additional sanity check */
 
967
        if (!nouveau_device(pNv->dev)->mm_enabled)
 
968
                pNv->kms_enable = false;
 
969
#endif
 
970
        xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
 
971
                   "[drm] kernel modesetting %s\n", pNv->kms_enable ?
 
972
                   "in use" : "not available");
 
973
 
 
974
        xfree(bus_id);
 
975
        return TRUE;
 
976
}
 
977
 
973
978
/* Mandatory */
974
979
Bool
975
980
NVPreInit(ScrnInfoPtr pScrn, int flags)
976
981
{
977
982
        NVPtr pNv;
978
983
        MessageType from;
979
 
        int i, max_width, max_height;
980
984
        ClockRangePtr clockRanges;
 
985
        int max_width, max_height;
981
986
        int config_mon_rates = FALSE;
 
987
        int ret, i;
982
988
 
983
989
        if (flags & PROBE_DETECT) {
984
990
                EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
1104
1110
#endif
1105
1111
        }
1106
1112
 
 
1113
        /* Attempt to initialise the kernel module, if we fail this we'll
 
1114
         * fallback to limited functionality.
 
1115
         */
 
1116
        if (!NVPreInitDRM(pScrn)) {
 
1117
                xf86DrvMsg(pScrn->scrnIndex, X_NOTICE,
 
1118
                           "Failing back to NoAccel mode\n");
 
1119
                pNv->NoAccel = TRUE;
 
1120
                pNv->ShadowFB = TRUE;
 
1121
        }
 
1122
 
1107
1123
        /* Save current console video mode */
1108
1124
        if (pNv->Architecture >= NV_ARCH_50 && pNv->pInt10 && !pNv->kms_enable) {
1109
1125
                const xf86Int10InfoPtr pInt10 = pNv->pInt10;
1193
1209
 
1194
1210
        from = X_DEFAULT;
1195
1211
 
1196
 
        pNv->kms_enable = false;
1197
 
#ifdef XF86DRM_MODE
1198
 
        if (pNv->Architecture == NV_ARCH_50)
1199
 
                pNv->kms_enable = nouveau_kernel_modesetting_enabled(pScrn);
1200
 
#endif /* XF86DRM_MODE */
1201
 
 
1202
 
        if (pNv->kms_enable)
1203
 
                xf86DrvMsg(pScrn->scrnIndex, from, "NV50 Kernel modesetting enabled\n");
1204
 
 
1205
1212
        pNv->randr12_enable = true;
1206
 
        if (pNv->Architecture != NV_ARCH_50 && !xf86ReturnOptValBool(pNv->Options, OPTION_RANDR12, TRUE))
 
1213
        if (pNv->Architecture != NV_ARCH_50 && !pNv->kms_enable &&
 
1214
            !xf86ReturnOptValBool(pNv->Options, OPTION_RANDR12, TRUE))
1207
1215
                pNv->randr12_enable = false;
1208
 
        xf86DrvMsg(pScrn->scrnIndex, from, "Randr1.2 support %sabled\n", pNv->randr12_enable ? "en" : "dis");
 
1216
        xf86DrvMsg(pScrn->scrnIndex, from, "Randr1.2 support %sabled\n",
 
1217
                   pNv->randr12_enable ? "en" : "dis");
1209
1218
 
1210
1219
        pNv->HWCursor = TRUE;
1211
1220
        /*
1220
1229
                from = X_CONFIG;
1221
1230
                pNv->HWCursor = FALSE;
1222
1231
        }
 
1232
        if (!pNv->randr12_enable)
 
1233
                pNv->HWCursor = FALSE;
1223
1234
        xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
1224
1235
                pNv->HWCursor ? "HW" : "SW");
1225
1236
 
1229
1240
                xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Flat panel scaling %s\n",
1230
1241
                        pNv->FpScale ? "on" : "off");
1231
1242
        }
 
1243
 
1232
1244
        if (xf86ReturnOptValBool(pNv->Options, OPTION_NOACCEL, FALSE)) {
1233
1245
                pNv->NoAccel = TRUE;
1234
1246
                xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
1235
1247
        }
 
1248
 
1236
1249
        if (xf86ReturnOptValBool(pNv->Options, OPTION_SHADOW_FB, FALSE)) {
1237
1250
                pNv->ShadowFB = TRUE;
1238
1251
                pNv->NoAccel = TRUE;
1240
1253
                        "Using \"Shadow Framebuffer\" - acceleration disabled\n");
1241
1254
        }
1242
1255
 
 
1256
        if (xf86ReturnOptValBool(pNv->Options, OPTION_EXA_PIXMAPS, FALSE))
 
1257
                pNv->exa_driver_pixmaps = TRUE;
 
1258
 
1243
1259
        if(xf86GetOptValInteger(pNv->Options, OPTION_VIDEO_KEY, &(pNv->videoKey))) {
1244
1260
                xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n",
1245
1261
                                        pNv->videoKey);
1324
1340
 
1325
1341
#ifdef XF86DRM_MODE
1326
1342
        if (pNv->kms_enable){
1327
 
                int res = 0;
1328
 
                char *bus_id;
1329
 
                bus_id = DRICreatePCIBusID(pNv->PciInfo);
1330
 
 
1331
 
                pNv->drmmode = calloc(1, sizeof(drmmode_rec));
1332
 
                res = drmmode_pre_init(pScrn, bus_id, pNv->drmmode, pScrn->bitsPerPixel >> 3);
1333
 
                if (!res) {
1334
 
                        xfree(bus_id);
 
1343
                ret = drmmode_pre_init(pScrn, nouveau_device(pNv->dev)->fd,
 
1344
                                       pScrn->bitsPerPixel >> 3);
 
1345
                if (ret == FALSE)
1335
1346
                        NVPreInitFail("Kernel modesetting failed to initialize\n");
1336
 
                }
1337
1347
        } else
1338
1348
#endif
1339
1349
        if (pNv->randr12_enable) {
1342
1352
                xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height);
1343
1353
        }
1344
1354
 
1345
 
        if (!pNv->NoAccel && NVPreInitDRI(pScrn) == FALSE) {
1346
 
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
1347
 
                           "DRI pre-initialisation failed.  Setting NoAccel\n");
1348
 
                pNv->ShadowFB = TRUE;
1349
 
                pNv->NoAccel = TRUE;
1350
 
        }
1351
 
 
1352
1355
        if (!pNv->randr12_enable) {
1353
1356
                if ((pScrn->monitor->nHsync == 0) && 
1354
1357
                        (pScrn->monitor->nVrefresh == 0)) {
1531
1534
                xf86LoaderReqSymLists(exaSymbols, NULL);
1532
1535
        }
1533
1536
 
1534
 
        /* Load ramdac if needed */
1535
 
        if (pNv->HWCursor) {
1536
 
                if (!xf86LoadSubModule(pScrn, "ramdac")) {
1537
 
                        NVPreInitFail("\n");
1538
 
                }
1539
 
                xf86LoaderReqSymLists(ramdacSymbols, NULL);
1540
 
        }
1541
 
 
1542
1537
        /* Load shadowfb */
1543
1538
        if (!xf86LoadSubModule(pScrn, "shadowfb"))
1544
1539
                NVPreInitFail("\n");
1580
1575
#endif
1581
1576
 
1582
1577
        Cursor0Offset = VRAMReserved;
1583
 
        Cursor1Offset = Cursor0Offset + (64 * 1024);
1584
 
        CLUTOffset[0] = Cursor1Offset + (64 * 1024);
 
1578
        Cursor1Offset = Cursor0Offset + (64 * 64 * 4);
 
1579
        CLUTOffset[0] = Cursor1Offset + (64 * 64 * 4);
1585
1580
        CLUTOffset[1] = CLUTOffset[0] + (4 * 1024);
1586
1581
 
1587
1582
        ret = nouveau_bo_fake(&dev, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_PIN,
1593
1588
 
1594
1589
        ret = nouveau_bo_fake(&dev, Cursor0Offset,
1595
1590
                              NOUVEAU_BO_VRAM | NOUVEAU_BO_PIN,
1596
 
                              64*1024, pNv->VRAMMap + Cursor0Offset,
 
1591
                              64 * 64 * 4, pNv->VRAMMap + Cursor0Offset,
1597
1592
                              &pNv->Cursor);
1598
1593
        if (ret)
1599
1594
                return FALSE;
1600
1595
 
1601
1596
        ret = nouveau_bo_fake(&dev, Cursor1Offset,
1602
1597
                              NOUVEAU_BO_VRAM | NOUVEAU_BO_PIN,
1603
 
                              64*1024, pNv->VRAMMap + Cursor1Offset,
 
1598
                              64 * 64 * 4, pNv->VRAMMap + Cursor1Offset,
1604
1599
                              &pNv->Cursor2);
1605
1600
        if (ret)
1606
1601
                return FALSE;
1634
1629
NVMapMem(ScrnInfoPtr pScrn)
1635
1630
{
1636
1631
        NVPtr pNv = NVPTR(pScrn);
1637
 
        int gart_scratch_size;
1638
1632
        uint64_t res;
 
1633
        int size;
1639
1634
 
1640
 
        if (pNv->NoAccel)
 
1635
        if (!pNv->dev)
1641
1636
                return NVMapMemSW(pScrn);
1642
1637
 
1643
1638
        nouveau_device_get_param(pNv->dev, NOUVEAU_GETPARAM_FB_SIZE, &res);
1647
1642
        nouveau_device_get_param(pNv->dev, NOUVEAU_GETPARAM_AGP_SIZE, &res);
1648
1643
        pNv->AGPSize=res;
1649
1644
 
 
1645
        if (pNv->exa_driver_pixmaps) {
 
1646
                size = NOUVEAU_ALIGN(pScrn->virtualX, 64);
 
1647
                size = size * (pScrn->bitsPerPixel >> 3);
 
1648
                size = size * pScrn->virtualY;
 
1649
        } else {
 
1650
                size = pNv->VRAMPhysicalSize / 2;
 
1651
        }
 
1652
 
1650
1653
        if (nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_PIN,
1651
 
                0, pNv->VRAMPhysicalSize / 2, &pNv->FB)) {
1652
 
                        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to allocate memory for framebuffer!\n");
1653
 
                        return FALSE;
 
1654
                           0, size, &pNv->FB)) {
 
1655
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
1656
                           "Failed to allocate framebuffer memory\n");
 
1657
                return FALSE;
1654
1658
        }
1655
1659
        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
1656
 
                "Allocated %dMiB VRAM for framebuffer + offscreen pixmaps, at offset 0x%X\n",
1657
 
                (uint32_t)(pNv->FB->size >> 20), (uint32_t) pNv->FB->offset);
1658
 
#ifdef XF86DRM_MODE
1659
 
        if (pNv->kms_enable)
1660
 
                drmmode_set_fb(pScrn, pNv->drmmode, pScrn->virtualX, pScrn->virtualY, pScrn->displayWidth*(pScrn->bitsPerPixel >> 3), pNv->FB);
1661
 
#endif
 
1660
                   "Allocated %dMiB VRAM for framebuffer + offscreen pixmaps, "
 
1661
                   "at offset 0x%X\n",
 
1662
                   (uint32_t)(pNv->FB->size >> 20), (uint32_t) pNv->FB->offset);
1662
1663
 
1663
1664
        if (pNv->AGPSize) {
1664
1665
                xf86DrvMsg(pScrn->scrnIndex, X_INFO,
1665
1666
                           "AGPGART: %dMiB available\n",
1666
1667
                           (unsigned int)(pNv->AGPSize >> 20));
1667
1668
                if (pNv->AGPSize > (16*1024*1024))
1668
 
                        gart_scratch_size = 16*1024*1024;
 
1669
                        size = 16*1024*1024;
1669
1670
                else
1670
1671
                        /* always leave 512kb for other things like the fifos */
1671
 
                        gart_scratch_size = pNv->AGPSize - 512*1024;
 
1672
                        size = pNv->AGPSize - 512*1024;
1672
1673
        } else {
1673
 
                gart_scratch_size = (4 << 20) - (1 << 18) ;
 
1674
                size = (4 << 20) - (1 << 18) ;
1674
1675
                xf86DrvMsg(pScrn->scrnIndex, X_INFO,
1675
1676
                           "GART: PCI DMA - using %dKiB\n",
1676
 
                           gart_scratch_size >> 10);
 
1677
                           size >> 10);
1677
1678
        }
1678
1679
 
1679
1680
        if (nouveau_bo_new(pNv->dev, NOUVEAU_BO_GART | NOUVEAU_BO_PIN, 0,
1680
 
                           gart_scratch_size, &pNv->GART)) {
 
1681
                           size, &pNv->GART)) {
1681
1682
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
1682
1683
                           "Unable to allocate GART memory\n");
1683
1684
        }
1687
1688
                           (unsigned int)(pNv->GART->size >> 20));
1688
1689
        }
1689
1690
 
 
1691
        /* We don't need to allocate cursors / lut here if we're using
 
1692
         * kernel modesetting
 
1693
         **/
 
1694
        if (pNv->kms_enable)
 
1695
                return TRUE;
 
1696
 
1690
1697
        if (nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_PIN, 0,
1691
 
                           64 * 1024, &pNv->Cursor)) {
 
1698
                           64 * 64 * 4, &pNv->Cursor)) {
1692
1699
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
1693
1700
                           "Failed to allocate memory for hardware cursor\n");
1694
1701
                return FALSE;
1695
1702
        }
1696
1703
 
1697
 
        if (pNv->randr12_enable) {
1698
 
                if (nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_PIN, 0,
1699
 
                        64 * 1024, &pNv->Cursor2)) {
1700
 
                        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
1701
 
                                "Failed to allocate memory for hardware cursor\n");
1702
 
                        return FALSE;
1703
 
                }
 
1704
        if (nouveau_bo_new(pNv->dev, NOUVEAU_BO_VRAM | NOUVEAU_BO_PIN, 0,
 
1705
                64 * 64 * 4, &pNv->Cursor2)) {
 
1706
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
1707
                        "Failed to allocate memory for hardware cursor\n");
 
1708
                return FALSE;
1704
1709
        }
1705
1710
 
1706
1711
        /* This is not the ideal solution, but significant changes are needed
1743
1748
{
1744
1749
        NVPtr pNv = NVPTR(pScrn);
1745
1750
 
1746
 
        if (pNv->NoAccel) {
 
1751
        if (!pNv->dev) {
1747
1752
#ifdef XSERVER_LIBPCIACCESS
1748
1753
                pci_device_unmap_range(pNv->PciInfo, pNv->VRAMMap,
1749
1754
                                       pNv->PciInfo->regions[1].size);
1759
1764
        nouveau_bo_ref(NULL, &pNv->Cursor2);
1760
1765
 
1761
1766
        /* Again not the most ideal way. */
1762
 
        if (pNv->Architecture == NV_ARCH_50) {
 
1767
        if (pNv->Architecture == NV_ARCH_50 && !pNv->kms_enable) {
1763
1768
                int i;
1764
1769
 
1765
1770
                for(i = 0; i < 2; i++) {
1840
1845
                int i;
1841
1846
 
1842
1847
                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Restoring encoders\n");
1843
 
                for (i = 0; i < pNv->dcb_table.entries; i++)
 
1848
                for (i = 0; i < pNv->vbios->dcb->entries; i++)
1844
1849
                        nv_encoder_restore(pScrn, &pNv->encoders[i]);
1845
1850
 
1846
1851
                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Restoring crtcs\n");
1936
1941
       /* NV17,18,34 Apple iMac, iBook, PowerBook */
1937
1942
      CARD32 tmp_pmc, tmp_pcrt;
1938
1943
      tmp_pmc = nvReadMC(pNv, NV_PBUS_DEBUG_DUALHEAD_CTL) & 0x7FFFFFFF;
1939
 
      tmp_pcrt = NVReadCRTC(pNv, 0, NV_CRTC_GPIO_EXT) & 0xFFFFFFFC;
 
1944
      tmp_pcrt = NVReadCRTC(pNv, 0, NV_PCRTC_GPIO_EXT) & 0xFFFFFFFC;
1940
1945
      if(on) {
1941
1946
          tmp_pmc |= (1 << 31);
1942
1947
          tmp_pcrt |= 0x1;
1943
1948
      }
1944
1949
      nvWriteMC(pNv, NV_PBUS_DEBUG_DUALHEAD_CTL, tmp_pmc);
1945
 
      NVWriteCRTC(pNv, 0, NV_CRTC_GPIO_EXT, tmp_pcrt);
 
1950
      NVWriteCRTC(pNv, 0, NV_PCRTC_GPIO_EXT, tmp_pcrt);
1946
1951
    }
1947
1952
#endif
1948
1953
    
1953
1958
    } else {
1954
1959
       CARD32 fpcontrol;
1955
1960
 
1956
 
       fpcontrol = nvReadCurRAMDAC(pNv, NV_RAMDAC_FP_CONTROL) & 0xCfffffCC;
 
1961
       fpcontrol = nvReadCurRAMDAC(pNv, NV_PRAMDAC_FP_TG_CONTROL) & 0xCfffffCC;
1957
1962
 
1958
1963
       /* cut the TMDS output */
1959
1964
       if(on) fpcontrol |= pNv->fpSyncs;
1960
1965
       else fpcontrol |= 0x20000022;
1961
1966
 
1962
 
       nvWriteCurRAMDAC(pNv, NV_RAMDAC_FP_CONTROL, fpcontrol);
 
1967
       nvWriteCurRAMDAC(pNv, NV_PRAMDAC_FP_TG_CONTROL, fpcontrol);
1963
1968
    }
1964
1969
}
1965
1970
 
2040
2045
                        return FALSE;
2041
2046
        }
2042
2047
 
2043
 
        /* First init DRI/DRM */
2044
 
        if (!pNv->NoAccel && !NVDRIScreenInit(pScrn)) {
2045
 
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
2046
 
                           "DRI initialisation failed.  Setting NoAccel\n");
2047
 
                pNv->ShadowFB = TRUE;
2048
 
                pNv->NoAccel = TRUE;
2049
 
        }
2050
 
 
2051
2048
        /* Allocate and map memory areas we need */
2052
2049
        if (!NVMapMem(pScrn))
2053
2050
                return FALSE;
2054
2051
 
2055
2052
        if (!pNv->NoAccel) {
 
2053
                if (!pNv->exa_driver_pixmaps)
 
2054
                        NVDRIScreenInit(pScrn);
 
2055
#ifdef DRI2
 
2056
                else
 
2057
                        nouveau_dri2_init(pScreen);
 
2058
#endif
 
2059
 
2056
2060
                /* Init DRM - Alloc FIFO */
2057
2061
                if (!NVInitDma(pScrn))
2058
2062
                        return FALSE;
2076
2080
        if (!pNv->kms_enable)
2077
2081
                NVSave(pScrn);
2078
2082
 
2079
 
        if (!pNv->randr12_enable) {
2080
 
                if (!NVModeInit(pScrn, pScrn->currentMode))
2081
 
                        return FALSE;
2082
 
                pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
2083
 
        } else {
2084
 
                pScrn->vtSema = TRUE;
2085
 
 
2086
 
                if (!pNv->kms_enable && pNv->Architecture == NV_ARCH_50)
2087
 
                        if (!NV50AcquireDisplay(pScrn))
2088
 
                                return FALSE;
2089
 
 
2090
 
                if (!xf86SetDesiredModes(pScrn))
2091
 
                        return FALSE;
2092
 
        }
2093
 
 
2094
 
        /* Darken the screen for aesthetic reasons */
2095
 
        if (!pNv->kms_enable)
2096
 
                NVSaveScreen(pScreen, SCREEN_SAVER_ON);
2097
 
 
2098
2083
        /*
2099
2084
         * The next step is to setup the screen's visuals, and initialise the
2100
2085
         * framebuffer code.  In cases where the framebuffer's default
2173
2158
 
2174
2159
        xf86SetBlackWhitePixels(pScreen);
2175
2160
 
 
2161
        nouveau_bo_map(pNv->FB, NOUVEAU_BO_RDWR);
 
2162
        pNv->FBMap = pNv->FB->map;
 
2163
        nouveau_bo_unmap(pNv->FB);
 
2164
 
2176
2165
        if (!pNv->NoAccel) {
2177
2166
                if (!nouveau_exa_init(pScreen))
2178
2167
                        return FALSE;
2187
2176
        xf86SetSilkenMouse(pScreen);
2188
2177
 
2189
2178
        /* Finish DRI init */
2190
 
        NVDRIFinishScreenInit(pScrn);
 
2179
        if (!NVDRIFinishScreenInit(pScrn)) {
 
2180
                xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 
2181
                           "[dri] NVDRIFinishScreenInit failed, disbling DRI\n");
 
2182
                NVDRICloseScreen(pScrn);
 
2183
        }
2191
2184
 
2192
2185
        /* 
2193
2186
         * Initialize software cursor.
2200
2193
         * Must follow software cursor initialization.
2201
2194
         */
2202
2195
        if (pNv->HWCursor) { 
2203
 
                if (pNv->Architecture < NV_ARCH_50 && !pNv->randr12_enable)
2204
 
                        ret = NVCursorInit(pScreen);
2205
 
                else if (pNv->Architecture < NV_ARCH_50 && pNv->randr12_enable)
 
2196
                if (pNv->Architecture < NV_ARCH_50)
2206
2197
                        ret = NVCursorInitRandr12(pScreen);
2207
2198
                else
2208
2199
                        ret = NV50CursorInit(pScreen);
2214
2205
                }
2215
2206
        }
2216
2207
 
 
2208
        if (pNv->ShadowFB)
 
2209
                ShadowFBInit(pScreen, NVRefreshArea);
 
2210
 
 
2211
        pScrn->memPhysBase = pNv->VRAMPhysical;
 
2212
        pScrn->fbOffset = 0;
 
2213
 
 
2214
        NVInitVideo(pScreen);
 
2215
 
 
2216
        pScrn->vtSema = TRUE;
 
2217
        pScrn->pScreen = pScreen;
 
2218
        if (!NVEnterVT(pScrn->scrnIndex, 0))
 
2219
                return FALSE;
 
2220
 
2217
2221
        if (pNv->randr12_enable) {
2218
2222
                xf86DPMSInit(pScreen, xf86DPMSSet, 0);
2219
2223
 
2220
2224
                if (!xf86CrtcScreenInit(pScreen))
2221
2225
                        return FALSE;
 
2226
        } else {
 
2227
                if(pNv->FlatPanel) {
 
2228
                        xf86DPMSInit(pScreen, NVDPMSSetLCD, 0);
 
2229
                } else {
 
2230
                        xf86DPMSInit(pScreen, NVDPMSSet, 0);
 
2231
                }
2222
2232
        }
2223
2233
 
2224
2234
        /* Initialise default colourmap */
2229
2239
         * Initialize colormap layer.
2230
2240
         * Must follow initialization of the default colormap 
2231
2241
         */
2232
 
        if (!pNv->randr12_enable && !pNv->kms_enable) {
 
2242
        if (!pNv->randr12_enable) {
2233
2243
                if(!xf86HandleColormaps(pScreen, 256, 8, NVDACLoadPalette,
2234
 
                                NULL, CMAP_RELOAD_ON_MODE_SWITCH | CMAP_PALETTED_TRUECOLOR))
 
2244
                                        NULL, CMAP_RELOAD_ON_MODE_SWITCH |
 
2245
                                        CMAP_PALETTED_TRUECOLOR))
2235
2246
                        return FALSE;
2236
2247
        } else {
2237
2248
                if (!xf86HandleColormaps(pScreen, 256, 8, NVLoadPalette,
2238
 
                                NULL, CMAP_PALETTED_TRUECOLOR))
 
2249
                                         NULL, CMAP_PALETTED_TRUECOLOR))
2239
2250
                        return FALSE;
2240
2251
        }
2241
2252
 
2242
 
        if (pNv->ShadowFB)
2243
 
                ShadowFBInit(pScreen, NVRefreshArea);
2244
 
 
2245
 
        if (!pNv->randr12_enable) {
2246
 
                if(pNv->FlatPanel) {
2247
 
                        xf86DPMSInit(pScreen, NVDPMSSetLCD, 0);
2248
 
                } else {
2249
 
                        xf86DPMSInit(pScreen, NVDPMSSet, 0);
2250
 
                }
2251
 
        }
2252
 
 
2253
 
        pScrn->memPhysBase = pNv->VRAMPhysical;
2254
 
        pScrn->fbOffset = 0;
2255
 
 
2256
 
        NVInitVideo(pScreen);
2257
 
 
2258
2253
        pScreen->SaveScreen = NVSaveScreen;
2259
2254
 
2260
2255
        /* Wrap the current CloseScreen function */
2318
2313
                        xf86_config->crtc[i]->funcs->save(xf86_config->crtc[i]);
2319
2314
 
2320
2315
                xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Saving encoders\n");
2321
 
                for (i = 0; i < pNv->dcb_table.entries; i++)
 
2316
                for (i = 0; i < pNv->vbios->dcb->entries; i++)
2322
2317
                        nv_encoder_save(pScrn, &pNv->encoders[i]);
2323
2318
        } else {
2324
2319
                vgaHWPtr pVga = VGAHWPTR(pScrn);