Mobility Radeon HD 4650: Full Resolution with QE & CI [ 10.6.x ]



CODE
http://www.megaupload.com/?d=4SN7VDMK

CODE
http://hotfile.com/dl/113477176/da80b51/ATI.zip.html


Updates:

1- the same method is tested in Mac OS X version 10.6.3 & the lastest update 10.6.7 and i report it's working perfectly for both

2- for the 10.6.3 system the personnality is 20 bytes (the SenseID byte is replaced by i2cid & SenseID is 4 bytes);

a-the original 10.6.3 Shrike ConnectorInfo:

CODE
02 00 00 00 40 00 00 00 09 00 00 00 02 01 00 00 03 00 00 00
02 00 00 00 00 01 00 00 09 01 00 00 20 01 02 91 02 00 00 00
00 04 00 00 04 03 00 00 00 01 00 00 10 00 01 90 01 00 00 00


b-My modded working 10.6.3 Shrike ConnectorInfo :

CODE
02 00 00 00 40 00 00 00 09 00 00 00 12 00 00 96 07 00 00 00
10 00 00 00 10 00 00 00 00 01 00 00 00 10 01 95 06 00 00 00
00 08 00 00 00 02 00 00 00 01 00 00 20 01 02 90 01 00 00 00


3- About the 10.6.7 Update:

a-ConnectorInfo are located in ATIFramebuffer.kext for the general combo update (the same as 10.6.6 system)
b-ConnectorInfo have migrated to ATIControlerXXXX.kext for 2011 MBP update (the kernel & ATi Drivers structure are closer to Lion 10.7 than to 10.6.6),
ATIController4600.kext contain only Shrike, Flicker & Gliff ConnectorInfo (which theorically restrict the possible framebuffer to use with a specific controller.kext)
ATIController4800.kext contain only Cardinal,Motmot & Quail ConnectorInfo.

The Online guide:

A- The Structure of a personality:

I'll take Shrike as framebuffer for the demonstration, cause it's used as default by Radeon HD 4670 (M96XT, DevID 0x9488 ) on iMac 10,1 & iMac11,2 
which is the closest to the Mobility Radeon HD 4650 (M96, DevID 0x9480) on my board.

for Shrike we have by default 3 personalities , one for each connector (3 connectors allowed): port0, port1, port2.

02 00 00 00 40 00 00 00 09 01 00 00 02 01 00 03
02 00 00 00 00 01 00 00 09 01 00 00 20 01 02 02
00 04 00 00 04 03 00 00 00 01 00 00 10 00 01 01

let's take the first one which is for port 0 : 

02 00 00 00 40 00 00 00 09 01 00 00 02 01 00 03

divide it to 8 parts:

02 00 00 00 - 40 00 00 00 - 09 01 - 00 00 - 02 - 01 - 00 - 03

Then byte swapped

1- ConnectorType : 02 00 00 00 > 0x00000002 - - -
2- ATY,ControlFlags : 40 00 00 00 > 0x00000040 +++
3- Features : 09 01 > 0x0109 +++
4- Unkown : 00 00 > 0x0000 - - - 
5- Transmitter : 02 > 0x02 - - - 
6- Encoder : 01 > 0x01 - - -
7- HotplugID : 00 > 0x00 - - -
8- SenseID : 03 > 0x03 ++++++

- - - > Value not important, but need to be accurate for better result
+++ > Important value, incorrect value == not working personality

Detailed info about possible value for each field is list below ( some are confirmed, some only guessed by studying different personalities and need some feed-back
from working system (for me LVDS and VGA value are confirmed)

1- ConnectorType;

CODE
/* 4 byte  ,from bbc9 radeondump */
         #define CONNECTORTYPE_LVDS   0x00000002 
         #define CONNECTORTYPE_DVI      0x00000004
        #define CONNECTORTYPE_VGA      0x00000010
        #define CONNECTORTYPE_S-V      0x00000080     
        #define CONNECTORTYPE_DP      0x00000400 
         #define CONNECTORTYPE_HDMI   0x00000800


2- ATY,ControlFlags;

CODE
/* 4 byte the same as found on ioreg key: ATY,ControlFlags. hardcoded for each connector type
    u can try one by one until u find the working one for u
    0x0002 : LVDS        >    ControlFlag : 0x0040 / 0x0100
    0x0004 : DVI-?        >    ControlFlag : 0x0016 - 0x0014 / 0x214
    0x0010 : VGA        >    ControlFlag : 0x0010
    0x0080 : S-Video       >    ControlFlag : 0x0002   
    0x0200 : DVI-?        >    ControlFlag : 0x0014 / 0x0214 - 0x0204
    0x0400 : DisplayPort    >    ControlFlag : 0x0100 - 0x0104 - 0x0304 / 0x0604 - 0x0400
    0x0800 : HDMI        >    ControlFlag : 0x0200
    0x1000 : DVI-?        >    ControlFlag : 0x0016
    */


3-Features;

CODE
/* Features byte 0 , for example for LVDS screen it's almost 0x09 = 0x01 + 0x08 > Internal + Backlight */
    #define FEATURE_USE_INTERNAL               0x01
    #define FEATURE_USE_RGB_ON_YUV        0x04
    #define FEATURE_USE_BACKLIGHT          0x08
    #define FEATURE_BACKLIGHT_INVERTED     0x10
    #define FEATURE_USE_CLAMSHELL          0x20

    /* 1 byte, hardcoded for each connector type
    0x0002 : LVDS        >    Features  :  0x09
    0x0004 : DVI-?        >    Features  :  0x00
    0x0010 : VGA        >    Features  :  0x00
    0x0080 : S-Video       >    Features  :  0x04  
    0x0200 : DVI-?        >    Features  :  0x00
    0x0400 : DisplayPort    >    Features  :  0x00
    0x0800 : HDMI        >    Features  :  0x00
    0x1000 : DVI-?        >    Features  :  0x00
    */

    /* Features byte 1 , no idea ???*/


4- Unkown ;

5- Transmitter

CODE
/* u can get this from dmesg after installing  Dong's RadeonHD with debug info */
    /* Transmitter Bits 0-3 (TransmitterID) */
    #define UNIPHY      0x00
    #define UNIPHY1   0x01
    #define UNIPHY2   0x02

    /* Transmitter Bits 4-7 (LinkID) */
    #define DUALLINK  0x00 // LINKA + LINKB
    #define LINKA          0x10
    #define LINKB          0x20

    /* Transmitter byte  */
    #define UNIPHYA     0x10 // = UNIPHY:LINKA
    #define UNIPHYB     0x20 // = UNIPHY:LINKB
    #define UNIPHYAB   0x00 // = UNIPHY:DUALLINK
    #define UNIPHYC     0x11 // = UNIPHY1:LINKA
    #define UNIPHYD     0x21 // = UNIPHY1:LINKB
    #define UNIPHYCD   0x01 // = UNIPHY1:DUALLINK
    #define UNIPHYE     0x12 // = UNIPHY2:LINKA
    #define UNIPHYF      0x22 // = UNIPHY2:LINKB
    #define UNIPHYEF    0x02 // = UNIPHY2:DUALLINK
    #define DACA              0x00
    #define DACB          0x10



6- Encoder; 

CODE
/* u can get this from Dmesg as above  for R8XX architecture and above there is 06 Digital Encoder: DIG_1 > DIG_6*/
    /* Encoder Bits 0-3 (DIG_ID : Digital) */
    #define DIG1   0x00 // = DIGA
    #define DIG2   0x01 // = DIGB
    #define DIG3   0x02 // = DIGC  Only for Radeon HD 5XXX Series  and above
    #define DIG4   0x03 // = DIGD  Only for Radeon HD 5XXX Series  and above
    #define DIG5   0x04 // = DIGE  Only for Radeon HD 5XXX Series  and above
    #define DIG6   0x05 // = DIGF  Only for Radeon HD 5XXX Series  and above

    /* Encoder Bits 4-7 (DAC_ID : Analog) */
    #define DAC     0x10


7- HotplugID; 

CODE
/* 4 bits it's a unique id for each port, i have tried with 0 for port0, 1 for port1 and 2 for port2 and it's just working */


8- SenseID;

CODE
/* SenseLine = (i2cid & 0xf) +1 ,you get  i2cid from bbc9 radeondump */
     Bits 0-3: Sense Line
     Bit    4: Use hw i2c flag


Now to some practice


B- Getting the ConnectorType, ATY,ControlFlags,Features, HotplugId and SenseLineId Values:


You will need : 
1- videocard bios dump ( i have used everest for that and renamed it 1002_9480.rom ) , 
2- radeondump tool from bbc9
launch Terminal & type ./radeondump < your_videobios.rom > connector.txt
you will get something like this :

CODE
    Desktop Mucha$ ./radeondump < 1002_9480.rom
ATOM BIOS Rom:
    SubsystemVendorID: 0x103c SubsystemID: 0x3629
    IOBaseAddress: 0x7000
    Filename: br33507.001
    BIOS Bootup Message:
HP_Quanta_Jones_Cujo_M96M_DDR3 M96 DDR3 128bit 550e/667m                 

Connector at index 0 type: LVDS (7)
Connector's i2cid: 96
Connector at index 1 type: VGA (1)
Connector's i2cid: 95
Connector at index 2 type: HDMI-A (11)
Connector's i2cid: 90



which means:

port0 > LVDS=0x00000002 - ControlFlag=0x0040 - Features = 0x09-------------------------HotplugId=0x00 - i2cid=96 > SenseLine = 0x07
port1 > VGA =0x00000010 - ControlFlag=0x0010 - Features = 0x00 ------------------------ HotplugId=0x01 - i2cid=95 > SenseLine = 0x06
port2 > HDMI=0x00000800 - ControlFlag=0x0200 - Features = 0x00 -------------------------HotplugId=0x02 - i2cid=90 > SenseLine = 0x01


C- Getting the Encoder & Transmitter ID Values:


For some useful info you may visit : "http://www.botchco.com/agd5f/?p=51"
and some Encoder-Transmitter Routing rules taking from commentary of linux drivers 
"http://lxr.free-electrons.com/source/drivers/gpu/drm/radeon/radeon_encoders.c"

CODE
682 /*
683  * DIG Encoder/Transmitter Setup
684  *
685  * DCE 3.0/3.1 (RV6XX, Radeon HD 3XXX Series and older)
686  * - 2 DIG transmitter blocks. UNIPHY (links A and B ) and LVTMA.
687  * Supports up to 3 digital outputs
688  * - 2 DIG encoder blocks.
689  * DIG1 can drive UNIPHY link A or link B
690  * DIG2 can drive UNIPHY link B or LVTMA
691  *
692  * DCE 3.2 (RV7XX, Radeon HD 4XXX Series)
693  * - 3 DIG transmitter blocks. UNIPHY0/1/2 (links A and B ).
694  * Supports up to 5 digital outputs
695  * - 2 DIG encoder blocks.
696  * DIG1/2 can drive UNIPHY0/1/2 link A or link B
697  *
698  * DCE 4.0 (RV8XX, Radeon HD 5XXX Series)
699  * - 3 DIG transmitter blocks UNPHY0/1/2 (links A and B ).
700  * Supports up to 6 digital outputs
701  * - 6 DIG encoder blocks.
702  * - DIG to PHY mapping is hardcoded
703  * DIG1 drives UNIPHY0 link A, A+B
704  * DIG2 drives UNIPHY0 link B
705  * DIG3 drives UNIPHY1 link A, A+B
706  * DIG4 drives UNIPHY1 link B
707  * DIG5 drives UNIPHY2 link A, A+B
708  * DIG6 drives UNIPHY2 link B
709  *
710  * Routing
711  * crtc -> dig encoder -> UNIPHY/LVTMA (1 or 2 links)
712  * Examples:
713  * crtc0 -> dig2 -> LVTMA   links A+B -> TMDS/HDMI
714  * crtc1 -> dig1 -> UNIPHY0 link  B   -> DP
715  * crtc0 -> dig1 -> UNIPHY2 link  A   -> LVDS
716  * crtc1 -> dig2 -> UNIPHY1 link  B+A -> TMDS/HDMI
717  */



You need Dong's RadeonHD.kext , i have used the 10/20/2009 update, edit the info.plist to set the debug to true and verbose level to 2 
then delete ATI4600 & ATIFramebuffer from S/L/E (make a back-up first) and install radeonHD reboot (your external VGA,DVI or HDMI screen most be connected)
once on desktop go to Terminal : sudo -s , type your password then dmesg >Encoder.txt 
In my case i get as output:
----------------------------------------------------------------------------
CailWriteATIRegister(1724,40002)
CAIL: CailReleaseMemory
ParseTable said: CD_SUCCESS
Call to AtomBIOS Exec succeeded
DAC_LoadDetection Successful
rhdAtomBIOSScratchDACSenseResults
BIOSScratch_0: 0x40002
rhdAtomBIOSScratchDACSenseResults sensed RHD_SENSED_VGA
AtomOutputvalueDACA: Sensed Output: VGA
atomTMDSPropertyControl
atomTMDSPropertyControl
Setting AtomOutputvalueDACA to incoherent
atomTMDSPropertyControl
RHDConnectorEnableHDMI
atomTMDSPropertyControl
RHDHPDCheck
RHDHPDCheck returned: 0 mask: 1
RHDMonitorInit
rhdMonitorPanel
RHDAtomBiosFunc
rhdAtomLvdsGetTimings
rhdAtomLvdsTimings
rhdAtomLvdsTimings: LVDS Modeline: 1366x768 72000 1366 (1366) 1414 1446 (1486) 1486 768 (768) 771 775 (806) 806
Call to AtomBIOS Get Panel Mode succeeded
RHDAtomBiosFunc
rhdAtomLvdsGetTimings
rhdAtomLvdsDDC
rhdAtomLvdsDDC: unknown record type: 24
Query for AtomBIOS Get Panel EDID: failed
RHDAtomOutputAllocFree
Mapping DIG1 encoder to KLDSKP_UNIPHYE
Crtc[0]: found native mode from Monitor[LVDS Panel]: 
Modeline "1366x768" 72 1366 1414 1446 1486 768 771 775 806
Connector "PANEL" uses Monitor "LVDS Panel":
RHDMonitorInit
Connector "VGA 1": Failed to retrieve Monitor information.
RHDValidateScaledToMode
rhdModeValidateCrtc
DxModeValid: ATOM CRTC 1
rhdAtomOutputModeValid
Listing modesetting layout:
ATOM CRTC 1: tied to Atom PLL 1 and LUT A:
Outputs: AtomOutputduleDemandUniphyE (PANEL)
ATOM CRTC 2: tied to Atom PLL 2 and LUT B:
Outputs: AtomOutputvalueDACA (VGA 1)
Unused Outputs: AtomOutputUniphyB
RHDModesPoolCreate
-------------------------------------------------------------------------------------

Based upon the above information my SPECIFIC videocard routing is:

CRTC0>DIG1>UNIPHYE>LVDS Encoder= 0x00 Transmitter = 0x12
CRTC1>DAC > DACA >VGA Encoder=0x10 Transmitter = 0x00
CRTC1>DIG2>UNIPHYB>HDMI Encoder= 0x01 Transmitter = 0x20 (i don't have a hdmi display to test) 

Now doing the compilation , my new modded Shrike personalities :

02 00 00 00 40 00 00 00 09 01 00 00 12 00 00 07 LVDS
10 00 00 00 10 00 00 00 00 01 00 00 00 10 01 06 VGA
00 08 00 00 00 02 00 00 00 01 00 00 20 01 02 01 HDMI

This mod allowed me to get both LVDS an VGA display working with Resolution change, QE/CI Extended desktop and Mirroring 
I have tested the same mod with Peregrine and i confirm it's also Working.


D- How to Easy Quick Patch your desired Framebuffer personality (without calculating the adresses and for both i386 and x86_64):


You should have a hexadecimal editor:

1- Download the attached : Sharks_FB.txt Birds_FB.txt and Monkeys_FB.txt,
2- Open the text file select and copy the desired personality hexadecimal code (the one you want to patch),
3- Open ATIFramebuffer.kext and Drag ATIFramebuffer binary to hexadecimal editor,
4- Select : edit>search , in the search fields paste the clipboard content and choose hex value & wrap option,
5- You should find 2 instances of the searched personality: the first one is for x86_64 and the second for i386 (make sure you have only 2),
6- Patch and save your binary, install reboot an ENJOY

For Radeon HD 3XXX and prior choose Sharks,
For Radeon HD 4XXX choose Birds,
For Radeon HD 5XXX choose Monkeys. 
Attached File(s)
Attached File  Screen_shot_2011_03_14_at_7.06.14_PM.png ( 733.19K ) Number of downloads: 1362
Attached File  Screen_shot_2011_03_14_at_6.55.58_PM.png ( 449.61K ) Number of downloads: 1064
Attached File  Screen_shot_2011_03_14_at_7.03.58_PM.png ( 445.64K ) Number of downloads: 779
Attached File  Screen_shot_2011_03_14_at_6.55.13_PM.png ( 463.04K ) Number of downloads: 731
Attached File  Screen_shot_2011_03_14_at_6.52.52_PM.png ( 303.62K ) Number of downloads: 695
Attached File  HowTo.rtf ( 19.29K ) Number of downloads: 1255
Attached File  Sharks_FB.rtf ( 1.33K ) Number of downloads: 507
Attached File  Birds_FB.rtf ( 1.73K ) Number of downloads: 1339
Attached File  Monkeys_FB.rtf ( 2.72K ) Number of downloads: 743
Attached File  ATI_10.6.3.zip ( 696.35K ) Number of downloads: 380
Attached File  ATI_10.6.6.zip ( 709.01K ) Number of downloads: 442
Attached File  ATI_10.6.7.zip ( 707.08K ) Number of downloads: 801
Attached File  boot_Mobility4650_Shrike.zip ( 102.37K ) Number of downloads: 737

Many thanks to bcc9