configure.ac          |    4 
 src/atombios_crtc.c   |   11 +-
 src/radeon_accel.c    |   34 ++++++-
 src/radeon_atombios.c |   56 +-----------
 src/radeon_atombios.h |    3 
 src/radeon_bios.c     |  232 +++++++++++++++++++++++++++++++++++++++++++++-----
 src/radeon_common.h   |    2 
 src/radeon_driver.c   |   99 ++++++++++++++-------
 src/radeon_reg.h      |   23 ++++
 9 files changed, 351 insertions(+), 113 deletions(-)

New commits:
commit faea008806802ec0e045754ec1eca492ebae320e
Author: Alex Deucher <[EMAIL PROTECTED]>
Date:   Tue May 27 18:36:01 2008 -0400

    R3/4/5xx: use get_param to get the num_gb_pipes from the drm

diff --git a/src/radeon_accel.c b/src/radeon_accel.c
index 92777c6..778d43e 100644
--- a/src/radeon_accel.c
+++ b/src/radeon_accel.c
@@ -370,6 +370,27 @@ void RADEONEngineInit(ScrnInfoPtr pScrn)
                   info->CurrentLayout.pixel_code,
                   info->CurrentLayout.bitsPerPixel);
 
+#ifdef XF86DRI
+    if (IS_R300_3D | IS_R500_3D) {
+       drmRadeonGetParam np;
+       int num_pipes;
+
+       memset(&np, 0, sizeof(np));
+       np.param = RADEON_PARAM_NUM_GB_PIPES;
+       np.value = &num_pipes;
+
+       if (drmCommandWriteRead(info->drmFD, DRM_RADEON_GETPARAM, &np,
+                               sizeof(np)) < 0) {
+           xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                      "Failed to determine num pipes from DRM, falling back to 
"
+                      "manual look-up!\n");
+           info->num_gb_pipes = 0;
+       } else {
+           info->num_gb_pipes = num_pipes;
+       }
+    }
+#endif
+
     if ((info->ChipFamily == CHIP_FAMILY_RV410) ||
        (info->ChipFamily == CHIP_FAMILY_R420)  ||
        (info->ChipFamily == CHIP_FAMILY_RS600) ||
@@ -378,14 +399,13 @@ void RADEONEngineInit(ScrnInfoPtr pScrn)
        (info->ChipFamily == CHIP_FAMILY_RS400) ||
        (info->ChipFamily == CHIP_FAMILY_RS480) ||
        IS_R500_3D) {
-       uint32_t gb_pipe_sel = INREG(R400_GB_PIPE_SELECT);
        if (info->num_gb_pipes == 0) {
+           uint32_t gb_pipe_sel = INREG(R400_GB_PIPE_SELECT);
+
            info->num_gb_pipes = ((gb_pipe_sel >> 12) & 0x3) + 1;
-           xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-                      "%s: num pipes is %d\n", __FUNCTION__, 
info->num_gb_pipes);
+           if (IS_R500_3D)
+               OUTPLL(pScrn, R500_DYN_SCLK_PWMEM_PIPE, (1 | ((gb_pipe_sel >> 
8) & 0xf) << 4));
        }
-       if (IS_R500_3D)
-           OUTPLL(pScrn, R500_DYN_SCLK_PWMEM_PIPE, (1 | ((gb_pipe_sel >> 8) & 
0xf) << 4));
     } else {
        if (info->num_gb_pipes == 0) {
            if ((info->ChipFamily == CHIP_FAMILY_R300) ||
@@ -399,6 +419,10 @@ void RADEONEngineInit(ScrnInfoPtr pScrn)
        }
     }
 
+    if (IS_R300_3D | IS_R500_3D)
+       xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                  "num pipes is %d\n", info->num_gb_pipes);
+
     if (IS_R300_3D | IS_R500_3D) {
        uint32_t gb_tile_config = (R300_ENABLE_TILING | R300_TILE_SIZE_16 | 
R300_SUBPIXEL_1_16);
 
diff --git a/src/radeon_common.h b/src/radeon_common.h
index 467addf..193c1f9 100644
--- a/src/radeon_common.h
+++ b/src/radeon_common.h
@@ -422,6 +422,8 @@ typedef union {
 #define RADEON_PARAM_SCRATCH_OFFSET        11
 #define RADEON_PARAM_CARD_TYPE             12
 #define RADEON_PARAM_VBLANK_CRTC           13   /* VBLANK CRTC */
+#define RADEON_PARAM_FB_LOCATION           14   /* FB location */
+#define RADEON_PARAM_NUM_GB_PIPES          15
 
 typedef struct drm_radeon_getparam {
        int param;

commit 965a5dbcd9dc4bf1cdd7f2bbdec15e9733b2e090
Author: Alex Deucher <[EMAIL PROTECTED]>
Date:   Tue May 27 16:48:41 2008 -0400

    RADEON: improve support for secondary cards
    
    this should fix bugs 16115, 16035

diff --git a/configure.ac b/configure.ac
index ab8bd97..a63f5e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -183,6 +183,10 @@ AC_CHECK_DECL(xf86RotateFreeShadow,
                #include <windowstr.h>
               #include <xf86Crtc.h>])
 
+AC_CHECK_DECL(pci_device_enable,
+             [AC_DEFINE(HAVE_PCI_DEVICE_ENABLE, 1, [Have pci_device_enable 
prototype])],
+             [],
+             [#include <pciaccess.h>])
 
 AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
              [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
diff --git a/src/radeon_atombios.c b/src/radeon_atombios.c
index db27362..5cc21d5 100644
--- a/src/radeon_atombios.c
+++ b/src/radeon_atombios.c
@@ -492,7 +492,7 @@ rhdAtomAllocateFbScratch(atomBiosHandlePtr handle,
 }
 
 # ifdef ATOM_BIOS_PARSER
-static Bool
+Bool
 rhdAtomASICInit(atomBiosHandlePtr handle)
 {
     ASIC_INIT_PS_ALLOCATION asicInit;
diff --git a/src/radeon_atombios.h b/src/radeon_atombios.h
index b4a19aa..fe7044d 100644
--- a/src/radeon_atombios.h
+++ b/src/radeon_atombios.h
@@ -131,6 +131,9 @@ atombios_external_tmds_setup(xf86OutputPtr output, 
DisplayModePtr mode);
 extern void
 atombios_get_command_table_version(atomBiosHandlePtr atomBIOS, int index, int 
*major, int *minor);
 
+Bool
+rhdAtomASICInit(atomBiosHandlePtr handle);
+
 # include "xf86int10.h"
 # ifdef ATOM_BIOS_PARSER
 #  define INT8 INT8
diff --git a/src/radeon_bios.c b/src/radeon_bios.c
index be72339..bc041c3 100644
--- a/src/radeon_bios.c
+++ b/src/radeon_bios.c
@@ -65,9 +65,208 @@ typedef enum
     CONNECTOR_UNSUPPORTED_LEGACY
 } RADEONLegacyConnectorType;
 
+static Bool
+radeon_read_bios(ScrnInfoPtr pScrn)
+{
+    RADEONInfoPtr info     = RADEONPTR(pScrn);
+
+#ifdef XSERVER_LIBPCIACCESS
+    if (pci_device_read_rom(info->PciInfo, info->VBIOS)) {
+       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                  "Failed to read PCI ROM!\n");
+       return FALSE;
+    }
+#else
+    xf86ReadPciBIOS(0, info->PciTag, 0, info->VBIOS, RADEON_VBIOS_SIZE);
+    if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) {
+       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                  "Video BIOS not detected in PCI space!\n");
+       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                  "Attempting to read Video BIOS from "
+                  "legacy ISA space!\n");
+       info->BIOSAddr = 0x000c0000;
+       xf86ReadDomainMemory(info->PciTag, info->BIOSAddr,
+                            RADEON_VBIOS_SIZE, info->VBIOS);
+    }
+#endif
+    if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa)
+       return FALSE;
+    else
+       return TRUE;
+}
+
+static Bool
+radeon_read_unposted_bios(ScrnInfoPtr pScrn)
+{
+    RADEONInfoPtr info     = RADEONPTR(pScrn);
+    RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn);
+    unsigned char *RADEONMMIO = info->MMIO;
+    Bool ret;
+
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Attempting to read un-POSTed 
bios\n");
+
+    if (info->ChipFamily >= CHIP_FAMILY_R600) {
+       uint32_t viph_control   = INREG(RADEON_VIPH_CONTROL);
+       uint32_t bus_cntl       = INREG(RADEON_BUS_CNTL);
+       uint32_t d1vga_control  = INREG(AVIVO_D1VGA_CONTROL);
+       uint32_t d2vga_control  = INREG(AVIVO_D2VGA_CONTROL);
+       uint32_t vga_render_control  = INREG(AVIVO_VGA_RENDER_CONTROL);
+       uint32_t rom_cntl       = INREG(R600_ROM_CNTL);
+       uint32_t general_pwrmgt = INREG(R600_GENERAL_PWRMGT);
+       uint32_t low_vid_lower_gpio_cntl    = 
INREG(R600_LOW_VID_LOWER_GPIO_CNTL);
+       uint32_t medium_vid_lower_gpio_cntl = 
INREG(R600_MEDIUM_VID_LOWER_GPIO_CNTL);
+       uint32_t high_vid_lower_gpio_cntl   = 
INREG(R600_HIGH_VID_LOWER_GPIO_CNTL);
+       uint32_t ctxsw_vid_lower_gpio_cntl  = 
INREG(R600_CTXSW_VID_LOWER_GPIO_CNTL);
+       uint32_t lower_gpio_enable          = INREG(R600_LOWER_GPIO_ENABLE);
+
+       /* disable VIP */
+       OUTREG(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN));
+
+       /* enable the rom */
+       OUTREG(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM));
+
+        /* Disable VGA mode */
+       OUTREG(AVIVO_D1VGA_CONTROL, (d1vga_control & 
~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
+                                                      
AVIVO_DVGA_CONTROL_TIMING_SELECT)));
+       OUTREG(AVIVO_D2VGA_CONTROL, (d2vga_control & 
~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
+                                                      
AVIVO_DVGA_CONTROL_TIMING_SELECT)));
+       OUTREG(AVIVO_VGA_RENDER_CONTROL, (vga_render_control & 
~AVIVO_VGA_VSTATUS_CNTL_MASK));
+
+       OUTREG(R600_ROM_CNTL, ((rom_cntl & ~R600_SCK_PRESCALE_CRYSTAL_CLK_MASK) 
|
+                              (1 << R600_SCK_PRESCALE_CRYSTAL_CLK_SHIFT) |
+                              R600_SCK_OVERWRITE));
+
+       OUTREG(R600_GENERAL_PWRMGT, (general_pwrmgt & ~R600_OPEN_DRAIN_PADS));
+
+       OUTREG(R600_LOW_VID_LOWER_GPIO_CNTL, (low_vid_lower_gpio_cntl & 
~0x400));
+
+       OUTREG(R600_MEDIUM_VID_LOWER_GPIO_CNTL, (medium_vid_lower_gpio_cntl & 
~0x400));
+
+       OUTREG(R600_HIGH_VID_LOWER_GPIO_CNTL, (high_vid_lower_gpio_cntl & 
~0x400));
+
+       OUTREG(R600_CTXSW_VID_LOWER_GPIO_CNTL, (ctxsw_vid_lower_gpio_cntl & 
~0x400));
+
+       OUTREG(R600_LOWER_GPIO_ENABLE, (lower_gpio_enable | 0x400));
+
+       ret = radeon_read_bios(pScrn);
+
+       /* restore regs */
+       OUTREG(RADEON_VIPH_CONTROL, viph_control);
+       OUTREG(RADEON_BUS_CNTL, bus_cntl);
+       OUTREG(AVIVO_D1VGA_CONTROL, d1vga_control);
+       OUTREG(AVIVO_D2VGA_CONTROL, d2vga_control);
+       OUTREG(AVIVO_VGA_RENDER_CONTROL, vga_render_control);
+       OUTREG(R600_ROM_CNTL, rom_cntl);
+       OUTREG(R600_GENERAL_PWRMGT, general_pwrmgt);
+       OUTREG(R600_LOW_VID_LOWER_GPIO_CNTL, low_vid_lower_gpio_cntl);
+       OUTREG(R600_MEDIUM_VID_LOWER_GPIO_CNTL, medium_vid_lower_gpio_cntl);
+       OUTREG(R600_HIGH_VID_LOWER_GPIO_CNTL, high_vid_lower_gpio_cntl);
+       OUTREG(R600_CTXSW_VID_LOWER_GPIO_CNTL, ctxsw_vid_lower_gpio_cntl);
+       OUTREG(R600_LOWER_GPIO_ENABLE, lower_gpio_enable);
+
+    } else if (info->ChipFamily >= CHIP_FAMILY_RV515) {
+       uint32_t seprom_cntl1   = INREG(RADEON_SEPROM_CNTL1);
+       uint32_t viph_control   = INREG(RADEON_VIPH_CONTROL);
+       uint32_t bus_cntl       = INREG(RADEON_BUS_CNTL);
+       uint32_t d1vga_control  = INREG(AVIVO_D1VGA_CONTROL);
+       uint32_t d2vga_control  = INREG(AVIVO_D2VGA_CONTROL);
+       uint32_t vga_render_control  = INREG(AVIVO_VGA_RENDER_CONTROL);
+       uint32_t gpiopad_a      = INREG(RADEON_GPIOPAD_A);
+       uint32_t gpiopad_en     = INREG(RADEON_GPIOPAD_EN);
+       uint32_t gpiopad_mask   = INREG(RADEON_GPIOPAD_MASK);
+
+       OUTREG(RADEON_SEPROM_CNTL1, ((seprom_cntl1 & ~RADEON_SCK_PRESCALE_MASK) 
|
+                                    (0xc << RADEON_SCK_PRESCALE_SHIFT)));
+
+       OUTREG(RADEON_GPIOPAD_A, 0);
+       OUTREG(RADEON_GPIOPAD_EN, 0);
+       OUTREG(RADEON_GPIOPAD_MASK, 0);
+
+       /* disable VIP */
+       OUTREG(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN));
+
+       /* enable the rom */
+       OUTREG(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM));
+
+        /* Disable VGA mode */
+       OUTREG(AVIVO_D1VGA_CONTROL, (d1vga_control & 
~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
+                                                      
AVIVO_DVGA_CONTROL_TIMING_SELECT)));
+       OUTREG(AVIVO_D2VGA_CONTROL, (d2vga_control & 
~(AVIVO_DVGA_CONTROL_MODE_ENABLE |
+                                                      
AVIVO_DVGA_CONTROL_TIMING_SELECT)));
+       OUTREG(AVIVO_VGA_RENDER_CONTROL, (vga_render_control & 
~AVIVO_VGA_VSTATUS_CNTL_MASK));
+
+       ret = radeon_read_bios(pScrn);
+
+       /* restore regs */
+       OUTREG(RADEON_SEPROM_CNTL1, seprom_cntl1);
+       OUTREG(RADEON_VIPH_CONTROL, viph_control);
+       OUTREG(RADEON_BUS_CNTL, bus_cntl);
+       OUTREG(AVIVO_D1VGA_CONTROL, d1vga_control);
+       OUTREG(AVIVO_D2VGA_CONTROL, d2vga_control);
+       OUTREG(AVIVO_VGA_RENDER_CONTROL, vga_render_control);
+       OUTREG(RADEON_GPIOPAD_A, gpiopad_a);
+       OUTREG(RADEON_GPIOPAD_EN, gpiopad_en);
+       OUTREG(RADEON_GPIOPAD_MASK, gpiopad_mask);
+
+    } else {
+       uint32_t seprom_cntl1   = INREG(RADEON_SEPROM_CNTL1);
+       uint32_t viph_control   = INREG(RADEON_VIPH_CONTROL);
+       uint32_t bus_cntl       = INREG(RADEON_BUS_CNTL);
+       uint32_t crtc_gen_cntl  = INREG(RADEON_CRTC_GEN_CNTL);
+       uint32_t crtc2_gen_cntl = 0;
+       uint32_t crtc_ext_cntl  = INREG(RADEON_CRTC_EXT_CNTL);
+       uint32_t fp2_gen_cntl   = 0;
+
+       if (PCI_DEV_DEVICE_ID(info->PciInfo) == PCI_CHIP_RV100_QY)
+           fp2_gen_cntl   = INREG(RADEON_FP2_GEN_CNTL);
+
+       if (pRADEONEnt->HasCRTC2)
+           crtc2_gen_cntl = INREG(RADEON_CRTC2_GEN_CNTL);
+
+       OUTREG(RADEON_SEPROM_CNTL1, ((seprom_cntl1 & ~RADEON_SCK_PRESCALE_MASK) 
|
+                                    (0xc << RADEON_SCK_PRESCALE_SHIFT)));
+
+       /* disable VIP */
+       OUTREG(RADEON_VIPH_CONTROL, (viph_control & ~RADEON_VIPH_EN));
+
+       /* enable the rom */
+       OUTREG(RADEON_BUS_CNTL, (bus_cntl & ~RADEON_BUS_BIOS_DIS_ROM));
+
+        /* Turn off mem requests and CRTC for both controllers */
+       OUTREG(RADEON_CRTC_GEN_CNTL, ((crtc_gen_cntl & ~RADEON_CRTC_EN) |
+                                     (RADEON_CRTC_DISP_REQ_EN_B |
+                                      RADEON_CRTC_EXT_DISP_EN)));
+       if (pRADEONEnt->HasCRTC2)
+           OUTREG(RADEON_CRTC2_GEN_CNTL, ((crtc2_gen_cntl & ~RADEON_CRTC2_EN) |
+                                          RADEON_CRTC2_DISP_REQ_EN_B));
+
+        /* Turn off CRTC */
+       OUTREG(RADEON_CRTC_EXT_CNTL, ((crtc_ext_cntl & ~RADEON_CRTC_CRT_ON) |
+                                     (RADEON_CRTC_SYNC_TRISTAT |
+                                      RADEON_CRTC_DISPLAY_DIS)));
+
+       if (PCI_DEV_DEVICE_ID(info->PciInfo) == PCI_CHIP_RV100_QY)
+           OUTREG(RADEON_FP2_GEN_CNTL, (fp2_gen_cntl & ~RADEON_FP2_ON));
+
+       ret = radeon_read_bios(pScrn);
+
+       /* restore regs */
+       OUTREG(RADEON_SEPROM_CNTL1, seprom_cntl1);
+       OUTREG(RADEON_VIPH_CONTROL, viph_control);
+       OUTREG(RADEON_BUS_CNTL, bus_cntl);
+       OUTREG(RADEON_CRTC_GEN_CNTL, crtc_gen_cntl);
+       if (pRADEONEnt->HasCRTC2)
+           OUTREG(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
+       OUTREG(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl);
+       if (PCI_DEV_DEVICE_ID(info->PciInfo) == PCI_CHIP_RV100_QY)
+           OUTREG(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
+    }
+    return ret;
+}
 
 /* Read the Video BIOS block and the FP registers (if applicable). */
-Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr  pInt10)
+Bool
+RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr  pInt10)
 {
     RADEONInfoPtr info     = RADEONPTR(pScrn);
     int tmp;
@@ -88,25 +287,8 @@ Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr  
pInt10)
            info->BIOSAddr = pInt10->BIOSseg << 4;
            (void)memcpy(info->VBIOS, xf86int10Addr(pInt10, info->BIOSAddr),
                         RADEON_VBIOS_SIZE);
-       } else {
-#ifdef XSERVER_LIBPCIACCESS
-           if (pci_device_read_rom(info->PciInfo, info->VBIOS)) {
-               xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                          "Failed to read PCI ROM!\n");
-           }
-#else
-           xf86ReadPciBIOS(0, info->PciTag, 0, info->VBIOS, RADEON_VBIOS_SIZE);
-           if (info->VBIOS[0] != 0x55 || info->VBIOS[1] != 0xaa) {
-               xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                          "Video BIOS not detected in PCI space!\n");
-               xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                          "Attempting to read Video BIOS from "
-                          "legacy ISA space!\n");
-               info->BIOSAddr = 0x000c0000;
-               xf86ReadDomainMemory(info->PciTag, info->BIOSAddr,
-                                    RADEON_VBIOS_SIZE, info->VBIOS);
-           }
-#endif
+       } else if (!radeon_read_bios(pScrn)) {
+           (void)radeon_read_unposted_bios(pScrn);
        }
     }
 
@@ -160,7 +342,6 @@ Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr  
pInt10)
               info->IsAtomBios ? "ATOM":"Legacy");
 
     if (info->IsAtomBios) {
-#if 1
         AtomBiosArgRec atomBiosArg;
 
         if (RHDAtomBiosFunc(pScrn->scrnIndex, NULL, ATOMBIOS_INIT, 
&atomBiosArg)
@@ -194,8 +375,14 @@ Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr 
 pInt10)
         RHDAtomBiosFunc(pScrn->scrnIndex, info->atomBIOS,
                         GET_REF_CLOCK, &atomBiosArg);
 
-#endif
        info->MasterDataStart = RADEON_BIOS16 (info->ROMHeaderStart + 32);
+    } else {
+       /* non-primary card may need posting */
+       if (!pInt10) {
+           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Attempting to POST via BIOS 
tables\n");
+           RADEONGetBIOSInitTableOffsets(pScrn);
+           RADEONPostCardFromBIOSTables(pScrn);
+       }
     }
 
     return TRUE;
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 733e9c6..91421b5 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -1631,7 +1631,7 @@ static Bool RADEONPreInitChipType(ScrnInfoPtr pScrn)
            break;
        }
     }
-           
+
     switch (info->Chipset) {
     case PCI_CHIP_RN50_515E:  /* RN50 is based on the RV100 but 3D isn't 
guaranteed to work.  YMMV. */
     case PCI_CHIP_RN50_5969:
@@ -1980,6 +1980,20 @@ static Bool RADEONPreInitInt10(ScrnInfoPtr pScrn, 
xf86Int10InfoPtr *ppInt10)
     unsigned char *RADEONMMIO = info->MMIO;
     uint32_t       fp2_gen_ctl_save   = 0;
 
+#ifdef XSERVER_LIBPCIACCESS
+#if HAVE_PCI_DEVICE_ENABLE
+    pci_device_enable(info->PciInfo);
+#endif
+#endif
+    /* don't need int10 on atom cards.
+     * in theory all radeons, but the older stuff
+     * isn't 100% yet
+     */
+    if ((info->ChipFamily == CHIP_FAMILY_R420)  ||
+       (info->ChipFamily == CHIP_FAMILY_RV410) ||
+       (info->ChipFamily >= CHIP_FAMILY_RV515))
+       return TRUE;
+
     if (xf86LoadSubModule(pScrn, "int10")) {
        /* The VGA BIOS on the RV100/QY cannot be read when the digital output
         * is enabled.  Clear and restore FP2_ON around int10 to avoid this.
@@ -1991,13 +2005,15 @@ static Bool RADEONPreInitInt10(ScrnInfoPtr pScrn, 
xf86Int10InfoPtr *ppInt10)
                OUTREG(RADEON_FP2_GEN_CNTL, fp2_gen_ctl_save & ~RADEON_FP2_ON);
            }
        }
-       
+
        xf86DrvMsg(pScrn->scrnIndex,X_INFO,"initializing int10\n");
        *ppInt10 = xf86InitInt10(info->pEnt->index);
 
-       if (fp2_gen_ctl_save & RADEON_FP2_ON) {
-           xf86DrvMsg(pScrn->scrnIndex, X_INFO, "re-enabling digital out\n");
-           OUTREG(RADEON_FP2_GEN_CNTL, fp2_gen_ctl_save);      
+       if (PCI_DEV_DEVICE_ID(info->PciInfo) == PCI_CHIP_RV100_QY) {
+           if (fp2_gen_ctl_save & RADEON_FP2_ON) {
+               xf86DrvMsg(pScrn->scrnIndex, X_INFO, "re-enabling digital 
out\n");
+               OUTREG(RADEON_FP2_GEN_CNTL, fp2_gen_ctl_save);
+           }
        }
     }
 #endif
@@ -2470,10 +2486,6 @@ static Bool RADEONPreInitXv(ScrnInfoPtr pScrn)
 static void RADEONPreInitBIOS(ScrnInfoPtr pScrn, xf86Int10InfoPtr  pInt10)
 {
     RADEONGetBIOSInfo(pScrn, pInt10);
-#if 0
-    RADEONGetBIOSInitTableOffsets(pScrn);
-    RADEONPostCardFromBIOSTables(pScrn);
-#endif
 }
 
 static void RADEONFixZaphodOutputs(ScrnInfoPtr pScrn)
@@ -2747,14 +2759,14 @@ Bool RADEONPreInit(ScrnInfoPtr pScrn, int flags)
            info->DispPriority = 1;
     }
 
+    if (!RADEONPreInitChipType(pScrn))
+       goto fail;
+
     if (!RADEONPreInitInt10(pScrn, &pInt10))
        goto fail;
 
     RADEONPostInt10Check(pScrn, int10_save);
 
-    if (!RADEONPreInitChipType(pScrn))
-       goto fail;
-
     RADEONPreInitBIOS(pScrn, pInt10);
 
 #ifdef XF86DRI
@@ -5244,20 +5256,29 @@ Bool RADEONEnterVT(int scrnIndex, int flags)
 
     xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
                   "RADEONEnterVT\n");
+
     if (info->ChipFamily >= CHIP_FAMILY_R600)
        mem_size = INREG(R600_CONFIG_MEMSIZE);
     else
        mem_size = INREG(RADEON_CONFIG_MEMSIZE);
+
     if (mem_size == 0) { /* Softboot V_BIOS */
-       xf86Int10InfoPtr pInt;
-       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-                  "zero MEMSIZE, probably at D3cold. Re-POSTing via int10.\n");
-       pInt = xf86InitInt10 (info->pEnt->index);
-       if (pInt) {
-           pInt->num = 0xe6;
-           xf86ExecX86int10 (pInt);
-           xf86FreeInt10 (pInt);
-       }
+       if (info->IsAtomBios) {
+           rhdAtomASICInit(info->atomBIOS);
+       } else {
+           xf86Int10InfoPtr pInt;
+           xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                      "zero MEMSIZE, probably at D3cold. Re-POSTing via 
int10.\n");
+           pInt = xf86InitInt10 (info->pEnt->index);
+           if (pInt) {
+               pInt->num = 0xe6;
+               xf86ExecX86int10 (pInt);
+               xf86FreeInt10 (pInt);
+           } else {
+               RADEONGetBIOSInitTableOffsets(pScrn);
+               RADEONPostCardFromBIOSTables(pScrn);
+           }
+       }
     }
 
     /* Makes sure the engine is idle before doing anything */
diff --git a/src/radeon_reg.h b/src/radeon_reg.h
index c5ab0de..b2d6fd1 100644
--- a/src/radeon_reg.h
+++ b/src/radeon_reg.h
@@ -265,6 +265,7 @@
 #define RADEON_BRUSH_Y_X                    0x1474
 #define RADEON_BUS_CNTL                     0x0030
 #       define RADEON_BUS_MASTER_DIS         (1 << 6)
+#       define RADEON_BUS_BIOS_DIS_ROM       (1 << 12)
 #       define RADEON_BUS_RD_DISCARD_EN      (1 << 24)
 #       define RADEON_BUS_RD_ABORT_EN        (1 << 25)
 #       define RADEON_BUS_MSTR_DISCONNECT_EN (1 << 28)
@@ -1046,10 +1047,12 @@
 #       define RADEON_MC_MCLK_DYN_ENABLE    (1 << 14)
 #       define RADEON_IO_MCLK_DYN_ENABLE    (1 << 15)
 #define RADEON_LCD_GPIO_MASK                0x01a0
+#define RADEON_GPIOPAD_EN                   0x01a0
 #define RADEON_LCD_GPIO_Y_REG               0x01a4
 #define RADEON_MDGPIO_A_REG                 0x01ac
 #define RADEON_MDGPIO_EN_REG                0x01b0
 #define RADEON_MDGPIO_MASK                  0x0198
+#define RADEON_GPIOPAD_MASK                 0x0198
 #define RADEON_GPIOPAD_A                   0x019c
 #define RADEON_MDGPIO_Y_REG                 0x01b4
 #define RADEON_MEM_ADDR_CONFIG              0x0148
@@ -1084,6 +1087,9 @@
 #define RADEON_MPLL_CNTL                    0x000e /* PLL */
 #define RADEON_MPP_TB_CONFIG                0x01c0 /* ? */
 #define RADEON_MPP_GP_CONFIG                0x01c8 /* ? */
+#define RADEON_SEPROM_CNTL1                 0x01c0
+#       define RADEON_SCK_PRESCALE_SHIFT    24
+#       define RADEON_SCK_PRESCALE_MASK     (0xff << 24)
 #define R300_MC_IND_INDEX                   0x01f8
 #       define R300_MC_IND_ADDR_MASK        0x3f
 #       define R300_MC_IND_WR_EN            (1 << 8)
@@ -1648,6 +1654,7 @@
 #       define RADEON_VIP_BUSY 0
 #       define RADEON_VIP_IDLE 1
 #       define RADEON_VIP_RESET 2
+#       define RADEON_VIPH_EN               (1 << 21)
 #define RADEON_VIPH_DV_LAT                  0x0c44
 #define RADEON_VIPH_BM_CHUNK                0x0c48
 #define RADEON_VIPH_DV_INT                  0x0c4c
@@ -3435,6 +3442,8 @@
 
 #define AVIVO_HDP_FB_LOCATION 0x134
 
+#define AVIVO_VGA_RENDER_CONTROL                               0x0300
+#       define AVIVO_VGA_VSTATUS_CNTL_MASK                      (3 << 16)
 #define AVIVO_D1VGA_CONTROL                                    0x0330
 #       define AVIVO_DVGA_CONTROL_MODE_ENABLE (1<<0)
 #       define AVIVO_DVGA_CONTROL_TIMING_SELECT (1<<8)
@@ -3875,6 +3884,15 @@
 #      define AVIVO_I2C_EN                                                     
(1 << 0)
 #      define AVIVO_I2C_RESET                                          (1 << 8)
 
+#define R600_GENERAL_PWRMGT                                        0x618
+#      define R600_OPEN_DRAIN_PADS                                (1 << 11)
+
+#define R600_LOWER_GPIO_ENABLE                                     0x710
+#define R600_CTXSW_VID_LOWER_GPIO_CNTL                             0x718
+#define R600_HIGH_VID_LOWER_GPIO_CNTL                              0x71c
+#define R600_MEDIUM_VID_LOWER_GPIO_CNTL                            0x720
+#define R600_LOW_VID_LOWER_GPIO_CNTL                               0x724
+
 #define R600_MC_VM_FB_LOCATION                                     0x2180
 #define R600_MC_VM_AGP_TOP                                         0x2184
 #define R600_MC_VM_AGP_BOT                                         0x2188
@@ -3891,6 +3909,11 @@
 #define R600_CONFIG_F0_BASE                                     0x542C
 #define R600_CONFIG_APER_SIZE                                   0x5430
 
+#define R600_ROM_CNTL                              0x1600
+#       define R600_SCK_OVERWRITE                  (1 << 1)
+#       define R600_SCK_PRESCALE_CRYSTAL_CLK_SHIFT 28
+#       define R600_SCK_PRESCALE_CRYSTAL_CLK_MASK  (0xf << 28)
+
 #define R600_BIOS_0_SCRATCH               0x1724
 #define R600_BIOS_1_SCRATCH               0x1728
 #define R600_BIOS_2_SCRATCH               0x172c

commit 5f951a5573f0c7572230c9aa4d3f75d67f91ed71
Author: Alex Deucher <[EMAIL PROTECTED]>
Date:   Wed May 21 00:35:14 2008 -0400

    ATOM: remove duplicate code

diff --git a/src/radeon_atombios.c b/src/radeon_atombios.c
index fb7d002..db27362 100644
--- a/src/radeon_atombios.c
+++ b/src/radeon_atombios.c
@@ -575,69 +575,30 @@ rhdAtomInit(atomBiosHandlePtr unused1, AtomBiosRequestID 
unused2,
 {
     int scrnIndex = data->val;
     RADEONInfoPtr  info   = RADEONPTR(xf86Screens[scrnIndex]);
-    unsigned char *ptr;
     atomDataTablesPtr atomDataPtr;
     unsigned int cmd_offset;
     atomBiosHandlePtr handle = NULL;
     unsigned int BIOSImageSize = 0;
     data->atomhandle = NULL;
 
-    //RHDFUNCI(scrnIndex);
-
-    /*if (info->BIOSCopy) {
-       xf86DrvMsg(scrnIndex,X_INFO,"Getting BIOS copy from INT10\n");
-       ptr = info->BIOSCopy;
-       info->BIOSCopy = NULL;
-
-       BIOSImageSize = ptr[2] * 512;
-       if (BIOSImageSize > legacyBIOSMax) {
-           xf86DrvMsg(scrnIndex,X_ERROR,"Invalid BIOS length field\n");
-           return ATOM_FAILED;
-       }
-    } else*/ {
-       /*if (!xf86IsEntityPrimary(info->entityIndex)) {
-           if (!(BIOSImageSize = RHDReadPCIBios(info, &ptr)))
-               return ATOM_FAILED;
-       } else*/ {
-            int read_len;
-           unsigned char tmp[32];
-           xf86DrvMsg(scrnIndex,X_INFO,"Getting BIOS copy from legacy VBIOS 
location\n");
-           if (xf86ReadBIOS(legacyBIOSLocation, 0, tmp, 32) < 0) {
-               xf86DrvMsg(scrnIndex,X_ERROR,
-                          "Cannot obtain POSTed BIOS header\n");
-               return ATOM_FAILED;
-           }
-           BIOSImageSize = tmp[2] * 512;
-           if (BIOSImageSize > legacyBIOSMax) {
-               xf86DrvMsg(scrnIndex,X_ERROR,"Invalid BIOS length field\n");
-               return ATOM_FAILED;
-           }
-           if (!(ptr = xcalloc(1,BIOSImageSize))) {
-               xf86DrvMsg(scrnIndex,X_ERROR,
-                          "Cannot allocate %i bytes of memory "
-                          "for BIOS image\n",BIOSImageSize);
-               return ATOM_FAILED;
-           }
-           if ((read_len = xf86ReadBIOS(legacyBIOSLocation, 0, ptr, 
BIOSImageSize)
-                < 0)) {
-               xf86DrvMsg(scrnIndex,X_ERROR,"Cannot read POSTed BIOS\n");
-               goto error;
-           }
-       }
-    }
+#ifdef XSERVER_LIBPCIACCESS
+    BIOSImageSize = info->PciInfo->rom_size > RADEON_VBIOS_SIZE ? 
info->PciInfo->rom_size : RADEON_VBIOS_SIZE;
+#else
+    BIOSImageSize = RADEON_VBIOS_SIZE;
+#endif
 
     if (!(atomDataPtr = xcalloc(1, sizeof(atomDataTables)))) {
        xf86DrvMsg(scrnIndex,X_ERROR,"Cannot allocate memory for "
                   "ATOM BIOS data tabes\n");
        goto error;
     }
-    if (!rhdAtomGetDataTable(scrnIndex, ptr, atomDataPtr, &cmd_offset, 
BIOSImageSize))
+    if (!rhdAtomGetDataTable(scrnIndex, info->VBIOS, atomDataPtr, &cmd_offset, 
BIOSImageSize))
        goto error1;
     if (!(handle = xcalloc(1, sizeof(atomBiosHandleRec)))) {
        xf86DrvMsg(scrnIndex,X_ERROR,"Cannot allocate memory\n");
        goto error1;
     }
-    handle->BIOSBase = ptr;
+    handle->BIOSBase = info->VBIOS;
     handle->atomDataPtr = atomDataPtr;
     handle->cmd_offset = cmd_offset;
     handle->scrnIndex = scrnIndex;
@@ -665,7 +626,6 @@ rhdAtomInit(atomBiosHandlePtr unused1, AtomBiosRequestID 
unused2,
  error1:
     xfree(atomDataPtr);
  error:
-    xfree(ptr);
     return ATOM_FAILED;
 }
 
diff --git a/src/radeon_bios.c b/src/radeon_bios.c
index fa09aae..be72339 100644
--- a/src/radeon_bios.c
+++ b/src/radeon_bios.c
@@ -74,7 +74,6 @@ Bool RADEONGetBIOSInfo(ScrnInfoPtr pScrn, xf86Int10InfoPtr  
pInt10)
     unsigned short dptr;
 
 #ifdef XSERVER_LIBPCIACCESS
-    //info->VBIOS = xalloc(info->PciInfo->rom_size);
     int size = info->PciInfo->rom_size > RADEON_VBIOS_SIZE ? 
info->PciInfo->rom_size : RADEON_VBIOS_SIZE;
     info->VBIOS = xalloc(size);
 #else

commit edce33e87fb79a540d8c285f205d4c3f2c2bc9f4
Author: Dave Airlie <[EMAIL PROTECTED]>
Date:   Wed May 28 06:43:40 2008 +1000

    radeon: fix surface access on avivo chips.
    
    This should fix VT switch on vesafb

diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 7124b11..733e9c6 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -3224,9 +3224,11 @@ Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
 #endif
 
     /* Initial setup of surfaces */
-    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
-                   "Setting up initial surfaces\n");
-    RADEONChangeSurfaces(pScrn);
+    if (info->ChipFamily < CHIP_FAMILY_R600) {
+        xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
+                       "Setting up initial surfaces\n");
+        RADEONChangeSurfaces(pScrn);
+    }
 
                                /* Memory manager setup */
 
@@ -3457,10 +3459,12 @@ Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen,
 #endif
 
     /* Make sure surfaces are allright since DRI setup may have changed them */
-    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
-                   "Setting up final surfaces\n");
+    if (info->ChipFamily < CHIP_FAMILY_R600) {
+        xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
+                       "Setting up final surfaces\n");
 
-    RADEONChangeSurfaces(pScrn);
+        RADEONChangeSurfaces(pScrn);
+    }
 
 
     /* Enable aceleration */
@@ -4037,7 +4041,8 @@ void RADEONChangeSurfaces(ScrnInfoPtr pScrn)
     }
 
     /* Update surface images */
-    RADEONSaveSurfaces(pScrn, info->ModeReg);
+    if (info->ChipFamily < CHIP_FAMILY_R600)
+        RADEONSaveSurfaces(pScrn, info->ModeReg);
 }
 
 /* Read memory map */
@@ -4808,7 +4813,8 @@ static void RADEONSave(ScrnInfoPtr pScrn)
     }
 
     RADEONSaveBIOSRegisters(pScrn, save);
-    RADEONSaveSurfaces(pScrn, save);
+    if (info->ChipFamily < CHIP_FAMILY_R600)
+        RADEONSaveSurfaces(pScrn, save);
 
 }
 
@@ -4864,9 +4870,9 @@ static void RADEONRestore(ScrnInfoPtr pScrn)
        }
 
        RADEONRestoreBIOSRegisters(pScrn, restore);
-       RADEONRestoreSurfaces(pScrn, restore);
     }
 
+
 #if 1
     /* Temp fix to "solve" VT switch problems.  When switching VTs on
      * some systems, the console can either hang or the fonts can be
@@ -4876,6 +4882,9 @@ static void RADEONRestore(ScrnInfoPtr pScrn)
     usleep(100000);
 #endif
 
+    if (info->ChipFamily < CHIP_FAMILY_R600)
+       RADEONRestoreSurfaces(pScrn, restore);
+
     /* need to make sure we don't enable a crtc by accident or we may get a 
hang */
     if (pRADEONEnt->HasCRTC2 && !info->IsSecondary) {
        if (info->crtc2_on && xf86_config->num_crtc > 1) {
@@ -5275,7 +5284,8 @@ Bool RADEONEnterVT(int scrnIndex, int flags)
     if (!xf86SetDesiredModes(pScrn))
        return FALSE;
 
-    RADEONRestoreSurfaces(pScrn, info->ModeReg);
+    if (info->ChipFamily < CHIP_FAMILY_R600)
+        RADEONRestoreSurfaces(pScrn, info->ModeReg);
 #ifdef XF86DRI
     if (info->directRenderingEnabled) {
        if (info->cardType == CARD_PCIE &&

commit 307bd65a25ee425d8359dd30572b002ce2338f91
Author: Michael Babej <[EMAIL PROTECTED]>
Date:   Tue May 27 19:13:49 2008 +1000

    r600: fix vt switch issue
    
    RH BZ 441492

diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 83e0f85..7124b11 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -5231,11 +5231,15 @@ Bool RADEONEnterVT(int scrnIndex, int flags)
     ScrnInfoPtr    pScrn = xf86Screens[scrnIndex];
     RADEONInfoPtr  info  = RADEONPTR(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
+    uint32_t mem_size;
 
     xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
                   "RADEONEnterVT\n");
-
-    if ((INREG(RADEON_CONFIG_MEMSIZE)) == 0) { /* Softboot V_BIOS */
+    if (info->ChipFamily >= CHIP_FAMILY_R600)
+       mem_size = INREG(R600_CONFIG_MEMSIZE);
+    else
+       mem_size = INREG(RADEON_CONFIG_MEMSIZE);
+    if (mem_size == 0) { /* Softboot V_BIOS */
        xf86Int10InfoPtr pInt;
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                   "zero MEMSIZE, probably at D3cold. Re-POSTing via int10.\n");

commit bf48c9eb8ec592515be9d1732d60283af715674d
Author: Dave Airlie <[EMAIL PROTECTED]>
Date:   Sat May 24 11:51:20 2008 +1000

    atombios: for LVDS set use ref div as per legacy

diff --git a/src/atombios_crtc.c b/src/atombios_crtc.c
index 5cb79e2..b5b7ca8 100644
--- a/src/atombios_crtc.c
+++ b/src/atombios_crtc.c
@@ -161,7 +161,7 @@ atombios_set_crtc_timing(atomBiosHandlePtr atomBIOS, 
SET_CRTC_TIMING_PARAMETERS_
 }
 
 void
-atombios_crtc_set_pll(xf86CrtcPtr crtc, DisplayModePtr mode)
+atombios_crtc_set_pll(xf86CrtcPtr crtc, DisplayModePtr mode, int pll_flags)
 {
     RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
     RADEONInfoPtr  info = RADEONPTR(crtc->scrn);
@@ -174,8 +174,6 @@ atombios_crtc_set_pll(xf86CrtcPtr crtc, DisplayModePtr mode)
     SET_PIXEL_CLOCK_PS_ALLOCATION spc_param;
     PIXEL_CLOCK_PARAMETERS_V2 *spc2_ptr;
     PIXEL_CLOCK_PARAMETERS_V3 *spc3_ptr;
-    int pll_flags = 0;
-
     xf86OutputPtr output;
     RADEONOutputPrivatePtr radeon_output = NULL;
 
@@ -334,7 +332,7 @@ atombios_crtc_mode_set(xf86CrtcPtr crtc,
     int i, ret;
     SET_CRTC_TIMING_PARAMETERS_PS_ALLOCATION crtc_timing;
     Bool tilingChanged = FALSE;
-
+    int pll_flags = 0;
     memset(&crtc_timing, 0, sizeof(crtc_timing));
 
     if (info->allowColorTiling) {
@@ -356,6 +354,9 @@ atombios_crtc_mode_set(xf86CrtcPtr crtc,
                    need_tv_timings = 2;
 
            }
+
+           if (radeon_output->MonType == MT_LCD)
+             pll_flags |= RADEON_PLL_USE_REF_DIV;
        }
     }
 
@@ -475,7 +476,7 @@ atombios_crtc_mode_set(xf86CrtcPtr crtc,
 
     }
 
-    atombios_crtc_set_pll(crtc, adjusted_mode);
+    atombios_crtc_set_pll(crtc, adjusted_mode, pll_flags);
 
     atombios_set_crtc_timing(info->atomBIOS, &crtc_timing);
 


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to