[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-ati: Changes to 'upstream-experimental'



 configure.ac                 |    2 
 man/radeon.man               |   51 +++++++-
 src/Makefile.am              |    9 +
 src/ati_pciids_gen.h         |  219 ++++++++++++++++++++++++++++++++++++
 src/atidri.c                 |   26 ++--
 src/atipciids.h              |  248 -----------------------------------------
 src/pcidb/ati_pciids.csv     |  220 ++++++++++++++++++++++++++++++++++++
 src/pcidb/parse_pci_ids.pl   |   94 +++++++++++++++
 src/radeon.h                 |   30 ++++
 src/radeon_chipinfo_gen.h    |  140 +++++++++++++++++++++++
 src/radeon_chipset.h         |  142 -----------------------
 src/radeon_chipset_gen.h     |  141 +++++++++++++++++++++++
 src/radeon_crtc.c            |    4 
 src/radeon_dri.c             |   30 ++--
 src/radeon_driver.c          |  260 +++++--------------------------------------
 src/radeon_output.c          |  212 ++++++++++++++++++++++++++++-------
 src/radeon_pci_chipset_gen.h |  141 +++++++++++++++++++++++
 src/radeon_probe.c           |  145 -----------------------
 src/radeon_render.c          |    4 
 src/radeon_tv.c              |    8 -
 src/radeon_video.c           |   56 ++++-----
 21 files changed, 1309 insertions(+), 873 deletions(-)

New commits:
commit 5022d006cfc06ca0395981526b2c2c94c6878567
Author: Michel Dänzer <michel@tungstengraphics.com>
Date:   Sun Dec 2 17:27:33 2007 +0100

    radeon: Further XVideo fixes.
    
    * Make sure pitch constraints are always met for DMA upload blits.
    * RGB24 is not affected by endianness.

diff --git a/src/radeon_video.c b/src/radeon_video.c
index 332f2cd..3f0209e 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -414,11 +414,11 @@ static XF86AttributeRec Attributes[NUM_DEC_ATTRIBUTES+1] =
 
 #define FOURCC_RGB24    0x00000000
 
-#define XVIMAGE_RGB24(byte_order)   \
+#define XVIMAGE_RGB24   \
         { \
                 FOURCC_RGB24, \
                 XvRGB, \
-                byte_order, \
+                LSBFirst, \
                 { 'R', 'G', 'B', 0, \
                   0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
                 24, \
@@ -473,15 +473,14 @@ static XF86ImageRec Images[NUM_IMAGES] =
 {
 #if X_BYTE_ORDER == X_BIG_ENDIAN
         XVIMAGE_RGBA32(MSBFirst),
-        XVIMAGE_RGB24(MSBFirst),
         XVIMAGE_RGBT16(MSBFirst),
         XVIMAGE_RGB16(MSBFirst),
 #else
         XVIMAGE_RGBA32(LSBFirst),
-        XVIMAGE_RGB24(LSBFirst),
         XVIMAGE_RGBT16(LSBFirst),
         XVIMAGE_RGB16(LSBFirst),
 #endif
+        XVIMAGE_RGB24,
         XVIMAGE_YUY2,
         XVIMAGE_UYVY,
         XVIMAGE_YV12,
@@ -2210,8 +2209,6 @@ RADEONCopyRGB24Data(
 	int x, y;
 	unsigned int hpass;
 
-	/* XXX Fix endian flip on R300 */
-
 	RADEONHostDataParams( pScrn, dst, dstPitch, 4, &dstPitchOff, &x, &y );
 
 	while ( (dptr = ( CARD32* )RADEONHostDataBlit( pScrn, 4, w, dstPitchOff,
@@ -2224,14 +2221,11 @@ RADEONCopyRGB24Data(
 
 		for ( i = 0 ; i < w; i++, sptr += 3 )
 		{
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-		    *dptr++ = (sptr[0] << 16) | (sptr[1] << 8) | sptr[2];
-#else
-		    *dptr++ = (sptr[2] << 16) | (sptr[1] << 8) | sptr[0];
-#endif
+		    dptr[i] = (sptr[2] << 16) | (sptr[1] << 8) | sptr[0];
 		}
 
 		src += srcPitch;
+		dptr += bufPitch / 4;
 	    }
 	}
 
@@ -2249,17 +2243,12 @@ RADEONCopyRGB24Data(
 				  & ~RADEON_NONSURF_AP0_SWP_16BPP);
 #endif
 
-	for(j=0;j<h;j++){
-	    dptr=(CARD32 *)(dst+j*dstPitch);
-	    sptr=src+j*srcPitch;
+	for (j = 0; j < h; j++) {
+	    dptr = (CARD32 *)(dst + j * dstPitch);
+	    sptr = src + j * srcPitch;
 
-	    for(i=w;i>0;i--){
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-	      *dptr++=((sptr[0])<<16)|((sptr[1])<<8)|(sptr[2]);
-#else
-	      *dptr++=((sptr[2])<<16)|((sptr[1])<<8)|(sptr[0]);
-#endif
-	      sptr+=3;
+	    for (i = 0; i < w; i++, sptr += 3) {
+		dptr[i] = (sptr[2] << 16) | (sptr[1] << 8) | sptr[0];
 	    }
 	}
 
@@ -2933,17 +2922,17 @@ RADEONPutImage(
 
    switch(id) {
    case FOURCC_RGB24:
-   	dstPitch=(width*4+0x0f)&(~0x0f);
-	srcPitch=width*3;
+	dstPitch = width * 4;
+	srcPitch = width * 3;
 	break;
    case FOURCC_RGBA32:
-   	dstPitch=(width*4+0x0f)&(~0x0f);
-	srcPitch=width*4;
+	dstPitch = width * 4;
+	srcPitch = width * 4;
 	break;
    case FOURCC_RGB16:
    case FOURCC_RGBT16:
-   	dstPitch=(width*2+0x0f)&(~0x0f);
-	srcPitch=(width*2+3)&(~0x03);
+	dstPitch = width * 2;
+	srcPitch = (width * 2 + 3) & ~3;
 	break;
    case FOURCC_YV12:
    case FOURCC_I420:
@@ -2956,11 +2945,20 @@ RADEONPutImage(
    case FOURCC_UYVY:
    case FOURCC_YUY2:
    default:
-	dstPitch = ((width << 1) + 63) & ~63;
-	srcPitch = (width << 1);
+	dstPitch = width * 2;
+	srcPitch = width * 2;
 	break;
    }
 
+#ifdef XF86DRI
+   if (info->directRenderingEnabled && info->DMAForXv) {
+       /* The upload blit only supports multiples of 64 bytes */
+       dstPitch = (dstPitch + 63) & ~63;
+   } else
+#endif
+       /* The overlay only supports multiples of 16 bytes */
+       dstPitch = (dstPitch + 15) & ~15;
+
    new_size = dstPitch * height;
    if (id == FOURCC_YV12 || id == FOURCC_I420) {
       new_size += (dstPitch >> 1) * ((height + 1) & ~1);

commit 6ed55b70b23dfdc7b41103ea59c1df2bda5e41e6
Author: Kusanagi Kouichi <slash@ma.neweb.ne.jp>
Date:   Sun Dec 2 17:18:46 2007 +0100

    radeon: Fix crash with XVideo 24bit RGB images.
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=13274 .

diff --git a/src/radeon_video.c b/src/radeon_video.c
index 26857a5..332f2cd 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -2199,7 +2199,7 @@ RADEONCopyRGB24Data(
   unsigned int w
 ){
     CARD32 *dptr;
-    CARD8 *sptr = 0;
+    CARD8 *sptr;
     int i,j;
     RADEONInfoPtr info = RADEONPTR(pScrn);
 #ifdef XF86DRI
@@ -2214,7 +2214,7 @@ RADEONCopyRGB24Data(
 
 	RADEONHostDataParams( pScrn, dst, dstPitch, 4, &dstPitchOff, &x, &y );
 
-	while ( (dptr = ( CARD32* )RADEONHostDataBlit( pScrn, 4, w, dstPitch,
+	while ( (dptr = ( CARD32* )RADEONHostDataBlit( pScrn, 4, w, dstPitchOff,
 						       &bufPitch, x, &y, &h,
 						       &hpass )) )
 	{
@@ -2224,11 +2224,14 @@ RADEONCopyRGB24Data(
 
 		for ( i = 0 ; i < w; i++, sptr += 3 )
 		{
-		    *dptr++ = (sptr[0] << 24) | (sptr[1] << 16) | sptr[2];
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+		    *dptr++ = (sptr[0] << 16) | (sptr[1] << 8) | sptr[2];
+#else
+		    *dptr++ = (sptr[2] << 16) | (sptr[1] << 8) | sptr[0];
+#endif
 		}
 
-		src += hpass * srcPitch;
-		dptr += hpass * bufPitch;
+		src += srcPitch;
 	    }
 	}
 
@@ -2251,8 +2254,11 @@ RADEONCopyRGB24Data(
 	    sptr=src+j*srcPitch;
 
 	    for(i=w;i>0;i--){
-	      dptr[0]=((sptr[0])<<24)|((sptr[1])<<16)|(sptr[2]);
-	      dptr++;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+	      *dptr++=((sptr[0])<<16)|((sptr[1])<<8)|(sptr[2]);
+#else
+	      *dptr++=((sptr[2])<<16)|((sptr[1])<<8)|(sptr[0]);
+#endif
 	      sptr+=3;
 	    }
 	}

commit a697b590899bb7704ec4d7ae9a9c3cbbfcaef382
Author: Michel Dänzer <michel@tungstengraphics.com>
Date:   Sun Dec 2 17:11:20 2007 +0100

    Fix build against xserver master.
    
    (DE)ALLOCATE_LOCAL are gone.

diff --git a/src/atidri.c b/src/atidri.c
index bc862a8..0da1bc5 100644
--- a/src/atidri.c
+++ b/src/atidri.c
@@ -553,11 +553,11 @@ static void ATIDRIMoveBuffers( WindowPtr pWin, DDXPointRec ptOldOrg,
 
 	if (nbox > 1) {
 	    /* Keep ordering in each band, reverse order of bands */
-	    pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+	    pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
 	    if (!pboxNew1) return;
-	    pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+	    pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
 	    if (!pptNew1) {
-		DEALLOCATE_LOCAL(pboxNew1);
+		xfree(pboxNew1);
 		return;
 	    }
 	    pboxBase = pboxNext = pbox+nbox-1;
@@ -588,13 +588,13 @@ static void ATIDRIMoveBuffers( WindowPtr pWin, DDXPointRec ptOldOrg,
 
 	if (nbox > 1) {
 	    /* reverse order of rects in each band */
-	    pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
-	    pptNew2  = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+	    pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
+	    pptNew2  = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
 	    if (!pboxNew2 || !pptNew2) {
-		DEALLOCATE_LOCAL(pptNew2);
-		DEALLOCATE_LOCAL(pboxNew2);
-		DEALLOCATE_LOCAL(pptNew1);
-		DEALLOCATE_LOCAL(pboxNew1);
+		xfree(pptNew2);
+		xfree(pboxNew2);
+		xfree(pptNew1);
+		xfree(pboxNew1);
 		return;
 	    }
 	    pboxBase = pboxNext = pbox;
@@ -665,10 +665,10 @@ static void ATIDRIMoveBuffers( WindowPtr pWin, DDXPointRec ptOldOrg,
     outf(SRC_OFF_PITCH, pATI->NewHW.dst_off_pitch);
     outf(DST_OFF_PITCH, pATI->NewHW.src_off_pitch);
 
-    DEALLOCATE_LOCAL(pptNew2);
-    DEALLOCATE_LOCAL(pboxNew2);
-    DEALLOCATE_LOCAL(pptNew1);
-    DEALLOCATE_LOCAL(pboxNew1);
+    xfree(pptNew2);
+    xfree(pboxNew2);
+    xfree(pptNew1);
+    xfree(pboxNew1);
 
     ATIDRIMarkSyncInt(pScreenInfo);
 #endif
diff --git a/src/radeon_dri.c b/src/radeon_dri.c
index ed418b8..7136e4e 100644
--- a/src/radeon_dri.c
+++ b/src/radeon_dri.c
@@ -559,12 +559,12 @@ static void RADEONDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
 
 	if (nbox > 1) {
 	    /* Keep ordering in each band, reverse order of bands */
-	    pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+	    pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
 	    if (!pboxNew1) return;
 
-	    pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+	    pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
 	    if (!pptNew1) {
-		DEALLOCATE_LOCAL(pboxNew1);
+		xfree(pboxNew1);
 		return;
 	    }
 
@@ -601,14 +601,14 @@ static void RADEONDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
 
 	if (nbox > 1) {
 	    /* reverse order of rects in each band */
-	    pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
-	    pptNew2  = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+	    pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
+	    pptNew2  = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
 
 	    if (!pboxNew2 || !pptNew2) {
-		DEALLOCATE_LOCAL(pptNew2);
-		DEALLOCATE_LOCAL(pboxNew2);
-		DEALLOCATE_LOCAL(pptNew1);
-		DEALLOCATE_LOCAL(pboxNew1);
+		xfree(pptNew2);
+		xfree(pboxNew2);
+		xfree(pptNew1);
+		xfree(pboxNew1);
 		return;
 	    }
 
@@ -679,10 +679,10 @@ static void RADEONDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
 
     info->dst_pitch_offset = info->frontPitchOffset;;
 
-    DEALLOCATE_LOCAL(pptNew2);
-    DEALLOCATE_LOCAL(pboxNew2);
-    DEALLOCATE_LOCAL(pptNew1);
-    DEALLOCATE_LOCAL(pboxNew1);
+    xfree(pptNew2);
+    xfree(pboxNew2);
+    xfree(pptNew1);
+    xfree(pboxNew1);
 
     info->accel->NeedToSync = TRUE;
 #endif /* USE_XAA */

commit 00b4480aa2c5d7f751e34fc964f431b90b14c8d2
Author: Alex Deucher <alex@t41p.hsd1.va.comcast.net>
Date:   Sat Dec 1 14:18:40 2007 -0500

    RADEON: add options for force TV out as detected and to set TV standard
    
    Also fix a typo in internal tv-out parsing

diff --git a/man/radeon.man b/man/radeon.man
index 41c7242..881612a 100644
--- a/man/radeon.man
+++ b/man/radeon.man
@@ -440,6 +440,31 @@ mini                 \-\- mini-external alias
 The default value is
 .B undefined.
 .TP
+.BI "Option \*qTVStandard\*q \*q" string \*q
+.br
+Used to specify the default TV standard if you want to use something other than
+the bios default. Valid options are:
+.br
+ntsc
+.br
+pal
+.br
+pal-m
+.br
+pal-60
+.br
+ntsc-j
+.br
+scart-pal
+.br
+The default value is
+.B undefined.
+.TP
+.BI "Option \*qForceTVOut\*q \*q" boolean \*q
+Enable this option to force TV Out to always be detected as attached.
+The default is
+.B off 
+.TP
 
 .SH SEE ALSO
 __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
diff --git a/src/radeon.h b/src/radeon.h
index f9bf343..78f756e 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -158,7 +158,9 @@ typedef enum {
     OPTION_MAC_MODEL,
 #endif
     OPTION_DEFAULT_TMDS_PLL,
-    OPTION_TVDAC_LOAD_DETECT
+    OPTION_TVDAC_LOAD_DETECT,
+    OPTION_FORCE_TVOUT,
+    OPTION_TVSTD
 } RADEONOpts;
 
 
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index 0465497..3422b66 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -192,6 +192,8 @@ static const OptionInfoRec RADEONOptions[] = {
     { OPTION_MAC_MODEL,      "MacModel",         OPTV_STRING,  {0}, FALSE },
 #endif
     { OPTION_TVDAC_LOAD_DETECT, "TVDACLoadDetect", OPTV_BOOLEAN, {0}, FALSE },
+    { OPTION_FORCE_TVOUT,    "ForceTVOut",         OPTV_BOOLEAN, {0}, FALSE },
+    { OPTION_TVSTD,          "TVStandard",         OPTV_STRING,  {0}, FALSE },
     { -1,                    NULL,               OPTV_NONE,    {0}, FALSE }
 };
 
@@ -1522,7 +1524,7 @@ static Bool RADEONPreInitChipType(ScrnInfoPtr pScrn)
 	    info->IsIGP = card->igp;
 	    pRADEONEnt->HasCRTC2 = !card->nocrtc2;
 	    info->HasSingleDAC = card->singledac;
-	    info->InternalTVOut = card->nointtvout;
+	    info->InternalTVOut = !card->nointtvout;
 	    break;
 	}
     }
diff --git a/src/radeon_output.c b/src/radeon_output.c
index efe093f..4e5aded 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -634,11 +634,18 @@ void RADEONConnectorFindMonitor(ScrnInfoPtr pScrn, xf86OutputPtr output)
 
     if (radeon_output->MonType == MT_UNKNOWN) {
 	if (radeon_output->type == OUTPUT_STV || radeon_output->type == OUTPUT_CTV) {
-	    if (info->InternalTVOut) {
-		if (radeon_output->load_detection)
-		    radeon_output->MonType = radeon_detect_tv(pScrn);
+	    if (xf86ReturnOptValBool(info->Options, OPTION_FORCE_TVOUT, FALSE)) {
+		if (radeon_output->type == OUTPUT_STV)
+		    radeon_output->MonType = MT_STV;
 		else
-		    radeon_output->MonType = MT_NONE;
+		    radeon_output->MonType = MT_CTV;
+	    } else {
+		if (info->InternalTVOut) {
+		    if (radeon_output->load_detection)
+			radeon_output->MonType = radeon_detect_tv(pScrn);
+		    else
+			radeon_output->MonType = MT_NONE;
+		}
 	    }
 	} else {
 	    radeon_output->MonType = RADEONDisplayDDCConnected(pScrn, output);
@@ -1759,6 +1766,7 @@ radeon_create_resources(xf86OutputPtr output)
     INT32 range[2];
     int data, err;
     const char *s;
+    char *optstr;
 
     /* backlight control */
     if (radeon_output->type == OUTPUT_LVDS) {
@@ -1994,6 +2002,26 @@ radeon_create_resources(xf86OutputPtr output)
 	    s = "ntsc";
 	    break;
 	}
+
+	optstr = (char *)xf86GetOptValString(info->Options, OPTION_TVSTD);
+	if (optstr) {
+	    if (!strncmp("ntsc", optstr, strlen("ntsc")))
+		radeon_output->tvStd = TV_STD_NTSC;
+	    else if (!strncmp("pal", optstr, strlen("pal")))
+		radeon_output->tvStd = TV_STD_PAL;
+	    else if (!strncmp("pal-m", optstr, strlen("pal-m")))
+		radeon_output->tvStd = TV_STD_PAL_M;
+	    else if (!strncmp("pal-60", optstr, strlen("pal-60")))
+		radeon_output->tvStd = TV_STD_PAL_60;
+	    else if (!strncmp("ntsc-j", optstr, strlen("ntsc-j")))
+		radeon_output->tvStd = TV_STD_NTSC_J;
+	    else if (!strncmp("scart-pal", optstr, strlen("scart-pal")))
+		radeon_output->tvStd = TV_STD_SCART_PAL;
+	    else {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid TV Standard: %s\n", optstr);
+	    }
+	}
+
 	err = RRChangeOutputProperty(output->randr_output, tv_std_atom,
 				     XA_STRING, 8, PropModeReplace, strlen(s), (pointer)s,
 				     FALSE, FALSE);

commit 0175b79987ef4d7b0ce8238c3bdde989e504516a
Author: Alex Deucher <alex@botch2.(none)>
Date:   Fri Nov 30 15:37:42 2007 -0500

    RADEON: rework MacModel option
    
    this brings in some previous research from Michel Dänzer,
    Sjoerd Simons, and myself.  Hopefully, the driver will pick
    the correct MacModel in more cases.  This also changes the
    default connector table for desktop Macs to dual DVI rather
    than DVI+VGA as that seems to be the case more often than not.
    External TMDS chips are handled separately now as well.
    Eventually we should add an option to allow the user to specify
    what external TMDS chip they need, but we don't have enough info
    yet, so we'll rely on OF to init the external chip in most cases
    for now.

diff --git a/man/radeon.man b/man/radeon.man
index 8f7b551..41c7242 100644
--- a/man/radeon.man
+++ b/man/radeon.man
@@ -421,14 +421,22 @@ a powerbook or mini with DVI that does not work properly, try the alternate
 .br
 ibook                \-\- ibooks
 .br
-powerbook-duallink   \-\- Powerbooks with external DVI
+powerbook-external   \-\- Powerbooks with external DVI
 .br
-powerbook            \-\- Powerbooks with integrated DVI
+powerbook-internal   \-\- Powerbooks with integrated DVI
 .br
-mini                 \-\- Mac Mini with external DVI
+powerbook-vga        \-\- Powerbooks with VGA rather than DVI
+.br
+powerbook-duallink   \-\- powerbook-external alias
+.br
+powerbook            \-\- powerbook-internal alias
+.br
+mini-external        \-\- Mac Mini with external DVI
 .br
 mini-internal        \-\- Mac Mini with integrated DVI
 .br
+mini                 \-\- mini-external alias
+.br
 The default value is
 .B undefined.
 .TP
diff --git a/src/radeon.h b/src/radeon.h
index 4180752..f9bf343 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -428,13 +428,19 @@ typedef enum {
        CHIP_ERRATA_PLL_DELAY           = 0x00000004
 } RADEONErrata;
 
+typedef enum {
+    RADEON_SIL_164  = 0x00000001,
+    RADEON_SIL_1178 = 0x00000002
+} RADEONExtTMDSChip;
+
 #if defined(__powerpc__)
 typedef enum {
-       RADEON_MAC_IBOOK             = 0x00000001,
-       RADEON_MAC_POWERBOOK_DL      = 0x00000002,
-       RADEON_MAC_POWERBOOK         = 0x00000004,
-       RADEON_MAC_MINI              = 0x00000008,
-       RADEON_MAC_MINI_INTERNAL     = 0x00000016
+       RADEON_MAC_IBOOK              = 0x00000001,
+       RADEON_MAC_POWERBOOK_EXTERNAL = 0x00000002,
+       RADEON_MAC_POWERBOOK_INTERNAL = 0x00000004,
+       RADEON_MAC_POWERBOOK_VGA      = 0x00000008,
+       RADEON_MAC_MINI_EXTERNAL      = 0x00000016,
+       RADEON_MAC_MINI_INTERNAL      = 0x00000032
 } RADEONMacModel;
 #endif
 
@@ -827,6 +833,7 @@ typedef struct {
 #if defined(__powerpc__)
     RADEONMacModel    MacModel;
 #endif
+    RADEONExtTMDSChip ext_tmds_chip;
 
     Rotation rotation;
     void (*PointerMoved)(int, int, int);
diff --git a/src/radeon_output.c b/src/radeon_output.c
index 1645b5a..efe093f 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -218,22 +218,33 @@ RADEONRestoreDVOChip(ScrnInfoPtr pScrn, xf86OutputPtr output)
 	   (CARD32)~(RADEON_GPIO_A_0 | RADEON_GPIO_A_1));
 
     if (!RADEONInitExtTMDSInfoFromBIOS(output)) {
-	/* do mac stuff here */
-#if defined(__powerpc__)
 	if (radeon_output->DVOChip) {
-	    switch(info->MacModel) {
-	    case RADEON_MAC_POWERBOOK_DL:
+	    switch(info->ext_tmds_chip) {
+	    case RADEON_SIL_164:
 		RADEONDVOWriteByte(radeon_output->DVOChip, 0x08, 0x30);
 		RADEONDVOWriteByte(radeon_output->DVOChip, 0x09, 0x00);
 		RADEONDVOWriteByte(radeon_output->DVOChip, 0x0a, 0x90);
 		RADEONDVOWriteByte(radeon_output->DVOChip, 0x0c, 0x89);
 		RADEONDVOWriteByte(radeon_output->DVOChip, 0x08, 0x3b);
 		break;
+#if 0
+		/* needs work see bug 10418 */
+	    case RADEON_SIL_1178:
+		RADEONDVOWriteByte(radeon_output->DVOChip, 0x0f, 0x44);
+		RADEONDVOWriteByte(radeon_output->DVOChip, 0x0f, 0x4c);
+		RADEONDVOWriteByte(radeon_output->DVOChip, 0x0e, 0x01);
+		RADEONDVOWriteByte(radeon_output->DVOChip, 0x0a, 0x80);
+                RADEONDVOWriteByte(radeon_output->DVOChip, 0x09, 0x30);
+                RADEONDVOWriteByte(radeon_output->DVOChip, 0x0c, 0xc9);
+                RADEONDVOWriteByte(radeon_output->DVOChip, 0x0d, 0x70);
+                RADEONDVOWriteByte(radeon_output->DVOChip, 0x08, 0x32);
+                RADEONDVOWriteByte(radeon_output->DVOChip, 0x08, 0x33);
+		break;
+#endif
 	    default:
 		break;
 	    }
 	}
-#endif
     }
 }
 
@@ -2667,7 +2678,7 @@ static Bool RADEONSetupAppleConnectors(ScrnInfoPtr pScrn)
 	info->BiosConnector[2].DDCType = DDC_NONE_DETECTED;
 	info->BiosConnector[2].valid = TRUE;
 	return TRUE;
-    case RADEON_MAC_POWERBOOK_DL:
+    case RADEON_MAC_POWERBOOK_EXTERNAL:
 	info->BiosConnector[0].DDCType = DDC_DVI;
 	info->BiosConnector[0].DACType = DAC_NONE;
 	info->BiosConnector[0].TMDSType = TMDS_NONE;
@@ -2686,7 +2697,7 @@ static Bool RADEONSetupAppleConnectors(ScrnInfoPtr pScrn)
 	info->BiosConnector[2].DDCType = DDC_NONE_DETECTED;
 	info->BiosConnector[2].valid = TRUE;
 	return TRUE;
-    case RADEON_MAC_POWERBOOK:
+    case RADEON_MAC_POWERBOOK_INTERNAL:
 	info->BiosConnector[0].DDCType = DDC_DVI;
 	info->BiosConnector[0].DACType = DAC_NONE;
 	info->BiosConnector[0].TMDSType = TMDS_NONE;
@@ -2705,7 +2716,26 @@ static Bool RADEONSetupAppleConnectors(ScrnInfoPtr pScrn)
 	info->BiosConnector[2].DDCType = DDC_NONE_DETECTED;
 	info->BiosConnector[2].valid = TRUE;
 	return TRUE;
-    case RADEON_MAC_MINI:
+    case RADEON_MAC_POWERBOOK_VGA:
+	info->BiosConnector[0].DDCType = DDC_DVI;
+	info->BiosConnector[0].DACType = DAC_NONE;
+	info->BiosConnector[0].TMDSType = TMDS_NONE;
+	info->BiosConnector[0].ConnectorType = CONNECTOR_CRT;
+	info->BiosConnector[0].valid = TRUE;
+
+	info->BiosConnector[1].DDCType = DDC_VGA;
+	info->BiosConnector[1].DACType = DAC_PRIMARY;
+	info->BiosConnector[1].TMDSType = TMDS_INT;
+	info->BiosConnector[1].ConnectorType = CONNECTOR_DVI_I;
+	info->BiosConnector[1].valid = TRUE;
+
+	info->BiosConnector[2].ConnectorType = CONNECTOR_STV;
+	info->BiosConnector[2].DACType = DAC_TVDAC;
+	info->BiosConnector[2].TMDSType = TMDS_NONE;
+	info->BiosConnector[2].DDCType = DDC_NONE_DETECTED;
+	info->BiosConnector[2].valid = TRUE;
+	return TRUE;
+    case RADEON_MAC_MINI_EXTERNAL:
 	info->BiosConnector[0].DDCType = DDC_CRT2;
 	info->BiosConnector[0].DACType = DAC_TVDAC;
 	info->BiosConnector[0].TMDSType = TMDS_EXT;
@@ -2815,11 +2845,19 @@ static void RADEONSetupGenericConnectors(ScrnInfoPtr pScrn)
 	    info->BiosConnector[0].ConnectorType = CONNECTOR_DVI_I;
 	    info->BiosConnector[0].valid = TRUE;
 
+#if defined(__powerpc__)
 	    info->BiosConnector[1].DDCType = DDC_VGA;
 	    info->BiosConnector[1].DACType = DAC_PRIMARY;
 	    info->BiosConnector[1].TMDSType = TMDS_EXT;
+	    info->BiosConnector[1].ConnectorType = CONNECTOR_DVI_I;
+	    info->BiosConnector[1].valid = TRUE;
+#else
+	    info->BiosConnector[1].DDCType = DDC_VGA;
+	    info->BiosConnector[1].DACType = DAC_PRIMARY;
+	    info->BiosConnector[1].TMDSType = TMDS_NONE;
 	    info->BiosConnector[1].ConnectorType = CONNECTOR_CRT;
 	    info->BiosConnector[1].valid = TRUE;
+#endif
 	}
     }
 
@@ -2848,6 +2886,7 @@ static void RADEONSetupGenericConnectors(ScrnInfoPtr pScrn)
  * in /proc/cpuinfo (on Linux) */
 static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
 {
+    RADEONInfoPtr info = RADEONPTR(pScrn);
     RADEONMacModel ret = 0;
 #ifdef __linux__
     char cpuline[50];  /* 50 should be sufficient for our purposes */
@@ -2858,23 +2897,52 @@ static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
      * Unforunately, there doesn't seem to be any good way to figure it out.
      */
 
+    /* 
+     * PowerBook5,[1-5]: external tmds, single-link
+     * PowerBook5,[789]: external tmds, dual-link
+     * PowerBook5,6:     external tmds, single-link or dual-link
+     * need to add another option to specify the external tmds chip
+     * or find out what's used and add it.
+     */
+
+
     if (f != NULL) {
 	while (fgets(cpuline, sizeof cpuline, f)) {
 	    if (!strncmp(cpuline, "machine", strlen ("machine"))) {
-		if (strstr(cpuline, "PowerBook5,6") ||
-		    strstr(cpuline, "PowerBook5,7") ||
+		if (strstr(cpuline, "PowerBook5,1") ||
+		    strstr(cpuline, "PowerBook5,2") ||
+		    strstr(cpuline, "PowerBook5,3") ||
+		    strstr(cpuline, "PowerBook5,4") ||
+		    strstr(cpuline, "PowerBook5,5")) {
+		    ret = RADEON_MAC_POWERBOOK_EXTERNAL; /* single link */
+		    info->ext_tmds_chip = RADEON_SIL_164; /* works on 5,2 */
+		    break;
+		}
+
+		if (strstr(cpuline, "PowerBook5,6")) {
+		    ret = RADEON_MAC_POWERBOOK_EXTERNAL; /* dual or single link */
+		    break;
+		}
+
+		if (strstr(cpuline, "PowerBook5,7") ||
 		    strstr(cpuline, "PowerBook5,8") ||
 		    strstr(cpuline, "PowerBook5,9")) {
-		    ret = RADEON_MAC_POWERBOOK_DL;
+		    ret = RADEON_MAC_POWERBOOK_EXTERNAL; /* dual link */
+		    info->ext_tmds_chip = RADEON_SIL_1178; /* guess */
+		    break;
+		}
+
+		if (strstr(cpuline, "PowerBook3,3")) {
+		    ret = RADEON_MAC_POWERBOOK_VGA; /* vga rather than dvi */
 		    break;
 		}
 
 		if (strstr(cpuline, "PowerMac10,1")) {
-		    ret = RADEON_MAC_MINI_INTERNAL;
+		    ret = RADEON_MAC_MINI_INTERNAL; /* internal tmds */
 		    break;
 		}
 		if (strstr(cpuline, "PowerMac10,2")) {
-		    ret = RADEON_MAC_MINI;
+		    ret = RADEON_MAC_MINI_EXTERNAL; /* external tmds */
 		    break;
 		}
 	    } else if (!strncmp(cpuline, "detected as", strlen("detected as"))) {
@@ -2882,7 +2950,7 @@ static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
                     ret = RADEON_MAC_IBOOK;
 		    break;
 		} else if (strstr(cpuline, "PowerBook")) {
-		    ret = RADEON_MAC_POWERBOOK_DL;
+		    ret = RADEON_MAC_POWERBOOK_INTERNAL; /* internal tmds */
 		    break;
                 }
 
@@ -2901,10 +2969,12 @@ static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
 
     if (ret) {
 	xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Detected %s.\n",
-		   ret == RADEON_MAC_POWERBOOK_DL ? "PowerBook with external DVI" :
-		   ret == RADEON_MAC_POWERBOOK ? "PowerBook with integrated DVI" :
+		   ret == RADEON_MAC_POWERBOOK_EXTERNAL ? "PowerBook with external DVI" :
+		   ret == RADEON_MAC_POWERBOOK_INTERNAL ? "PowerBook with integrated DVI" :
+		   ret == RADEON_MAC_POWERBOOK_VGA ? "PowerBook with VGA" :
 		   ret == RADEON_MAC_IBOOK ? "iBook" :
-		   "Mac Mini");
+		   ret == RADEON_MAC_MINI_EXTERNAL ? "Mac Mini with external DVI" :
+		   "Mac Mini with integrated DVI");
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 		   "If this is not correct, try Option \"MacModel\" and "
 		   "consider reporting to the\n");
@@ -2951,14 +3021,22 @@ Bool RADEONSetupConnectors(ScrnInfoPtr pScrn)
     if (optstr) {
 	if (!strncmp("ibook", optstr, strlen("ibook")))
 	    info->MacModel = RADEON_MAC_IBOOK;
-	else if (!strncmp("powerbook-duallink", optstr, strlen("powerbook-duallink")))
-	    info->MacModel = RADEON_MAC_POWERBOOK_DL;
-	else if (!strncmp("powerbook", optstr, strlen("powerbook")))
-	    info->MacModel = RADEON_MAC_POWERBOOK;
+	else if (!strncmp("powerbook-duallink", optstr, strlen("powerbook-duallink"))) /* alias */
+	    info->MacModel = RADEON_MAC_POWERBOOK_EXTERNAL;
+	else if (!strncmp("powerbook-external", optstr, strlen("powerbook-external")))
+	    info->MacModel = RADEON_MAC_POWERBOOK_EXTERNAL;
+	else if (!strncmp("powerbook-internal", optstr, strlen("powerbook-internal")))
+	    info->MacModel = RADEON_MAC_POWERBOOK_INTERNAL;
+	else if (!strncmp("powerbook-vga", optstr, strlen("powerbook-vga")))
+	    info->MacModel = RADEON_MAC_POWERBOOK_VGA;
+	else if (!strncmp("powerbook", optstr, strlen("powerbook"))) /* alias */
+	    info->MacModel = RADEON_MAC_POWERBOOK_INTERNAL;
 	else if (!strncmp("mini-internal", optstr, strlen("mini-internal")))
 	    info->MacModel = RADEON_MAC_MINI_INTERNAL;
-	else if (!strncmp("mini", optstr, strlen("mini")))
-	    info->MacModel = RADEON_MAC_MINI;
+	else if (!strncmp("mini-external", optstr, strlen("mini-external")))
+	    info->MacModel = RADEON_MAC_MINI_EXTERNAL;
+	else if (!strncmp("mini", optstr, strlen("mini"))) /* alias */
+	    info->MacModel = RADEON_MAC_MINI_EXTERNAL;
 	else {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Invalid Mac Model: %s\n", optstr);
 	}

commit 9840a0fd4fc8c980533fcd4a02c55cd0d5634b6d
Author: Alex Deucher <alex@botch2.(none)>
Date:   Thu Nov 29 13:27:37 2007 -0500

    RADEON: add MacModel "mini-internal" for minis with internal TMDS
    
    Some macs (minis and powerbooks) use internal tmds, others use external tmds
    and not just for dual-link TMDS, it shows up with single-link as well.
    Unforunately, there doesn't seem to be any good way to figure it out.

diff --git a/man/radeon.man b/man/radeon.man
index f302ade..8f7b551 100644
--- a/man/radeon.man
+++ b/man/radeon.man
@@ -414,8 +414,10 @@ The default is
 .TP
 .BI "Option \*qMacModel\*q \*q" string \*q
 .br
-Used to specify Mac models for connector tables and quirks.  Only valid
- on PowerPC.
+Used to specify Mac models for connector tables and quirks.  If you have
+a powerbook or mini with DVI that does not work properly, try the alternate
+ options as Apple does not seem to provide a good way of knowing whether
+ they use internal or external TMDS for DVI.  Only valid on PowerPC.
 .br
 ibook                \-\- ibooks
 .br
@@ -423,7 +425,9 @@ powerbook-duallink   \-\- Powerbooks with external DVI
 .br
 powerbook            \-\- Powerbooks with integrated DVI
 .br
-mini                 \-\- Mac Mini
+mini                 \-\- Mac Mini with external DVI
+.br
+mini-internal        \-\- Mac Mini with integrated DVI
 .br
 The default value is
 .B undefined.
diff --git a/src/radeon.h b/src/radeon.h
index 5b91d00..4180752 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -433,7 +433,8 @@ typedef enum {
        RADEON_MAC_IBOOK             = 0x00000001,
        RADEON_MAC_POWERBOOK_DL      = 0x00000002,
        RADEON_MAC_POWERBOOK         = 0x00000004,
-       RADEON_MAC_MINI              = 0x00000008
+       RADEON_MAC_MINI              = 0x00000008,
+       RADEON_MAC_MINI_INTERNAL     = 0x00000016
 } RADEONMacModel;
 #endif
 
diff --git a/src/radeon_output.c b/src/radeon_output.c
index 08c690c..1645b5a 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -2718,6 +2718,19 @@ static Bool RADEONSetupAppleConnectors(ScrnInfoPtr pScrn)
 	info->BiosConnector[1].DDCType = DDC_NONE_DETECTED;
 	info->BiosConnector[1].valid = TRUE;
 	return TRUE;
+    case RADEON_MAC_MINI_INTERNAL:
+	info->BiosConnector[0].DDCType = DDC_CRT2;
+	info->BiosConnector[0].DACType = DAC_TVDAC;
+	info->BiosConnector[0].TMDSType = TMDS_INT;
+	info->BiosConnector[0].ConnectorType = CONNECTOR_DVI_I;
+	info->BiosConnector[0].valid = TRUE;
+
+	info->BiosConnector[1].ConnectorType = CONNECTOR_STV;
+	info->BiosConnector[1].DACType = DAC_TVDAC;
+	info->BiosConnector[1].TMDSType = TMDS_NONE;
+	info->BiosConnector[1].DDCType = DDC_NONE_DETECTED;
+	info->BiosConnector[1].valid = TRUE;
+	return TRUE;
     default:
 	return FALSE;
     }
@@ -2840,6 +2853,11 @@ static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
     char cpuline[50];  /* 50 should be sufficient for our purposes */
     FILE *f = fopen ("/proc/cpuinfo", "r");
 
+    /* Some macs (minis and powerbooks) use internal tmds, others use external tmds
+     * and not just for dual-link TMDS, it shows up with single-link as well.
+     * Unforunately, there doesn't seem to be any good way to figure it out.
+     */
+
     if (f != NULL) {
 	while (fgets(cpuline, sizeof cpuline, f)) {
 	    if (!strncmp(cpuline, "machine", strlen ("machine"))) {
@@ -2851,8 +2869,11 @@ static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
 		    break;
 		}
 
-		if (strstr(cpuline, "PowerMac10,1") ||
-		    strstr(cpuline, "PowerMac10,2")) {
+		if (strstr(cpuline, "PowerMac10,1")) {
+		    ret = RADEON_MAC_MINI_INTERNAL;
+		    break;
+		}
+		if (strstr(cpuline, "PowerMac10,2")) {
 		    ret = RADEON_MAC_MINI;
 		    break;
 		}
@@ -2880,8 +2901,8 @@ static RADEONMacModel RADEONDetectMacModel(ScrnInfoPtr pScrn)
 
     if (ret) {
 	xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Detected %s.\n",
-		   ret == RADEON_MAC_POWERBOOK_DL ? "PowerBook with dual link DVI" :
-		   ret == RADEON_MAC_POWERBOOK ? "PowerBook with single link DVI" :
+		   ret == RADEON_MAC_POWERBOOK_DL ? "PowerBook with external DVI" :
+		   ret == RADEON_MAC_POWERBOOK ? "PowerBook with integrated DVI" :
 		   ret == RADEON_MAC_IBOOK ? "iBook" :
 		   "Mac Mini");
 	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -2934,6 +2955,8 @@ Bool RADEONSetupConnectors(ScrnInfoPtr pScrn)
 	    info->MacModel = RADEON_MAC_POWERBOOK_DL;
 	else if (!strncmp("powerbook", optstr, strlen("powerbook")))
 	    info->MacModel = RADEON_MAC_POWERBOOK;
+	else if (!strncmp("mini-internal", optstr, strlen("mini-internal")))
+	    info->MacModel = RADEON_MAC_MINI_INTERNAL;
 	else if (!strncmp("mini", optstr, strlen("mini")))
 	    info->MacModel = RADEON_MAC_MINI;
 	else {

commit 6f080d00e6f4f84d5e0d6b4eff302bf42c230e81
Author: Arkadiusz Miskiewicz <arekm@maven.pl>
Date:   Mon Nov 26 12:43:30 2007 -0500

    RADEON: fix backlight control on some laptops
    
    It seems the bios scratch regs are involved in backlight control
    on some laptops.  This patch fixes the problematic laptops and doesn't
    seem to break the previous bios lid and output control fixes.

diff --git a/src/radeon_crtc.c b/src/radeon_crtc.c
index de24273..b1d216d 100644
--- a/src/radeon_crtc.c
+++ b/src/radeon_crtc.c
@@ -769,8 +769,8 @@ RADEONInitBIOSRegisters(ScrnInfoPtr pScrn, RADEONSavePtr save)
     RADEONInfoPtr  info      = RADEONPTR(pScrn);
 
     /* tell the bios not to muck with the hardware on events */
-    save->bios_4_scratch = 0;
-    save->bios_5_scratch = 0xff00;
+    save->bios_4_scratch = 0x4; /* 0x4 needed for backlight */
+    save->bios_5_scratch = (info->SavedReg.bios_5_scratch & 0xff) | 0xff00; /* bits 0-3 keep backlight level */
     save->bios_6_scratch = info->SavedReg.bios_6_scratch | 0x40000000;
 
 }
diff --git a/src/radeon_driver.c b/src/radeon_driver.c
index c55b5a5..0465497 100644
--- a/src/radeon_driver.c
+++ b/src/radeon_driver.c
@@ -4041,10 +4041,13 @@ void RADEONRestoreBIOSRegisters(ScrnInfoPtr pScrn, RADEONSavePtr restore)
 {
     RADEONInfoPtr  info       = RADEONPTR(pScrn);
     unsigned char *RADEONMMIO = info->MMIO;
+    CARD32 bios_5_scratch = INREG(RADEON_BIOS_5_SCRATCH);
     CARD32 bios_6_scratch = INREG(RADEON_BIOS_6_SCRATCH);
 
     OUTREG(RADEON_BIOS_4_SCRATCH, restore->bios_4_scratch);
-    OUTREG(RADEON_BIOS_5_SCRATCH, restore->bios_5_scratch);
+    bios_5_scratch &= 0xF;
+    bios_5_scratch |= (restore->bios_5_scratch & ~0xF);
+    OUTREG(RADEON_BIOS_5_SCRATCH, bios_5_scratch);
     if (restore->bios_6_scratch & 0x40000000)
 	bios_6_scratch |= 0x40000000;
     else

commit dcf22aed87366f4625fb5042cb84fecccd9ceece
Author: Alex Deucher <alex@botch2.(none)>
Date:   Mon Nov 26 11:10:03 2007 -0500

    RADEON: only return status unknown for XPRESS chips
    
    this seems to cause more issues than it attempted to fix
    so limit it to XPRESS chips for now.

diff --git a/src/radeon_output.c b/src/radeon_output.c
index 54c27cd..08c690c 100644
--- a/src/radeon_output.c
+++ b/src/radeon_output.c
@@ -1672,11 +1672,13 @@ radeon_detect(xf86OutputPtr output)
 	  /* default to unknown for flaky chips/connectors
 	   * so we can get something on the screen
 	   */
-	  if (((radeon_output->type == OUTPUT_VGA || radeon_output->type == OUTPUT_DVI) &&
-	       radeon_output->DACType == DAC_TVDAC)) {
+	  if ((radeon_output->type == OUTPUT_VGA || radeon_output->type == OUTPUT_DVI) &&
+	      (radeon_output->DACType == DAC_TVDAC) &&
+	      (info->ChipFamily == CHIP_FAMILY_RS400)) {
 	      radeon_output->MonType = MT_CRT;
 	      return XF86OutputStatusUnknown;
-	  } else if  (info->IsIGP && radeon_output->type == OUTPUT_DVI) {
+	  } else if  ((info->ChipFamily == CHIP_FAMILY_RS400) &&
+		      radeon_output->type == OUTPUT_DVI) {



Reply to: