Mailinglist Archive: radeonhd (333 mails)

< Previous Next >
[radeonhd] Re: [patch] preliminary R5xx PowerPlay support
  • From: Yang Zhao <yang@xxxxxxxxxx>
  • Date: Wed, 08 Oct 2008 08:16:50 -0700
  • Message-id: <48ECCEE2.7090604@xxxxxxxxxx>
Yang Zhao wrote:
Attached is a patch giving preliminary support for PowerPlay on r5xx
chips.


And here it is again, this time with commit history.

If you are having issues with X locking up before dumping any PowerPlay
information, try commenting out the 3 lines in rhdInitPowerManagement_r5xx()
from rhd_powerplay.c below the "Enable dynamic clock gating" comment.


Yang
From 2c71bd241b10dc6b14d20d2fb34fa8fd834cd21e Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Fri, 15 Aug 2008 15:47:50 -0700
Subject: [PATCH] Port PowerPlay table dumping code from radeon

Functions were modified to output messages via xf86DrvMsg and
reorganized to better fit radeonhd structure.
---
src/rhd_atombios.c | 315 +++++++++++++++++++++++++++++++++++++++++++++++++++-
src/rhd_atombios.h | 1 +
src/rhd_driver.c | 16 +++
3 files changed, 330 insertions(+), 2 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 9e9ad96..92c9868 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -126,6 +126,8 @@ atomSetRegisterListLocation(atomBiosHandlePtr handle,
AtomBiosRequestID func, At
static AtomBiosResult
atomRestoreRegisters(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);

+static AtomBiosResult
+rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);

enum msgDataFormat {
MSG_FORMAT_NONE,
@@ -270,6 +272,8 @@ struct atomBIOSRequests {
"Register List Location", MSG_FORMAT_NONE},
{ATOM_RESTORE_REGISTERS, atomRestoreRegisters,
"Restore Registers", MSG_FORMAT_NONE},
+ {ATOM_POWERPLAY_MODES, rhdAtomPowerPlayInfoQuery,
+ "PowerPlay Modes", MSG_FORMAT_NONE},
{FUNC_END, NULL,
NULL, MSG_FORMAT_NONE}
};
@@ -325,7 +329,12 @@ typedef struct _atomDataTables
ATOM_COMPONENT_VIDEO_INFO *ComponentVideoInfo;
ATOM_COMPONENT_VIDEO_INFO_V21 *ComponentVideoInfo_v21;
} ComponentVideoInfo;
-/**/unsigned char *PowerPlayInfo;
+ union {
+ void *base;
+ ATOM_POWERPLAY_INFO *PowerPlayInfo;
+ ATOM_POWERPLAY_INFO_V2 *PowerPlayInfo_v2;
+ ATOM_POWERPLAY_INFO_V3 *PowerPlayInfo_v3;
+ } PowerPlayInfo;
COMPASSIONATE_DATA *CompassionateData;
ATOM_DISPLAY_DEVICE_PRIORITY_INFO *SaveRestoreInfo;
/**/unsigned char *PPLL_SS_Info;
@@ -546,7 +555,7 @@ rhdAtomAnalyzeMasterDataTable(unsigned char *base,
SET_DATA_TABLE(GPIO_Pin_LUT);
SET_DATA_TABLE(VESA_ToInternalModeLUT);
SET_DATA_TABLE_VERS(ComponentVideoInfo);
- SET_DATA_TABLE(PowerPlayInfo);
+ SET_DATA_TABLE_VERS(PowerPlayInfo);
SET_DATA_TABLE(CompassionateData);
SET_DATA_TABLE(SaveRestoreInfo);
SET_DATA_TABLE(PPLL_SS_Info);
@@ -5021,6 +5030,308 @@ atomSaveRegisters(atomBiosHandlePtr handle, enum
atomRegisterType Type, CARD32 a
List->Last++;
}

+
+static char *
+rhdAtomPowerPlayTypeName(unsigned long miscInfo)
+{
+ switch ((miscInfo & ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK) >>
ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT) {
+
+ case 1: return "Optimal Battery Life";
+ case 2: return "High Battery";
+ case 3: return "Balanced";
+ case 4: return "High Performance";
+ case 5: return "Optimal Performance";
+ default: return "Unknown";
+ }
+}
+
+static void
+rhdDumpAtomPowerMisc1(int scrnIndex, unsigned long MiscInfo)
+{
+ ErrorF("\tPM mode attributes:\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_USING_MCLK_SRC)
+ ErrorF("\tATOM_PM_MISCINFO_USING_MCLK_SRC\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_USING_SCLK_SRC)
+ ErrorF("\tATOM_PM_MISCINFO_USING_SCLK_SRC\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT)
+ ErrorF("\tATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
+ ErrorF("\tATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN)
+ ErrorF("\tATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN)
+ ErrorF("\tATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN)
+ ErrorF("\tATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE)
+ ErrorF("\tucVoltageDropIndex is not an index for GPIO pin, but a
voltage ID that SW needs program\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN)
+ ErrorF("\tATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN)
+ ErrorF("\tATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)
+ ErrorF("\tATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
+ ErrorF("\tATOM_PM_MISCINFO_LOAD_BALANCE_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
+ ErrorF("\tATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)
+ ErrorF("\tATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE)
+ ErrorF("\tATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE)
+ ErrorF("\tATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_OVER_CLOCK_MODE)
+ ErrorF("\tATOM_PM_MISCINFO_OVER_CLOCK_MODE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_OVER_DRIVE_MODE)
+ ErrorF("\tATOM_PM_MISCINFO_OVER_DRIVE_MODE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
+ ErrorF("\tATOM_PM_MISCINFO_POWER_SAVING_MODE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_THERMAL_DIODE_MODE)
+ ErrorF("\tATOM_PM_MISCINFO_THERMAL_DIODE_MODE\n");
+ if (((MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK) >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) == 0)
+ ErrorF("\tFM Disable\n");
+ else if (((MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK) >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) == 1)
+ ErrorF("\t2 level FM\n");
+ else if (((MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK) >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) == 2)
+ ErrorF("\t4 level FM\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DYN_CLK_3D_IDLE)
+ ErrorF("\tATOM_PM_MISCINFO_DYN_CLK_3D_IDLE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2)
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4)
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN)
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN)
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
+ ErrorF("\tATOM_PM_MISCINFO_3D_ACCELERATION_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO_ENABLE_BACK_BIAS)
+ ErrorF("\tATOM_PM_MISCINFO_ENABLE_BACK_BIAS\n");
+}
+
+static void
+rhdDumpAtomPowerMisc2(int scrnIndex, unsigned long MiscInfo)
+{
+ if (MiscInfo & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE)
+ ErrorF("\tATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT)
+ ErrorF("\tATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN)
+ ErrorF("\tATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO)
+ ErrorF("\tATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE)
+ ErrorF("\tATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN)
+ ErrorF("\tATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE)
+ ErrorF("\tATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_NOT_VALID_ON_DC)
+ ErrorF("\tATOM_PM_MISCINFO2_NOT_VALID_ON_DC\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_STUTTER_MODE_EN)
+ ErrorF("\tATOM_PM_MISCINFO2_STUTTER_MODE_EN\n");
+}
+
+static void
+dumpAtomPowerV1Mode(int scrnIndex, ATOM_POWERMODE_INFO *info, int i)
+{
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "PowerPlay mode %d (%s)\n\tengine:%d memory:%d\n"
+ "\tVoltage GPIO entry:%d Panel Refresh:%d temp range:%d-%d pcie
lanes:%d\n",
+ i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
+ info->usEngineClock, info->usMemoryClock,
+ info->ucVoltageDropIndex,
+ info->ucSelectedPanel_RefreshRate,
+ info->ucMinTemperature, info->ucMaxTemperature,
+ info->ucNumPciELanes);
+ rhdDumpAtomPowerMisc1(scrnIndex, info->ulMiscInfo);
+}
+
+static void
+dumpAtomPowerV2Mode(int scrnIndex, ATOM_POWERMODE_INFO_V2 *info, int i)
+{
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Powerplay %d (%s)\n\tengine:%d memory:%d\n"
+ "\tVoltage GPIO entry:%d Panel Refresh:%d temp range:%d-%d pcie
lanes:%d\n",
+ i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
+ info->ulEngineClock, info->ulMemoryClock,
+ info->ucVoltageDropIndex,
+ info->ucSelectedPanel_RefreshRate,
+ info->ucMinTemperature, info->ucMaxTemperature,
+ info->ucNumPciELanes);
+ rhdDumpAtomPowerMisc1(scrnIndex, info->ulMiscInfo);
+ rhdDumpAtomPowerMisc2(scrnIndex, info->ulMiscInfo2);
+}
+
+static void
+dumpAtomPowerV3Mode(int scrnIndex, ATOM_POWERMODE_INFO_V3 *info, int i)
+{
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Powerplay %d (%s)\n\tengine:%d memory:%d\n"
+ "\tIndex to core VDCC voltage table:%d Index to VDDCI voltage table:
%d\n"
+ "Panel Refresh:%d temp range:%d-%d pcie lanes:%d\n",
+ i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
+ info->ulEngineClock, info->ulMemoryClock,
+ info->ucVoltageDropIndex, info->ucVDDCI_VoltageDropIndex,
+ info->ucSelectedPanel_RefreshRate,
+ info->ucMinTemperature, info->ucMaxTemperature,
+ info->ucNumPciELanes);
+ rhdDumpAtomPowerMisc1(scrnIndex, info->ulMiscInfo);
+ rhdDumpAtomPowerMisc2(scrnIndex, info->ulMiscInfo2);
+}
+
+static AtomBiosResult
+rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID func,
+ AtomBiosArgPtr data)
+{
+ atomDataTablesPtr atomDataPtr;
+ CARD8 crev, frev;
+ int i;
+
+ RHDFUNC(handle);
+
+ atomDataPtr = handle->atomDataPtr;
+
+ if (!rhdAtomGetTableRevisionAndSize(
+ (ATOM_COMMON_TABLE_HEADER *)(atomDataPtr->PowerPlayInfo.base),
+ &crev,&frev,NULL)) {
+ return ATOM_FAILED;
+ }
+
+ int table_version = 0;
+ switch (frev) {
+ case 1:
+ switch (crev) {
+ case 1:
+ table_version = 1;
+ break;
+ }
+ break;
+
+ case 2:
+ switch (crev) {
+ case 1:
+ table_version = 2;
+ break;
+ case 2:
+ table_version = 3;
+ break;
+ }
+ break;
+ }
+
+ if (table_version > 0 && table_version <= 3)
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "PowerPlay table version %d\n",
table_version);
+ else {
+ xf86DrvMsg(handle->scrnIndex, X_ERROR, "Unknown PowerPlay table
version; format: %d content %d\n",
+ frev, crev);
+ return ATOM_FAILED;
+ }
+
+ /* All 3 known table versions share a common header section */
+ UCHAR odController;
+ UCHAR odI2c;
+ UCHAR odIntBitmap;
+ UCHAR odAddr;
+ UCHAR numEntries;
+
+ switch (table_version) {
+ case 1:
+ odController =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->ucOverdriveThermalController;
+ odI2c = atomDataPtr->PowerPlayInfo.PowerPlayInfo->ucOverdriveI2cLine;
+ odIntBitmap =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->ucOverdriveIntBitmap;
+ odAddr =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->ucOverdriveControllerAddress;
+ numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->ucNumOfPowerModeEntries;
+ break;
+ case 2:
+ odController =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->ucOverdriveThermalController;
+ odI2c =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->ucOverdriveI2cLine;
+ odIntBitmap =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->ucOverdriveIntBitmap;
+ odAddr =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->ucOverdriveControllerAddress;
+ numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->ucNumOfPowerModeEntries;
+ break;
+ case 3:
+ odController =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucOverdriveThermalController;
+ odI2c =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucOverdriveI2cLine;
+ odIntBitmap =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucOverdriveIntBitmap;
+ odAddr =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucOverdriveControllerAddress;
+ numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucNumOfPowerModeEntries;
+ break;
+ }
+
+ switch (odController) {
+ case 0:
+ default:
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "No thermal controller\n");
+ break;
+ case ATOM_PP_OVERDRIVE_THERMALCONTROLLER_LM63:
+ xf86DrvMsg(handle->scrnIndex, X_INFO,
+ "LM63 thermal controller at 0x%x, GPIO entry %d, Interrupt
Bitmap 0x%x\n",
+ odAddr, odI2c, odIntBitmap);
+ break;
+ case ATOM_PP_OVERDRIVE_THERMALCONTROLLER_ADM1032:
+ xf86DrvMsg(handle->scrnIndex, X_INFO,
+ "ADM1032 thermal controller at 0x%x, GPIO entry %d,
Interrupt Bitmap 0x%x\n",
+ odAddr, odI2c, odIntBitmap);
+ break;
+ case ATOM_PP_OVERDRIVE_THERMALCONTROLLER_ADM1030:
+ xf86DrvMsg(handle->scrnIndex, X_INFO,
+ "ADM1030 thermal controller at 0x%x, GPIO entry %d,
Interrupt Bitmap 0x%x\n",
+ odAddr, odI2c, odIntBitmap);
+ break;
+ case ATOM_PP_OVERDRIVE_THERMALCONTROLLER_MUA6649:
+ xf86DrvMsg(handle->scrnIndex, X_INFO,
+ "MUA6649 thermal controller at 0x%x, GPIO entry %d,
Interrupt Bitmap 0x%x\n",
+ odAddr, odI2c, odIntBitmap);
+ break;
+ case ATOM_PP_OVERDRIVE_THERMALCONTROLLER_LM64:
+ xf86DrvMsg(handle->scrnIndex, X_INFO,
+ "LM64 thermal controller at 0x%x, GPIO entry %d, Interrupt
Bitmap 0x%x\n",
+ odAddr, odI2c, odIntBitmap);
+ break;
+ case ATOM_PP_OVERDRIVE_THERMALCONTROLLER_F75375:
+ xf86DrvMsg(handle->scrnIndex, X_INFO,
+ "F75375 thermal controller at 0x%x, GPIO entry %d,
Interrupt Bitmap 0x%x\n",
+ odAddr, odI2c, odIntBitmap);
+ break;
+ case ATOM_PP_OVERDRIVE_THERMALCONTROLLER_ASC7512:
+ xf86DrvMsg(handle->scrnIndex, X_INFO,
+ "ASC7512 thermal controller at 0x%x, GPIO entry %d,
Interrupt Bitmap 0x%x\n",
+ odAddr, odI2c, odIntBitmap);
+ break;
+ }
+
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "%d avilable power modes:\n",
numEntries);
+
+ switch (table_version) {
+ case 1:
+ for (i = 0; i < numEntries; i++) {
+ dumpAtomPowerV1Mode(handle->scrnIndex,
+
&atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i],
+ i);
+ }
+ break;
+ case 2:
+ for (i = 0; i < numEntries; i++) {
+ dumpAtomPowerV2Mode(handle->scrnIndex,
+
&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i],
+ i);
+ }
+ break;
+ case 3:
+ for (i = 0; i < numEntries; i++) {
+ dumpAtomPowerV3Mode(handle->scrnIndex,
+
&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i],
+ i);
+ }
+ break;
+ }
+
+ return ATOM_SUCCESS;
+}
+
/*
*
*/
diff --git a/src/rhd_atombios.h b/src/rhd_atombios.h
index e841433..4ec778f 100644
--- a/src/rhd_atombios.h
+++ b/src/rhd_atombios.h
@@ -94,6 +94,7 @@ typedef enum _AtomBiosRequestID {
ATOM_GET_PCIE_LANES,
ATOM_SET_REGISTER_LIST_LOCATION,
ATOM_RESTORE_REGISTERS,
+ ATOM_POWERPLAY_MODES,
FUNC_END
} AtomBiosRequestID;

diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index de1fa9e..b293db8 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -740,6 +740,22 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)
}
#endif

+#ifdef ATOM_BIOS
+ if (rhdPtr->atomBIOS) {
+ AtomBiosArgRec atomBiosArg;
+
+ if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_POWERPLAY_MODES, &atomBiosArg)
+ == ATOM_SUCCESS) {
+ }
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
+ }
+#else
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
+#endif
+
#ifdef USE_DRI
RHDDRIPreInit(pScrn);
#else
--
1.5.6.4

From e3574260206d19cb9ed51f6ba2a1f81e44ed1e81 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Fri, 15 Aug 2008 16:08:19 -0700
Subject: [PATCH] Clean up PowerPlay log

---
src/rhd_atombios.c | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 92c9868..17dbf6a 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5035,7 +5035,6 @@ static char *
rhdAtomPowerPlayTypeName(unsigned long miscInfo)
{
switch ((miscInfo & ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK) >>
ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT) {
-
case 1: return "Optimal Battery Life";
case 2: return "High Battery";
case 3: return "Balanced";
@@ -5048,7 +5047,6 @@ rhdAtomPowerPlayTypeName(unsigned long miscInfo)
static void
rhdDumpAtomPowerMisc1(int scrnIndex, unsigned long MiscInfo)
{
- ErrorF("\tPM mode attributes:\n");
if (MiscInfo & ATOM_PM_MISCINFO_USING_MCLK_SRC)
ErrorF("\tATOM_PM_MISCINFO_USING_MCLK_SRC\n");
if (MiscInfo & ATOM_PM_MISCINFO_USING_SCLK_SRC)
@@ -5089,12 +5087,13 @@ rhdDumpAtomPowerMisc1(int scrnIndex, unsigned long
MiscInfo)
ErrorF("\tATOM_PM_MISCINFO_POWER_SAVING_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_THERMAL_DIODE_MODE)
ErrorF("\tATOM_PM_MISCINFO_THERMAL_DIODE_MODE\n");
- if (((MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK) >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) == 0)
- ErrorF("\tFM Disable\n");
- else if (((MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK) >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) == 1)
- ErrorF("\t2 level FM\n");
- else if (((MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK) >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) == 2)
- ErrorF("\t4 level FM\n");
+ switch (MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) {
+ case 0: ErrorF("\tFrame Modulation disabled\n"); break;
+ case 1: ErrorF("\t1-2 level Frame Modulation\n"); break;
+ case 2: ErrorF("\t2-3 level Frame Modulation\n"); break;
+ case 3: ErrorF("\tReserved Frame Modulation value\n"); break;
+ default: ErrorF("\tUnknown Frame Modulation value\n"); break;
+ }
if (MiscInfo & ATOM_PM_MISCINFO_DYN_CLK_3D_IDLE)
ErrorF("\tATOM_PM_MISCINFO_DYN_CLK_3D_IDLE\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2)
@@ -5139,7 +5138,7 @@ dumpAtomPowerV1Mode(int scrnIndex, ATOM_POWERMODE_INFO
*info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
"PowerPlay mode %d (%s)\n\tengine:%d memory:%d\n"
- "\tVoltage GPIO entry:%d Panel Refresh:%d temp range:%d-%d pcie
lanes:%d\n",
+ "\tVoltage GPIO entry:%d Panel Refresh:%d Temp range:%d-%d PCIe
lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
info->usEngineClock, info->usMemoryClock,
info->ucVoltageDropIndex,
@@ -5153,8 +5152,8 @@ static void
dumpAtomPowerV2Mode(int scrnIndex, ATOM_POWERMODE_INFO_V2 *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
- "Powerplay %d (%s)\n\tengine:%d memory:%d\n"
- "\tVoltage GPIO entry:%d Panel Refresh:%d temp range:%d-%d pcie
lanes:%d\n",
+ "PowerPlay %d (%s)\n\tengine:%d memory:%d\n"
+ "\tVoltage GPIO entry:%d Panel Refresh:%d Temp range:%d-%d PCIe
lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
info->ulEngineClock, info->ulMemoryClock,
info->ucVoltageDropIndex,
@@ -5169,9 +5168,9 @@ static void
dumpAtomPowerV3Mode(int scrnIndex, ATOM_POWERMODE_INFO_V3 *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
- "Powerplay %d (%s)\n\tengine:%d memory:%d\n"
- "\tIndex to core VDCC voltage table:%d Index to VDDCI voltage table:
%d\n"
- "Panel Refresh:%d temp range:%d-%d pcie lanes:%d\n",
+ "PowerPlay %d (%s)\n\tengine:%d memory:%d\n"
+ "\tIndex to core VDCC voltage table:%d Index to VDDCI voltage
table: %d\n"
+ "Panel Refresh:%d Temp range:%d-%d PCIe lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
info->ulEngineClock, info->ulMemoryClock,
info->ucVoltageDropIndex, info->ucVDDCI_VoltageDropIndex,
@@ -5303,7 +5302,7 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
break;
}

- xf86DrvMsg(handle->scrnIndex, X_INFO, "%d avilable power modes:\n",
numEntries);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "%d power modes available:\n",
numEntries);

switch (table_version) {
case 1:
--
1.5.6.4

From b748f593c1652d7424d59cef96effe926e957969 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Fri, 15 Aug 2008 16:13:17 -0700
Subject: [PATCH] More PowerPlay message cleanup

I'm guessing that POWERPLAY_SETTING_GROUP value of 0 means automatic;
atombios.h doesn't specify, it is used on my laptop.
---
src/rhd_atombios.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 17dbf6a..bfea104 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5035,6 +5035,7 @@ static char *
rhdAtomPowerPlayTypeName(unsigned long miscInfo)
{
switch ((miscInfo & ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK) >>
ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT) {
+ case 0: return "Automatic";
case 1: return "Optimal Battery Life";
case 2: return "High Battery";
case 3: return "Balanced";
@@ -5152,7 +5153,7 @@ static void
dumpAtomPowerV2Mode(int scrnIndex, ATOM_POWERMODE_INFO_V2 *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
- "PowerPlay %d (%s)\n\tengine:%d memory:%d\n"
+ "PowerPlay mode %d (%s)\n\tengine:%d memory:%d\n"
"\tVoltage GPIO entry:%d Panel Refresh:%d Temp range:%d-%d PCIe
lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
info->ulEngineClock, info->ulMemoryClock,
@@ -5168,7 +5169,7 @@ static void
dumpAtomPowerV3Mode(int scrnIndex, ATOM_POWERMODE_INFO_V3 *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
- "PowerPlay %d (%s)\n\tengine:%d memory:%d\n"
+ "PowerPlay mode %d (%s)\n\tengine:%d memory:%d\n"
"\tIndex to core VDCC voltage table:%d Index to VDDCI voltage
table: %d\n"
"Panel Refresh:%d Temp range:%d-%d PCIe lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
--
1.5.6.4

From e411f1e7e775585ab33955ec0642221e1091ede9 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sat, 16 Aug 2008 08:16:25 -0700
Subject: [PATCH] Replace ErrorF() with xf86DrvMsg()

---
src/rhd_atombios.c | 84 ++++++++++++++++++++++++++--------------------------
1 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index bfea104..e83aff7 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5035,7 +5035,7 @@ static char *
rhdAtomPowerPlayTypeName(unsigned long miscInfo)
{
switch ((miscInfo & ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK) >>
ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT) {
- case 0: return "Automatic";
+ case 0: return "Automatic"; /* This is not listed in atombios.h, but
is a guess*/
case 1: return "Optimal Battery Life";
case 2: return "High Battery";
case 3: return "Balanced";
@@ -5049,89 +5049,89 @@ static void
rhdDumpAtomPowerMisc1(int scrnIndex, unsigned long MiscInfo)
{
if (MiscInfo & ATOM_PM_MISCINFO_USING_MCLK_SRC)
- ErrorF("\tATOM_PM_MISCINFO_USING_MCLK_SRC\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_USING_MCLK_SRC\n");
if (MiscInfo & ATOM_PM_MISCINFO_USING_SCLK_SRC)
- ErrorF("\tATOM_PM_MISCINFO_USING_SCLK_SRC\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_USING_SCLK_SRC\n");
if (MiscInfo & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT)
- ErrorF("\tATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT\n");
if (MiscInfo & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
- ErrorF("\tATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH\n");
if (MiscInfo & ATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN)
- ErrorF("\tATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN)
- ErrorF("\tATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN)
- ErrorF("\tATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE)
- ErrorF("\tucVoltageDropIndex is not an index for GPIO pin, but a
voltage ID that SW needs program\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tucVoltageDropIndex is not an index for
GPIO pin, but a voltage ID that SW needs program\n");
if (MiscInfo & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN)
- ErrorF("\tATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN)
- ErrorF("\tATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)
- ErrorF("\tATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
- ErrorF("\tATOM_PM_MISCINFO_LOAD_BALANCE_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_LOAD_BALANCE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
- ErrorF("\tATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE\n");
if (MiscInfo & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)
- ErrorF("\tATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE\n");
if (MiscInfo & ATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE)
- ErrorF("\tATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE\n");
if (MiscInfo & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE)
- ErrorF("\tATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_OVER_CLOCK_MODE)
- ErrorF("\tATOM_PM_MISCINFO_OVER_CLOCK_MODE\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_OVER_CLOCK_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_OVER_DRIVE_MODE)
- ErrorF("\tATOM_PM_MISCINFO_OVER_DRIVE_MODE\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_OVER_DRIVE_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
- ErrorF("\tATOM_PM_MISCINFO_POWER_SAVING_MODE\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_POWER_SAVING_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_THERMAL_DIODE_MODE)
- ErrorF("\tATOM_PM_MISCINFO_THERMAL_DIODE_MODE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_THERMAL_DIODE_MODE\n");
switch (MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) {
- case 0: ErrorF("\tFrame Modulation disabled\n"); break;
- case 1: ErrorF("\t1-2 level Frame Modulation\n"); break;
- case 2: ErrorF("\t2-3 level Frame Modulation\n"); break;
- case 3: ErrorF("\tReserved Frame Modulation value\n"); break;
- default: ErrorF("\tUnknown Frame Modulation value\n"); break;
+ case 0: xf86DrvMsg(scrnIndex, X_NONE, "\tFrame Modulation disabled\n");
break;
+ case 1: xf86DrvMsg(scrnIndex, X_NONE, "\t1-2 level Frame Modulation\n");
break;
+ case 2: xf86DrvMsg(scrnIndex, X_NONE, "\t2-3 level Frame Modulation\n");
break;
+ case 3: xf86DrvMsg(scrnIndex, X_NONE, "\tReserved Frame Modulation
value\n"); break;
+ default: xf86DrvMsg(scrnIndex, X_NONE, "\tUnknown Frame Modulation
value\n"); break;
}
if (MiscInfo & ATOM_PM_MISCINFO_DYN_CLK_3D_IDLE)
- ErrorF("\tATOM_PM_MISCINFO_DYN_CLK_3D_IDLE\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_DYN_CLK_3D_IDLE\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2)
- ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4)
- ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN)
- ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN)
- ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
- ErrorF("\tATOM_PM_MISCINFO_3D_ACCELERATION_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_3D_ACCELERATION_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ENABLE_BACK_BIAS)
- ErrorF("\tATOM_PM_MISCINFO_ENABLE_BACK_BIAS\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_ENABLE_BACK_BIAS\n");
}

static void
rhdDumpAtomPowerMisc2(int scrnIndex, unsigned long MiscInfo)
{
if (MiscInfo & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE)
- ErrorF("\tATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT)
- ErrorF("\tATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT\n");
if (MiscInfo & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN)
- ErrorF("\tATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO)
- ErrorF("\tATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO\n");
if (MiscInfo & ATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE)
- ErrorF("\tATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN)
- ErrorF("\tATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE)
- ErrorF("\tATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE\n");
+ xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE\n");
if (MiscInfo & ATOM_PM_MISCINFO2_NOT_VALID_ON_DC)
- ErrorF("\tATOM_PM_MISCINFO2_NOT_VALID_ON_DC\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO2_NOT_VALID_ON_DC\n");
if (MiscInfo & ATOM_PM_MISCINFO2_STUTTER_MODE_EN)
- ErrorF("\tATOM_PM_MISCINFO2_STUTTER_MODE_EN\n");
+ xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO2_STUTTER_MODE_EN\n");
}

static void
--
1.5.6.4

From 549f7dc877509ef281e6a72b5d40ccb34063620a Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sat, 16 Aug 2008 09:17:37 -0700
Subject: [PATCH] atombios: ATOM_POWERPLAY_MODES now returns number of modes
available

Also eliminate some gcc warnings.
---
src/rhd_atombios.c | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index e83aff7..a1711b6 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -273,7 +273,7 @@ struct atomBIOSRequests {
{ATOM_RESTORE_REGISTERS, atomRestoreRegisters,
"Restore Registers", MSG_FORMAT_NONE},
{ATOM_POWERPLAY_MODES, rhdAtomPowerPlayInfoQuery,
- "PowerPlay Modes", MSG_FORMAT_NONE},
+ "PowerPlay Modes", MSG_FORMAT_DEC},
{FUNC_END, NULL,
NULL, MSG_FORMAT_NONE}
};
@@ -5188,7 +5188,12 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
{
atomDataTablesPtr atomDataPtr;
CARD8 crev, frev;
- int i;
+ int i, table_version;
+ UCHAR odController;
+ UCHAR odI2c;
+ UCHAR odIntBitmap;
+ UCHAR odAddr;
+ UCHAR numEntries;

RHDFUNC(handle);

@@ -5200,7 +5205,7 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
return ATOM_FAILED;
}

- int table_version = 0;
+ table_version = 0;
switch (frev) {
case 1:
switch (crev) {
@@ -5231,11 +5236,6 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
}

/* All 3 known table versions share a common header section */
- UCHAR odController;
- UCHAR odI2c;
- UCHAR odIntBitmap;
- UCHAR odAddr;
- UCHAR numEntries;

switch (table_version) {
case 1:
@@ -5259,6 +5259,11 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
odAddr =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucOverdriveControllerAddress;
numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucNumOfPowerModeEntries;
break;
+ default:
+ odController = 0;
+ odI2c = 0;
+ odAddr = 0;
+ numEntries = 0;
}

switch (odController) {
--
1.5.6.4

From 2e28cd2a47beb21de90e58d7dc2e1811068a0494 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sat, 16 Aug 2008 09:20:36 -0700
Subject: [PATCH] atombios: Missed a line in last ATOM_POWERPLAY_MODES commit

---
src/rhd_atombios.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index a1711b6..7e90f52 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5334,6 +5334,8 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
break;
}

+ data->val = numEntries;
+
return ATOM_SUCCESS;
}

--
1.5.6.4

From b6de0ff8346173eb076b6b055d07e7a5ec59e3dc Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sat, 16 Aug 2008 09:21:18 -0700
Subject: [PATCH] Add ATOM_SET_ENGINE_CLOCK and ATOM_SET_MEMORY_CLOCK commands

---
src/rhd_atombios.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/rhd_atombios.h | 3 ++
2 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 7e90f52..8c9ea07 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -129,6 +129,11 @@ atomRestoreRegisters(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBiosA
static AtomBiosResult
rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);

+static AtomBiosResult
+rhdAtomSetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
+static AtomBiosResult
+rhdAtomSetMemoryClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
+
enum msgDataFormat {
MSG_FORMAT_NONE,
MSG_FORMAT_HEX,
@@ -274,6 +279,10 @@ struct atomBIOSRequests {
"Restore Registers", MSG_FORMAT_NONE},
{ATOM_POWERPLAY_MODES, rhdAtomPowerPlayInfoQuery,
"PowerPlay Modes", MSG_FORMAT_DEC},
+ {ATOM_SET_ENGINE_CLOCK, rhdAtomSetEngineClock,
+ "Set Engine Clock", MSG_FORMAT_NONE},
+ {ATOM_SET_MEMORY_CLOCK, rhdAtomSetMemoryClock,
+ "Set Memory Clock", MSG_FORMAT_NONE},
{FUNC_END, NULL,
NULL, MSG_FORMAT_NONE}
};
@@ -5339,6 +5348,52 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
return ATOM_SUCCESS;
}

+
+static AtomBiosResult
+rhdAtomSetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
+{
+ AtomBiosArgRec execData;
+ SET_ENGINE_CLOCK_PS_ALLOCATION eng_clock_ps;
+
+ RHDFUNC(handle);
+
+ eng_clock_ps.ulTargetEngineClock = data->clockValue;
+
+ execData.exec.dataSpace = NULL;
+ execData.exec.pspace = &eng_clock_ps;
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Engine Clock to %d\n",
data->clockValue);
+ if (RHDAtomBiosFunc(handle->scrnIndex, handle,
+ ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Engine Clock to
%d\n", data->clockValue);
+ return ATOM_SUCCESS;
+ }
+ xf86DrvMsg(handle->scrnIndex, X_WARNING, "Failed to set Engine Clock\n");
+ return ATOM_FAILED;
+}
+
+static AtomBiosResult
+rhdAtomSetMemoryClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
+{
+ AtomBiosArgRec execData;
+ SET_MEMORY_CLOCK_PS_ALLOCATION mem_clock_ps;
+
+ RHDFUNC(handle);
+
+ mem_clock_ps.ulTargetMemoryClock = data->clockValue;
+
+ execData.exec.dataSpace = NULL;
+ execData.exec.pspace = &mem_clock_ps;
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Memory Clock to %d\n",
data->clockValue);
+ if (RHDAtomBiosFunc(handle->scrnIndex, handle,
+ ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Memory Clock to
%d\n", data->clockValue);
+ return ATOM_SUCCESS;
+ }
+ xf86DrvMsg(handle->scrnIndex, X_WARNING, "Failed to set Memory Clock\n");
+ return ATOM_FAILED;
+}
+
+
/*
*
*/
diff --git a/src/rhd_atombios.h b/src/rhd_atombios.h
index 4ec778f..5e94ad5 100644
--- a/src/rhd_atombios.h
+++ b/src/rhd_atombios.h
@@ -95,6 +95,8 @@ typedef enum _AtomBiosRequestID {
ATOM_SET_REGISTER_LIST_LOCATION,
ATOM_RESTORE_REGISTERS,
ATOM_POWERPLAY_MODES,
+ ATOM_SET_ENGINE_CLOCK,
+ ATOM_SET_MEMORY_CLOCK,
FUNC_END
} AtomBiosRequestID;

@@ -201,6 +203,7 @@ typedef union AtomBiosArg
AtomExecRec exec;
AtomFbRec fb;
enum RHD_TV_MODE tvMode;
+ unsigned char clockValue;
} AtomBiosArgRec, *AtomBiosArgPtr;

enum atomCrtc {
--
1.5.6.4

From 8e95d239cdd79d87711b1eaa5cee6c0966a721c6 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sat, 16 Aug 2008 11:00:50 -0700
Subject: [PATCH] Break PowerPlay table version check into its own function

---
src/rhd_atombios.c | 46 +++++++++++++++++++++++++---------------------
1 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 8c9ea07..e1b3a70 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5191,6 +5191,30 @@ dumpAtomPowerV3Mode(int scrnIndex,
ATOM_POWERMODE_INFO_V3 *info, int i)
rhdDumpAtomPowerMisc2(scrnIndex, info->ulMiscInfo2);
}

+/*
+ * Determine PowerPlay table version from formatRevision and contentRevision
+ * Returns 1, 2, or 3; 0 when unknown
+ */
+static int
+rhdAtomPowerPlayTableVersion(CARD8 frev, CARD8 crev)
+{
+ switch (frev) {
+ case 1:
+ switch (crev) {
+ case 1: return 1;
+ }
+ break;
+
+ case 2:
+ switch (crev) {
+ case 1: return 2;
+ case 2: return 3;
+ }
+ break;
+ }
+ return 0;
+}
+
static AtomBiosResult
rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
@@ -5214,27 +5238,7 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
return ATOM_FAILED;
}

- table_version = 0;
- switch (frev) {
- case 1:
- switch (crev) {
- case 1:
- table_version = 1;
- break;
- }
- break;
-
- case 2:
- switch (crev) {
- case 1:
- table_version = 2;
- break;
- case 2:
- table_version = 3;
- break;
- }
- break;
- }
+ table_version = rhdAtomPowerPlayTableVersion(frev, crev);

if (table_version > 0 && table_version <= 3)
xf86DrvMsg(handle->scrnIndex, X_INFO, "PowerPlay table version %d\n",
table_version);
--
1.5.6.4

From 85976c6537006ad08c7e5f1498c586ec177ffb96 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sat, 16 Aug 2008 11:30:01 -0700
Subject: [PATCH] Add ATOM_SET_POWERPLAY_MODE command

Also some related misc fixes
---
src/rhd_atombios.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++-----
src/rhd_atombios.h | 4 ++-
2 files changed, 78 insertions(+), 9 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index e1b3a70..a0bda23 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -128,6 +128,8 @@ atomRestoreRegisters(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBiosA

static AtomBiosResult
rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
+static AtomBiosResult
+rhdAtomPowerPlaySetMode(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);

static AtomBiosResult
rhdAtomSetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
@@ -279,6 +281,8 @@ struct atomBIOSRequests {
"Restore Registers", MSG_FORMAT_NONE},
{ATOM_POWERPLAY_MODES, rhdAtomPowerPlayInfoQuery,
"PowerPlay Modes", MSG_FORMAT_DEC},
+ {ATOM_SET_POWERPLAY_MODE, rhdAtomPowerPlaySetMode,
+ "Set PowerPlay Mode", MSG_FORMAT_NONE},
{ATOM_SET_ENGINE_CLOCK, rhdAtomSetEngineClock,
"Set Engine Clock", MSG_FORMAT_NONE},
{ATOM_SET_MEMORY_CLOCK, rhdAtomSetMemoryClock,
@@ -5276,6 +5280,7 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
odController = 0;
odI2c = 0;
odAddr = 0;
+ odIntBitmap = 0;
numEntries = 0;
}

@@ -5352,6 +5357,68 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
return ATOM_SUCCESS;
}

+static AtomBiosResult
+rhdAtomPowerPlaySetMode(atomBiosHandlePtr handle, AtomBiosRequestID func,
+ AtomBiosArgPtr data)
+{
+ atomDataTablesPtr atomDataPtr;
+ CARD8 crev, frev;
+ int table_version;
+ UCHAR numEntries;
+ unsigned long eng_clock, mem_clock;
+ AtomBiosArgRec arg;
+
+ RHDFUNC(handle);
+
+ atomDataPtr = handle->atomDataPtr;
+
+ if (!rhdAtomGetTableRevisionAndSize(
+ (ATOM_COMMON_TABLE_HEADER *)(atomDataPtr->PowerPlayInfo.base),
+ &crev,&frev,NULL)) {
+ return ATOM_FAILED;
+ }
+
+ table_version = rhdAtomPowerPlayTableVersion(frev, crev);
+
+ switch (table_version) {
+ case 1:
+ numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->ucNumOfPowerModeEntries;
+ if (data->powerPlayMode > numEntries) return ATOM_FAILED;
+ eng_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[data->powerPlayMode].usEngineClock;
+ mem_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[data->powerPlayMode].usMemoryClock;
+ break;
+ case 2:
+ numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->ucNumOfPowerModeEntries;
+ if (data->powerPlayMode > numEntries) return ATOM_FAILED;
+ eng_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[data->powerPlayMode].ulEngineClock;
+ mem_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[data->powerPlayMode].ulMemoryClock;
+ break;
+ case 3:
+ numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucNumOfPowerModeEntries;
+ if (data->powerPlayMode > numEntries) return ATOM_FAILED;
+ eng_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[data->powerPlayMode].ulEngineClock;
+ mem_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[data->powerPlayMode].ulMemoryClock;
+ break;
+ default:
+ return ATOM_FAILED;
+ }
+
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting PowerPlay to mode %d\n",
data->powerPlayMode);
+
+ arg.clockValue = eng_clock;
+ if (!RHDAtomBiosFunc(handle->scrnIndex, NULL, ATOM_SET_ENGINE_CLOCK, &arg)
+ == ATOM_SUCCESS) {
+ return ATOM_FAILED;
+ }
+
+ arg.clockValue = mem_clock;
+ if (!RHDAtomBiosFunc(handle->scrnIndex, NULL, ATOM_SET_MEMORY_CLOCK, &arg)
+ == ATOM_SUCCESS) {
+ return ATOM_FAILED;
+ }
+
+ return ATOM_FAILED;
+}

static AtomBiosResult
rhdAtomSetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
@@ -5365,11 +5432,11 @@ rhdAtomSetEngineClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios

execData.exec.dataSpace = NULL;
execData.exec.pspace = &eng_clock_ps;
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Engine Clock to %d\n",
data->clockValue);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Engine Clock to %ld\n",
data->clockValue);
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
- ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Engine Clock to
%d\n", data->clockValue);
- return ATOM_SUCCESS;
+ ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Engine Clock
to %ld\n", data->clockValue);
+ return ATOM_SUCCESS;
}
xf86DrvMsg(handle->scrnIndex, X_WARNING, "Failed to set Engine Clock\n");
return ATOM_FAILED;
@@ -5387,11 +5454,11 @@ rhdAtomSetMemoryClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios

execData.exec.dataSpace = NULL;
execData.exec.pspace = &mem_clock_ps;
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Memory Clock to %d\n",
data->clockValue);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Memory Clock to %ld\n",
data->clockValue);
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
- ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Memory Clock to
%d\n", data->clockValue);
- return ATOM_SUCCESS;
+ ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Memory Clock
to %ld\n", data->clockValue);
+ return ATOM_SUCCESS;
}
xf86DrvMsg(handle->scrnIndex, X_WARNING, "Failed to set Memory Clock\n");
return ATOM_FAILED;
diff --git a/src/rhd_atombios.h b/src/rhd_atombios.h
index 5e94ad5..e6edf28 100644
--- a/src/rhd_atombios.h
+++ b/src/rhd_atombios.h
@@ -95,6 +95,7 @@ typedef enum _AtomBiosRequestID {
ATOM_SET_REGISTER_LIST_LOCATION,
ATOM_RESTORE_REGISTERS,
ATOM_POWERPLAY_MODES,
+ ATOM_SET_POWERPLAY_MODE,
ATOM_SET_ENGINE_CLOCK,
ATOM_SET_MEMORY_CLOCK,
FUNC_END
@@ -203,7 +204,8 @@ typedef union AtomBiosArg
AtomExecRec exec;
AtomFbRec fb;
enum RHD_TV_MODE tvMode;
- unsigned char clockValue;
+ unsigned long clockValue;
+ unsigned char powerPlayMode;
} AtomBiosArgRec, *AtomBiosArgPtr;

enum atomCrtc {
--
1.5.6.4

From d83ace4d4be47d76613db0c34c692866b9447f47 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sat, 16 Aug 2008 11:31:04 -0700
Subject: [PATCH] Revert "Replace ErrorF() with xf86DrvMsg()"

This reverts commit e411f1e7e775585ab33955ec0642221e1091ede9.
---
src/rhd_atombios.c | 84 ++++++++++++++++++++++++++--------------------------
1 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index a0bda23..57ca759 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5048,7 +5048,7 @@ static char *
rhdAtomPowerPlayTypeName(unsigned long miscInfo)
{
switch ((miscInfo & ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK) >>
ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT) {
- case 0: return "Automatic"; /* This is not listed in atombios.h, but
is a guess*/
+ case 0: return "Automatic";
case 1: return "Optimal Battery Life";
case 2: return "High Battery";
case 3: return "Balanced";
@@ -5062,89 +5062,89 @@ static void
rhdDumpAtomPowerMisc1(int scrnIndex, unsigned long MiscInfo)
{
if (MiscInfo & ATOM_PM_MISCINFO_USING_MCLK_SRC)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_USING_MCLK_SRC\n");
+ ErrorF("\tATOM_PM_MISCINFO_USING_MCLK_SRC\n");
if (MiscInfo & ATOM_PM_MISCINFO_USING_SCLK_SRC)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_USING_SCLK_SRC\n");
+ ErrorF("\tATOM_PM_MISCINFO_USING_SCLK_SRC\n");
if (MiscInfo & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT\n");
+ ErrorF("\tATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT\n");
if (MiscInfo & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH\n");
+ ErrorF("\tATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH\n");
if (MiscInfo & ATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE)
- xf86DrvMsg(scrnIndex, X_NONE, "\tucVoltageDropIndex is not an index for
GPIO pin, but a voltage ID that SW needs program\n");
+ ErrorF("\tucVoltageDropIndex is not an index for GPIO pin, but a
voltage ID that SW needs program\n");
if (MiscInfo & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_LOAD_BALANCE_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_LOAD_BALANCE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE\n");
+ ErrorF("\tATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE\n");
if (MiscInfo & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE\n");
+ ErrorF("\tATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE\n");
if (MiscInfo & ATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE\n");
+ ErrorF("\tATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE\n");
if (MiscInfo & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE\n");
+ ErrorF("\tATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_OVER_CLOCK_MODE)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_OVER_CLOCK_MODE\n");
+ ErrorF("\tATOM_PM_MISCINFO_OVER_CLOCK_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_OVER_DRIVE_MODE)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_OVER_DRIVE_MODE\n");
+ ErrorF("\tATOM_PM_MISCINFO_OVER_DRIVE_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_POWER_SAVING_MODE\n");
+ ErrorF("\tATOM_PM_MISCINFO_POWER_SAVING_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO_THERMAL_DIODE_MODE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_THERMAL_DIODE_MODE\n");
+ ErrorF("\tATOM_PM_MISCINFO_THERMAL_DIODE_MODE\n");
switch (MiscInfo & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) {
- case 0: xf86DrvMsg(scrnIndex, X_NONE, "\tFrame Modulation disabled\n");
break;
- case 1: xf86DrvMsg(scrnIndex, X_NONE, "\t1-2 level Frame Modulation\n");
break;
- case 2: xf86DrvMsg(scrnIndex, X_NONE, "\t2-3 level Frame Modulation\n");
break;
- case 3: xf86DrvMsg(scrnIndex, X_NONE, "\tReserved Frame Modulation
value\n"); break;
- default: xf86DrvMsg(scrnIndex, X_NONE, "\tUnknown Frame Modulation
value\n"); break;
+ case 0: ErrorF("\tFrame Modulation disabled\n"); break;
+ case 1: ErrorF("\t1-2 level Frame Modulation\n"); break;
+ case 2: ErrorF("\t2-3 level Frame Modulation\n"); break;
+ case 3: ErrorF("\tReserved Frame Modulation value\n"); break;
+ default: ErrorF("\tUnknown Frame Modulation value\n"); break;
}
if (MiscInfo & ATOM_PM_MISCINFO_DYN_CLK_3D_IDLE)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_DYN_CLK_3D_IDLE\n");
+ ErrorF("\tATOM_PM_MISCINFO_DYN_CLK_3D_IDLE\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2\n");
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4\n");
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO_3D_ACCELERATION_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO_3D_ACCELERATION_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO_ENABLE_BACK_BIAS)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO_ENABLE_BACK_BIAS\n");
+ ErrorF("\tATOM_PM_MISCINFO_ENABLE_BACK_BIAS\n");
}

static void
rhdDumpAtomPowerMisc2(int scrnIndex, unsigned long MiscInfo)
{
if (MiscInfo & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE\n");
+ ErrorF("\tATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT\n");
+ ErrorF("\tATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT\n");
if (MiscInfo & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO\n");
+ ErrorF("\tATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO\n");
if (MiscInfo & ATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE\n");
+ ErrorF("\tATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE\n");
if (MiscInfo & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN\n");
if (MiscInfo & ATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE)
- xf86DrvMsg(scrnIndex, X_NONE,
"\tATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE\n");
+ ErrorF("\tATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE\n");
if (MiscInfo & ATOM_PM_MISCINFO2_NOT_VALID_ON_DC)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO2_NOT_VALID_ON_DC\n");
+ ErrorF("\tATOM_PM_MISCINFO2_NOT_VALID_ON_DC\n");
if (MiscInfo & ATOM_PM_MISCINFO2_STUTTER_MODE_EN)
- xf86DrvMsg(scrnIndex, X_NONE, "\tATOM_PM_MISCINFO2_STUTTER_MODE_EN\n");
+ ErrorF("\tATOM_PM_MISCINFO2_STUTTER_MODE_EN\n");
}

static void
--
1.5.6.4

From b8182cb2415a6ac07b8293a287a8215a6e317680 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Sun, 17 Aug 2008 22:38:36 -0700
Subject: [PATCH] First try at actually setting PowerPlay modes

PowerPlay mode is statically configurable. Attempts to set engine and
memory clock according to AtomBIOS table information of the configured
mode.
---
src/Makefile.am | 4 ++-
src/rhd.h | 17 +++++++++
src/rhd_atombios.c | 93 +++++++++++----------------------------------------
src/rhd_atombios.h | 3 +-
src/rhd_driver.c | 18 +++++++++-
5 files changed, 58 insertions(+), 77 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index e0b2f64..cd8c305 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,6 +40,7 @@ radeonhd_drv_la_SOURCES = \
rhd_atompll.c \
rhd_atomcrtc.c \
rhd_biosscratch.c \
+ rhd_powerplay.c \
rhd_atombios.h \
rhd_atomout.h \
rhd.h \
@@ -64,7 +65,8 @@ radeonhd_drv_la_SOURCES = \
radeon_video.c \
radeon_textured_video.c \
radeon_video.h \
- radeon_reg.h
+ radeon_reg.h \
+ rhd_powerplay.h

EXTRA_DIST += \
radeon_accelfuncs.c \
diff --git a/src/rhd.h b/src/rhd.h
index d42d99a..67add7f 100644
--- a/src/rhd.h
+++ b/src/rhd.h
@@ -194,6 +194,18 @@ enum AccelMethod {
RHD_ACCEL_DEFAULT = 4 /* keep as highest. */
};

+typedef unsigned char RHDPowerPlayMode;
+#define RHD_POWERPLAY_USE_DEFAULT_MODE 255
+
+typedef struct _RHDPowerMode {
+ unsigned long engineClock;
+ unsigned long memoryClock;
+} RHDPowerMode;
+
+typedef struct _RHDPowerPlayTable {
+ unsigned char numOfModes;
+ RHDPowerMode modes[8]; /* FIXME */
+} RHDPowerPlayTable;

typedef struct RHDRec {
int scrnIndex;
@@ -225,6 +237,7 @@ typedef struct RHDRec {
RHDOpt tvModeName;
RHDOpt scaleTypeOpt;
RHDOpt unverifiedFeatures;
+ RHDOpt defaultPowerPlayMode;
enum RHD_HPD_USAGE hpdUsage;
unsigned int FbMapSize;
pointer FbBase; /* map base of fb */
@@ -323,6 +336,9 @@ typedef struct RHDRec {

/* AtomBIOS usage */
RHDOpt UseAtomBIOS;
+
+ RHDPowerPlayTable PowerPlayTable;
+ RHDPowerPlayMode PowerPlayMode;
} RHDRec, *RHDPtr;

#define RHDPTR(p) ((RHDPtr)((p)->driverPrivate))
@@ -344,6 +360,7 @@ enum atomSubSystem {
atomUsageOutput
};

+
/* rhd_driver.c */
/* Some handy functions that makes life so much more readable */
extern unsigned int RHDReadPCIBios(RHDPtr rhdPtr, unsigned char **prt);
diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 57ca759..f90100f 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -128,8 +128,6 @@ atomRestoreRegisters(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBiosA

static AtomBiosResult
rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
-static AtomBiosResult
-rhdAtomPowerPlaySetMode(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);

static AtomBiosResult
rhdAtomSetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
@@ -281,8 +279,6 @@ struct atomBIOSRequests {
"Restore Registers", MSG_FORMAT_NONE},
{ATOM_POWERPLAY_MODES, rhdAtomPowerPlayInfoQuery,
"PowerPlay Modes", MSG_FORMAT_DEC},
- {ATOM_SET_POWERPLAY_MODE, rhdAtomPowerPlaySetMode,
- "Set PowerPlay Mode", MSG_FORMAT_NONE},
{ATOM_SET_ENGINE_CLOCK, rhdAtomSetEngineClock,
"Set Engine Clock", MSG_FORMAT_NONE},
{ATOM_SET_MEMORY_CLOCK, rhdAtomSetMemoryClock,
@@ -5231,6 +5227,7 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
UCHAR odIntBitmap;
UCHAR odAddr;
UCHAR numEntries;
+ RHDPtr rhdPtr = RHDPTRI(handle);

RHDFUNC(handle);

@@ -5326,7 +5323,7 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
break;
}

- xf86DrvMsg(handle->scrnIndex, X_INFO, "%d power modes available:\n",
numEntries);
+ rhdPtr->PowerPlayTable.numOfModes = numEntries;

switch (table_version) {
case 1:
@@ -5334,6 +5331,10 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
dumpAtomPowerV1Mode(handle->scrnIndex,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i],
i);
+ rhdPtr->PowerPlayTable.modes[i].engineClock =
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usEngineClock;
+ rhdPtr->PowerPlayTable.modes[i].memoryClock =
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usMemoryClock;
}
break;
case 2:
@@ -5341,6 +5342,10 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
dumpAtomPowerV2Mode(handle->scrnIndex,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i],
i);
+ rhdPtr->PowerPlayTable.modes[i].engineClock =
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulEngineClock;
+ rhdPtr->PowerPlayTable.modes[i].memoryClock =
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulMemoryClock;
}
break;
case 3:
@@ -5348,6 +5353,10 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
dumpAtomPowerV3Mode(handle->scrnIndex,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i],
i);
+ rhdPtr->PowerPlayTable.modes[i].engineClock =
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulEngineClock;
+ rhdPtr->PowerPlayTable.modes[i].memoryClock =
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulMemoryClock;
}
break;
}
@@ -5357,68 +5366,6 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
return ATOM_SUCCESS;
}

-static AtomBiosResult
-rhdAtomPowerPlaySetMode(atomBiosHandlePtr handle, AtomBiosRequestID func,
- AtomBiosArgPtr data)
-{
- atomDataTablesPtr atomDataPtr;
- CARD8 crev, frev;
- int table_version;
- UCHAR numEntries;
- unsigned long eng_clock, mem_clock;
- AtomBiosArgRec arg;
-
- RHDFUNC(handle);
-
- atomDataPtr = handle->atomDataPtr;
-
- if (!rhdAtomGetTableRevisionAndSize(
- (ATOM_COMMON_TABLE_HEADER *)(atomDataPtr->PowerPlayInfo.base),
- &crev,&frev,NULL)) {
- return ATOM_FAILED;
- }
-
- table_version = rhdAtomPowerPlayTableVersion(frev, crev);
-
- switch (table_version) {
- case 1:
- numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->ucNumOfPowerModeEntries;
- if (data->powerPlayMode > numEntries) return ATOM_FAILED;
- eng_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[data->powerPlayMode].usEngineClock;
- mem_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[data->powerPlayMode].usMemoryClock;
- break;
- case 2:
- numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->ucNumOfPowerModeEntries;
- if (data->powerPlayMode > numEntries) return ATOM_FAILED;
- eng_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[data->powerPlayMode].ulEngineClock;
- mem_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[data->powerPlayMode].ulMemoryClock;
- break;
- case 3:
- numEntries =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->ucNumOfPowerModeEntries;
- if (data->powerPlayMode > numEntries) return ATOM_FAILED;
- eng_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[data->powerPlayMode].ulEngineClock;
- mem_clock =
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[data->powerPlayMode].ulMemoryClock;
- break;
- default:
- return ATOM_FAILED;
- }
-
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting PowerPlay to mode %d\n",
data->powerPlayMode);
-
- arg.clockValue = eng_clock;
- if (!RHDAtomBiosFunc(handle->scrnIndex, NULL, ATOM_SET_ENGINE_CLOCK, &arg)
- == ATOM_SUCCESS) {
- return ATOM_FAILED;
- }
-
- arg.clockValue = mem_clock;
- if (!RHDAtomBiosFunc(handle->scrnIndex, NULL, ATOM_SET_MEMORY_CLOCK, &arg)
- == ATOM_SUCCESS) {
- return ATOM_FAILED;
- }
-
- return ATOM_FAILED;
-}

static AtomBiosResult
rhdAtomSetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
@@ -5432,13 +5379,13 @@ rhdAtomSetEngineClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios

execData.exec.dataSpace = NULL;
execData.exec.pspace = &eng_clock_ps;
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Engine Clock to %ld\n",
data->clockValue);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Calling SetEngineClock (%ld)\n",
data->clockValue);
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Engine Clock
to %ld\n", data->clockValue);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "SetEngineClock Successful\n");
return ATOM_SUCCESS;
}
- xf86DrvMsg(handle->scrnIndex, X_WARNING, "Failed to set Engine Clock\n");
+ xf86DrvMsg(handle->scrnIndex, X_WARNING, "SetEngineClock Failed\n");
return ATOM_FAILED;
}

@@ -5454,13 +5401,13 @@ rhdAtomSetMemoryClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios

execData.exec.dataSpace = NULL;
execData.exec.pspace = &mem_clock_ps;
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Setting Memory Clock to %ld\n",
data->clockValue);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Calling SetMemoryClock (%ld)\n",
data->clockValue);
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
ATOMBIOS_EXEC, &execData) == ATOM_SUCCESS) {
- xf86DrvMsg(handle->scrnIndex, X_INFO, "Successfully set Memory Clock
to %ld\n", data->clockValue);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "SetMemoryClock Successful\n");
return ATOM_SUCCESS;
}
- xf86DrvMsg(handle->scrnIndex, X_WARNING, "Failed to set Memory Clock\n");
+ xf86DrvMsg(handle->scrnIndex, X_WARNING, "SetMemoryClock Failed\n");
return ATOM_FAILED;
}

diff --git a/src/rhd_atombios.h b/src/rhd_atombios.h
index e6edf28..95107ab 100644
--- a/src/rhd_atombios.h
+++ b/src/rhd_atombios.h
@@ -95,7 +95,6 @@ typedef enum _AtomBiosRequestID {
ATOM_SET_REGISTER_LIST_LOCATION,
ATOM_RESTORE_REGISTERS,
ATOM_POWERPLAY_MODES,
- ATOM_SET_POWERPLAY_MODE,
ATOM_SET_ENGINE_CLOCK,
ATOM_SET_MEMORY_CLOCK,
FUNC_END
@@ -205,7 +204,7 @@ typedef union AtomBiosArg
AtomFbRec fb;
enum RHD_TV_MODE tvMode;
unsigned long clockValue;
- unsigned char powerPlayMode;
+ RHDPowerPlayMode powerPlayMode;
} AtomBiosArgRec, *AtomBiosArgPtr;

enum atomCrtc {
diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index b293db8..ea48c80 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -118,6 +118,7 @@
#include "rhd_shadow.h"
#include "rhd_card.h"
#include "rhd_randr.h"
+#include "rhd_powerplay.h"
#if 0
#include "r5xx_accel.h"
#endif
@@ -253,7 +254,8 @@ typedef enum {
OPTION_TV_MODE,
OPTION_SCALE_TYPE,
OPTION_UNVERIFIED_FEAT,
- OPTION_USE_ATOMBIOS
+ OPTION_USE_ATOMBIOS,
+ OPTION_POWERPLAY_MODE
} RHDOpts;

static const OptionInfoRec RHDOptions[] = {
@@ -274,6 +276,7 @@ static const OptionInfoRec RHDOptions[] = {
{ OPTION_SCALE_TYPE, "ScaleType", OPTV_ANYSTR, {0},
FALSE },
{ OPTION_UNVERIFIED_FEAT, "UnverifiedFeatures", OPTV_BOOLEAN, {0},
FALSE },
{ OPTION_USE_ATOMBIOS, "UseAtomBIOS", OPTV_BOOLEAN, {0},
FALSE },
+ { OPTION_POWERPLAY_MODE, "PowerPlayMode", OPTV_INTEGER, {0},
FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};

@@ -982,6 +985,14 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)
RHDDebug(pScrn->scrnIndex, "Free FB offset 0x%08X (size = 0x%08X)\n",
rhdPtr->FbFreeStart, rhdPtr->FbFreeSize);

+ /* Handle PowerPlayMode option */
+ if (!rhdPtr->defaultPowerPlayMode.set) {
+ rhdPtr->defaultPowerPlayMode.val.integer =
RHD_POWERPLAY_USE_DEFAULT_MODE;
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Setting default PowerPlay mode
to %d\n", rhdPtr->defaultPowerPlayMode.val.integer);
+ }
+
ret = TRUE;

error1:
@@ -1208,6 +1219,9 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv)
RADEONInitVideo(pScreen);
}

+ /* Switch PowerPlay mode */
+ rhdPowerPlaySetMode(rhdPtr, rhdPtr->defaultPowerPlayMode.val.integer);
+
/* Wrap the current CloseScreen function */
rhdPtr->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = RHDCloseScreen;
@@ -2633,6 +2647,8 @@ rhdProcessOptions(ScrnInfoPtr pScrn)
&rhdPtr->unverifiedFeatures, FALSE);
RhdGetOptValBool (rhdPtr->Options, OPTION_USE_ATOMBIOS,
&rhdPtr->UseAtomBIOS, FALSE);
+ RhdGetOptValInteger(rhdPtr->Options, OPTION_POWERPLAY_MODE,
+ &rhdPtr->defaultPowerPlayMode, 0);

rhdAccelOptionsHandle(pScrn);

--
1.5.6.4

From 7d65c1cd01a96f2b600532139fc17682d0bec519 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Fri, 19 Sep 2008 12:33:33 -0700
Subject: [PATCH] fix bad merge from pulling master

---
src/rhd_driver.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index 4a97f78..506fd63 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -255,7 +255,6 @@ typedef enum {
OPTION_ATOMBIOS, /* only for testing, don't document in man page! */
#endif
OPTION_UNVERIFIED_FEAT,
- OPTION_USE_ATOMBIOS,
OPTION_POWERPLAY_MODE
} RHDOpts;

--
1.5.6.4

From 1fb007a885af732a1f434bfe56bc2acdf8b7bd23 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Fri, 19 Sep 2008 16:58:28 -0700
Subject: [PATCH] Add powerplay files

---
src/rhd_powerplay.c | 38 ++++++++++++++++++++++++++++++++++++++
src/rhd_powerplay.h | 8 ++++++++
2 files changed, 46 insertions(+), 0 deletions(-)
create mode 100644 src/rhd_powerplay.c
create mode 100644 src/rhd_powerplay.h

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
new file mode 100644
index 0000000..b17a1bf
--- /dev/null
+++ b/src/rhd_powerplay.c
@@ -0,0 +1,38 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xf86.h"
+
+#if HAVE_XF86_ANSIC_H
+# include "xf86_ansic.h"
+#else
+# include <unistd.h>
+#endif
+
+#include "rhd.h"
+#include "rhd_powerplay.h"
+#include "rhd_mc.h"
+#if defined (ATOM_BIOS) && defined (ATOM_BIOS_PARSER)
+# include "rhd_atombios.h"
+
+Bool
+rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
+{
+ AtomBiosArgRec atomBiosArg;
+
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Switching to PowerPlay mode %d\n",
mode);
+
+ atomBiosArg.clockValue = rhdPtr->PowerPlayTable.modes[mode].engineClock;
+ if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_ENGINE_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
+ return FALSE;
+
+ atomBiosArg.clockValue = rhdPtr->PowerPlayTable.modes[mode].memoryClock;
+ if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_MEMORY_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
+ return FALSE;
+
+ return TRUE;
+}
+
+#endif /* ATOM_BIOS && ATOM_BIOS_PARSER */
diff --git a/src/rhd_powerplay.h b/src/rhd_powerplay.h
new file mode 100644
index 0000000..a6cb64f
--- /dev/null
+++ b/src/rhd_powerplay.h
@@ -0,0 +1,8 @@
+
+#ifndef _RHD_POWERPLAY_H
+# define _RHD_POWERPLAY_H
+
+Bool rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode);
+
+#endif /* _RHD_POWERPLAY_H */
+
--
1.5.6.4

From 529d0eb20b05138a6ed58c31541c60ea69331686 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Thu, 25 Sep 2008 21:04:45 -0700
Subject: [PATCH] Add R5xx CLOCK_CNTL register manipulation, and power
management init

---
src/rhd_driver.c | 3 +++
src/rhd_powerplay.c | 27 +++++++++++++++++++++++++++
src/rhd_powerplay.h | 2 ++
src/rhd_regs.h | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index 506fd63..73f407d 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -1240,6 +1240,9 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv)
RADEONInitVideo(pScreen);
}

+ /* Initialize power management */
+ rhdInitPowerManagement(rhdPtr);
+
/* Switch PowerPlay mode */
rhdPowerPlaySetMode(rhdPtr, rhdPtr->defaultPowerPlayMode.val.integer);

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index b17a1bf..13d5b69 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -13,10 +13,37 @@

#include "rhd.h"
#include "rhd_powerplay.h"
+#include "rhd_regs.h"
#include "rhd_mc.h"
#if defined (ATOM_BIOS) && defined (ATOM_BIOS_PARSER)
# include "rhd_atombios.h"

+#define RHDSetCCRegIndex(ptr, index) RHDRegMask(ptr, CLOCK_CNTL_INDEX,
index|PLL_WR_EN, PLL_ADDR|PLL_WR_EN)
+#define RHDSetCCRegIndexRO(ptr, index) RHDRegMask(ptr, CLOCK_CNTL_INDEX,
index, PLL_ADDR|PLL_WR_EN)
+#define RHDCCRegWrite(ptr, data) RHDRegWrite(ptr, CLOCK_CNTL_DATA, data)
+
+void rhdInitPowerManagement_r5xx(RHDPtr rhdPtr);
+
+void
+rhdInitPowerManagement(RHDPtr rhdPtr)
+{
+ if (rhdPtr->ChipSet < RHD_R600) {
+ rhdInitPowerManagement_r5xx(rhdPtr);
+ }
+ else
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Power management not supported
on R600 and greater");
+
+}
+
+
+void
+rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
+{
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");
+ RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
+ RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);
+}
+
Bool
rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
{
diff --git a/src/rhd_powerplay.h b/src/rhd_powerplay.h
index a6cb64f..4920052 100644
--- a/src/rhd_powerplay.h
+++ b/src/rhd_powerplay.h
@@ -2,6 +2,8 @@
#ifndef _RHD_POWERPLAY_H
# define _RHD_POWERPLAY_H

+void rhdInitPowerManagement(RHDPtr rhdPtr);
+
Bool rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode);

#endif /* _RHD_POWERPLAY_H */
diff --git a/src/rhd_regs.h b/src/rhd_regs.h
index 1c1e7d7..96ac0db 100644
--- a/src/rhd_regs.h
+++ b/src/rhd_regs.h
@@ -643,6 +643,43 @@ enum _r5xxSPLLRegs {
SPLL_FUNC_CNTL = 0x0 /* (RW) */
};

+/* Registers in the r5xx CLKIND aperture */
+enum _r5xxCLKINDRegs {
+ R5_SPLL_FUNC_CNTL = 0x00,
+ R5_SPLL_BYPASSCLK_SEL = 0x01,
+ R5_SPLL_CNTL_MODE = 0x02,
+ R5_SPLL_CKL_SEL = 0x03,
+ R5_MPLL_FUNC_CNTL = 0x04,
+ R5_MPLL_BYPASSCLK_SEL = 0x05,
+ R5_MPLL_CNTL_MODE = 0x06,
+ R5_MPLL_CLK_SEL = 0x07,
+ R5_GENERAL_PWRMGT = 0x08,
+ R5_SCLK_PWRMGT_CNTL = 0x09,
+ R5_MCLK_PWRMGT_CNTL = 0x0A,
+ R5_DYN_PWRMGT_SCLK_CNTL = 0x0B,
+ R5_DYN_PWRMGT_SCLK_LENGTH = 0x0C,
+ R5_DYN_SCLK_PWMEN_PIPE = 0x0D,
+ R5_DYN_SCLK_VOL_CNTL = 0x0E,
+ R5_VIP_DYN_CNTL = 0x14,
+ R5_TCL_DYN_CNTL = 0x1A,
+ R5_MC_GUI_DYN_CNTL = 0x1D,
+ R5_MC_HOST_DYN_CNTL = 0x1E,
+ R5_MC_RBS_DYN_CNTL = 0x26,
+ R5_CG_MISC_REG = 0x1F,
+ R5_PLL_TEST_CNTL = 0x21,
+ R5_MCLK_MISC = 0x22,
+ R5_DLL_CNTL = 0x23,
+ R5_SPLL_TIME = 0x24,
+ R5_MPLL_TIME = 0x25,
+ R5_DYN_BACKBIAS_CNTL = 0x29,
+ R5_POLARITY_CNTL = 0x2A,
+ R5_ERROR_STATUS = 0x2C,
+ R5_CG_CLKPIN_CNTL = 0x3C,
+ R5_VOL_DROP_CNTL = 0x36,
+ R5_CG_TC_JTAG_0 = 0x38,
+ R5_CG_TC_JTAG_1 = 0x39
+};
+
enum _r6xxRegs {
/* MCLK */
R6_MCLK_PWRMGT_CNTL = 0x620,
--
1.5.6.4

From 2d4d4a622b82ffdf5a84d67313dda152e9b2b354 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Thu, 25 Sep 2008 21:29:44 -0700
Subject: [PATCH] Fix missing indexing into command table for
rhdAtomSet{Engine|Memory}Clock

---
src/rhd_atombios.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index f502642..53a5a49 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5383,6 +5383,7 @@ rhdAtomSetEngineClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios
eng_clock_ps.ulTargetEngineClock = data->clockValue;

execData.exec.dataSpace = NULL;
+ execData.exec.index = GetIndexIntoMasterTable(COMMAND,SetEngineClock);
execData.exec.pspace = &eng_clock_ps;
xf86DrvMsg(handle->scrnIndex, X_INFO, "Calling SetEngineClock (%ld)\n",
data->clockValue);
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
@@ -5405,6 +5406,7 @@ rhdAtomSetMemoryClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios
mem_clock_ps.ulTargetMemoryClock = data->clockValue;

execData.exec.dataSpace = NULL;
+ execData.exec.index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock);
execData.exec.pspace = &mem_clock_ps;
xf86DrvMsg(handle->scrnIndex, X_INFO, "Calling SetMemoryClock (%ld)\n",
data->clockValue);
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
--
1.5.6.4

From ec6258c05d65e6274ca62ff19d8edd996ce43dc5 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Fri, 26 Sep 2008 17:35:13 -0700
Subject: [PATCH] Store engine and memory clock in units of kHz instead of 10kHz

---
src/rhd_atombios.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 53a5a49..6daa4af 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5049,7 +5049,7 @@ static char *
rhdAtomPowerPlayTypeName(unsigned long miscInfo)
{
switch ((miscInfo & ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK) >>
ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT) {
- case 0: return "Automatic";
+ case 0: return "Automatic?";
case 1: return "Optimal Battery Life";
case 2: return "High Battery";
case 3: return "Balanced";
@@ -5152,7 +5152,7 @@ static void
dumpAtomPowerV1Mode(int scrnIndex, ATOM_POWERMODE_INFO *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
- "PowerPlay mode %d (%s)\n\tengine:%d memory:%d\n"
+ "PowerPlay mode %d (%s)\n\tengine:%dkHz memory:%dkHz\n"
"\tVoltage GPIO entry:%d Panel Refresh:%d Temp range:%d-%d PCIe
lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
info->usEngineClock, info->usMemoryClock,
@@ -5167,7 +5167,7 @@ static void
dumpAtomPowerV2Mode(int scrnIndex, ATOM_POWERMODE_INFO_V2 *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
- "PowerPlay mode %d (%s)\n\tengine:%d memory:%d\n"
+ "PowerPlay mode %d (%s)\n\tengine:%dkHz memory:%dkHz\n"
"\tVoltage GPIO entry:%d Panel Refresh:%d Temp range:%d-%d PCIe
lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
info->ulEngineClock, info->ulMemoryClock,
@@ -5183,7 +5183,7 @@ static void
dumpAtomPowerV3Mode(int scrnIndex, ATOM_POWERMODE_INFO_V3 *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
- "PowerPlay mode %d (%s)\n\tengine:%d memory:%d\n"
+ "PowerPlay mode %d (%s)\n\tengine:%dkHz memory:%dkHz\n"
"\tIndex to core VDCC voltage table:%d Index to VDDCI voltage
table: %d\n"
"Panel Refresh:%d Temp range:%d-%d PCIe lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
@@ -5337,9 +5337,9 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i],
i);
rhdPtr->PowerPlayTable.modes[i].engineClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usEngineClock;
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usEngineClock * 10;
rhdPtr->PowerPlayTable.modes[i].memoryClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usMemoryClock;
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usMemoryClock * 10;
}
break;
case 2:
@@ -5348,9 +5348,9 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i],
i);
rhdPtr->PowerPlayTable.modes[i].engineClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulEngineClock;
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulEngineClock *
10;
rhdPtr->PowerPlayTable.modes[i].memoryClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulMemoryClock;
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulMemoryClock *
10;
}
break;
case 3:
@@ -5359,9 +5359,9 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i],
i);
rhdPtr->PowerPlayTable.modes[i].engineClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulEngineClock;
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulEngineClock *
10;
rhdPtr->PowerPlayTable.modes[i].memoryClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulMemoryClock;
+
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulMemoryClock *
10;
}
break;
}
@@ -5380,10 +5380,10 @@ rhdAtomSetEngineClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios

RHDFUNC(handle);

- eng_clock_ps.ulTargetEngineClock = data->clockValue;
+ eng_clock_ps.ulTargetEngineClock = data->clockValue / 10;

execData.exec.dataSpace = NULL;
- execData.exec.index = GetIndexIntoMasterTable(COMMAND,SetEngineClock);
+ execData.exec.index = GetIndexIntoMasterTable(COMMAND, SetEngineClock);
execData.exec.pspace = &eng_clock_ps;
xf86DrvMsg(handle->scrnIndex, X_INFO, "Calling SetEngineClock (%ld)\n",
data->clockValue);
if (RHDAtomBiosFunc(handle->scrnIndex, handle,
@@ -5403,7 +5403,7 @@ rhdAtomSetMemoryClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios

RHDFUNC(handle);

- mem_clock_ps.ulTargetMemoryClock = data->clockValue;
+ mem_clock_ps.ulTargetMemoryClock = data->clockValue / 10;

execData.exec.dataSpace = NULL;
execData.exec.index = GetIndexIntoMasterTable(COMMAND, SetMemoryClock);
--
1.5.6.4

From d8d2e1eb00c9d9bef4a3e4c4d675eb8e809682d1 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yangman@xxxxxxxxx>
Date: Fri, 26 Sep 2008 17:36:00 -0700
Subject: [PATCH] Add functionality to get engine and memory clock via AtomBIOS

---
src/rhd_atombios.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/rhd_atombios.h | 2 ++
src/rhd_powerplay.c | 3 +++
3 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 6daa4af..2331abe 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -134,6 +134,11 @@ rhdAtomSetEngineClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios
static AtomBiosResult
rhdAtomSetMemoryClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);

+static AtomBiosResult
+rhdAtomGetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
+static AtomBiosResult
+rhdAtomGetMemoryClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);
+
enum msgDataFormat {
MSG_FORMAT_NONE,
MSG_FORMAT_HEX,
@@ -283,6 +288,10 @@ struct atomBIOSRequests {
"Set Engine Clock", MSG_FORMAT_NONE},
{ATOM_SET_MEMORY_CLOCK, rhdAtomSetMemoryClock,
"Set Memory Clock", MSG_FORMAT_NONE},
+ {ATOM_GET_ENGINE_CLOCK, rhdAtomGetEngineClock,
+ "Get Engine Clock", MSG_FORMAT_DEC},
+ {ATOM_GET_MEMORY_CLOCK, rhdAtomGetMemoryClock,
+ "Get Memory Clock", MSG_FORMAT_DEC},
{FUNC_END, NULL,
NULL, MSG_FORMAT_NONE}
};
@@ -5418,6 +5427,47 @@ rhdAtomSetMemoryClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios
return ATOM_FAILED;
}

+static AtomBiosResult
+rhdAtomGetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
+{
+ AtomBiosArgRec idx;
+
+ RHDFUNC(handle);
+
+ GET_ENGINE_CLOCK_PARAMETERS p;
+
+ idx.exec.dataSpace = NULL;
+ idx.exec.index = GetIndexIntoMasterTable(COMMAND, GetEngineClock);
+ idx.exec.pspace = &p;
+
+ if (RHDAtomBiosFunc(handle->scrnIndex, handle,
+ ATOMBIOS_EXEC, &idx) == ATOM_SUCCESS) {
+ data->val = p.ulReturnEngineClock;
+ return ATOM_SUCCESS;
+ }
+ return ATOM_FAILED;
+}
+
+static AtomBiosResult
+rhdAtomGetMemoryClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
+{
+ AtomBiosArgRec idx;
+
+ RHDFUNC(handle);
+
+ GET_MEMORY_CLOCK_PARAMETERS p;
+
+ idx.exec.dataSpace = NULL;
+ idx.exec.index = GetIndexIntoMasterTable(COMMAND, GetMemoryClock);
+ idx.exec.pspace = &p;
+
+ if (RHDAtomBiosFunc(handle->scrnIndex, handle,
+ ATOMBIOS_EXEC, &idx) == ATOM_SUCCESS) {
+ data->val = p.ulReturnMemoryClock;
+ return ATOM_SUCCESS;
+ }
+ return ATOM_FAILED;
+}

/*
*
diff --git a/src/rhd_atombios.h b/src/rhd_atombios.h
index 071509a..93cf88b 100644
--- a/src/rhd_atombios.h
+++ b/src/rhd_atombios.h
@@ -104,6 +104,8 @@ typedef enum _AtomBiosRequestID {
ATOM_POWERPLAY_MODES,
ATOM_SET_ENGINE_CLOCK,
ATOM_SET_MEMORY_CLOCK,
+ ATOM_GET_ENGINE_CLOCK,
+ ATOM_GET_MEMORY_CLOCK,
FUNC_END
} AtomBiosRequestID;

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 13d5b69..f030dd5 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -59,6 +59,9 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_MEMORY_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
return FALSE;

+ RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_ENGINE_CLOCK, &atomBiosArg);
+ RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_MEMORY_CLOCK, &atomBiosArg);
+
return TRUE;
}

--
1.5.6.4

From 872f25088814ce70651f8583eae40d014b3c5dd5 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 00:35:41 -0700
Subject: [PATCH] PowerPlay: extract more of PowerPlay tables into RHDRec

First steps towards storing and using PowerPlay table independently of
atombios.h.
---
src/rhd.h | 60 +++++++++++++++++++++-
src/rhd_atombios.c | 146 +++++++++++++++++++++++++++++++++++++++++++++------
src/rhd_driver.c | 13 +----
src/rhd_powerplay.c | 29 ++++++++++
src/rhd_powerplay.h | 1 +
5 files changed, 221 insertions(+), 28 deletions(-)

diff --git a/src/rhd.h b/src/rhd.h
index 3cf77b1..6f06f1b 100644
--- a/src/rhd.h
+++ b/src/rhd.h
@@ -194,19 +194,77 @@ enum AccelMethod {
RHD_ACCEL_DEFAULT = 4 /* keep as highest. */
};

+/* PowerPlay related structs */
typedef unsigned char RHDPowerPlayMode;
#define RHD_POWERPLAY_USE_DEFAULT_MODE 255
+#define RHD_POWERPLAY_MAX_MODES 8
+
+enum RHDPowerModeGroup {
+ RHD_PM_AUTOMATIC = 0,
+ RHD_PM_OPTIMAL_BATTERY = 1,
+ RHD_PM_HIGH_BATTERY = 2,
+ RHD_PM_BALANCED = 3,
+ RHD_PM_HIGH_PERFORMANCE = 4,
+ RHD_PM_OPTIMAL_PERFORMANCE = 5
+};
+
+enum RHDPowerModeMode {
+ RHD_PM_DEFAULT_MODE,
+ RHD_PM_OVER_CLOCK_MODE,
+ RHD_PM_OVER_DRIVE_MODE,
+ RHD_PM_POWER_SAVING_MODE,
+ RHD_PM_THERMAL_DIODE_MODE
+};
+
+enum RHDPowerModeClockInfo {
+ RHD_PM_USING_MCLK_SRC = 1 << 0,
+ RHD_PM_USING_SCLK_SRC = 1 << 1,
+ RHD_PM_ENGINE_CLOCK_CONTRL_EN = 1 << 9,
+ RHD_PM_MEMORY_CLOCK_CONTRL_EN = 1 << 10,
+ RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN = 1 << 16,
+ RHD_PM_DYNAMIC_CLOCK_3D_IDLE = 1 << 24,
+ RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 = 1 << 25,
+ RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 = 1 << 26
+};
+
+enum RHDPowerModeVoltageInfo {
+ RHD_PM_PROGRAM_VOLTAGE = 1 << 0,
+ RHD_PM_VOLTAGE_DROP_SUPPORT = 1 << 1,
+ RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH = 1 << 2,
+ RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN = 1 << 3,
+ RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN = 1 << 4
+};
+
+enum RHDPowerModeCapabilitiesInfo {
+ RHD_PM_3D_ACCELERATION_EN = 1 << 0,
+ RHD_PM_MULTI_DISPLAY_SUPPORT = 1 << 1,
+ RHD_PM_VIDEO_PLAYBACK_CAPABLE = 1 << 2,
+ RHD_PM_UVD_SUPPORT_MODE = 1 << 3
+};

typedef struct _RHDPowerMode {
+ enum RHDPowerModeGroup group;
+ enum RHDPowerModeMode mode;
unsigned long engineClock;
unsigned long memoryClock;
+ unsigned char pcieLanes;
+
+ union {
+ unsigned char index;
+ unsigned short level;
+ } voltageDrop;
+
+ enum RHDPowerModeClockInfo clockInfo;
+ enum RHDPowerModeVoltageInfo voltageInfo;
+ enum RHDPowerModeCapabilitiesInfo capInfo;
} RHDPowerMode;

typedef struct _RHDPowerPlayTable {
unsigned char numOfModes;
- RHDPowerMode modes[8]; /* FIXME */
+ RHDPowerMode modes[RHD_POWERPLAY_MAX_MODES];
} RHDPowerPlayTable;

+
typedef struct RHDRec {
int scrnIndex;

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 2331abe..fe3b30d 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5155,6 +5155,8 @@ rhdDumpAtomPowerMisc2(int scrnIndex, unsigned long
MiscInfo)
ErrorF("\tATOM_PM_MISCINFO2_NOT_VALID_ON_DC\n");
if (MiscInfo & ATOM_PM_MISCINFO2_STUTTER_MODE_EN)
ErrorF("\tATOM_PM_MISCINFO2_STUTTER_MODE_EN\n");
+ if (MiscInfo & ATOM_PM_MISCINFO2_UVD_SUPPORT_MODE)
+ ErrorF("\tATOM_PM_MISCINFO2UVD_SUPPORT_MODEN\n");
}

static void
@@ -5173,6 +5175,126 @@ dumpAtomPowerV1Mode(int scrnIndex, ATOM_POWERMODE_INFO
*info, int i)
}

static void
+rhdAtomStorePowerModeMisc1(ULONG info, RHDPowerMode *mode)
+{
+ if (info & ATOM_PM_MISCINFO_USING_MCLK_SRC)
+ mode->clockInfo |= RHD_PM_USING_MCLK_SRC;
+ if (info & ATOM_PM_MISCINFO_USING_SCLK_SRC)
+ mode->clockInfo |= RHD_PM_USING_SCLK_SRC;
+ if (info & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT)
+ mode->voltageInfo |= RHD_PM_VOLTAGE_DROP_SUPPORT;
+ if (info & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
+ mode->voltageInfo |= RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH;
+ /*if (info & ATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN)*/
+ if (info & ATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN)
+ mode->clockInfo |= RHD_PM_ENGINE_CLOCK_CONTRL_EN;
+ if (info & ATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN)
+ mode->clockInfo |= RHD_PM_MEMORY_CLOCK_CONTRL_EN;
+ if (info & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE)
+ mode->voltageInfo |= RHD_PM_PROGRAM_VOLTAGE;
+ if (info & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN)
+ mode->clockInfo |= RHD_PM_USING_SCLK_SRC;
+ if (info & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN)
+ mode->voltageInfo |= RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN;
+ /*if (info & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)*/
+ /*if (info & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)*/
+ /*if (info & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)*/
+ /*if (info & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)*/
+ /*if (info & ATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE)*/
+ if (info & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE)
+ mode->mode = RHD_PM_DEFAULT_MODE;
+ if (info & ATOM_PM_MISCINFO_OVER_CLOCK_MODE)
+ mode->mode = RHD_PM_OVER_CLOCK_MODE;
+ if (info & ATOM_PM_MISCINFO_OVER_DRIVE_MODE)
+ mode->mode = RHD_PM_OVER_DRIVE_MODE;
+ if (info & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
+ mode->mode = RHD_PM_POWER_SAVING_MODE;
+ if (info & ATOM_PM_MISCINFO_THERMAL_DIODE_MODE)
+ mode->mode = RHD_PM_THERMAL_DIODE_MODE;
+ /*
+ switch (info & ATOM_PM_MISCINFO_FRAME_MODULATION_MASK >>
ATOM_PM_MISCINFO_FRAME_MODULATION_SHIFT) {
+ case 0: ErrorF("\tFrame Modulation disabled\n"); break;
+ case 1: ErrorF("\t1-2 level Frame Modulation\n"); break;
+ case 2: ErrorF("\t2-3 level Frame Modulation\n"); break;
+ case 3: ErrorF("\tReserved Frame Modulation value\n"); break;
+ default: ErrorF("\tUnknown Frame Modulation value\n"); break;
+ }
+ */
+ if (info & ATOM_PM_MISCINFO_DYN_CLK_3D_IDLE)
+ mode->clockInfo |= RHD_PM_DYNAMIC_CLOCK_3D_IDLE;
+ if (info & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2)
+ mode->clockInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2;
+ if (info & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4)
+ mode->clockInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4;
+ /*if (info & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN)*/
+ /*if (info & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN)*/
+ if (info & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
+ mode->capInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4;
+ /*if (info & ATOM_PM_MISCINFO_ENABLE_BACK_BIAS)*/
+}
+
+static void
+rhdAtomStorePowerModeMisc2(ULONG info, RHDPowerMode *mode)
+{
+ /*if (info & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE)*/
+ if (info & ATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT)
+ mode->capInfo |= RHD_PM_MULTI_DISPLAY_SUPPORT;
+ /*if (info & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN)*/
+ /*if (info & ATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO)*/
+ /*if (info & ATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE)*/
+ if (info & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN)
+ mode->voltageInfo |= RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN;
+ if (info & ATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE)
+ mode->capInfo |= RHD_PM_VIDEO_PLAYBACK_CAPABLE;
+ /*if (info & ATOM_PM_MISCINFO2_NOT_VALID_ON_DC)*/
+ /*if (info & ATOM_PM_MISCINFO2_STUTTER_MODE_EN)*/
+ if (info & ATOM_PM_MISCINFO2_UVD_SUPPORT_MODE)
+ mode->capInfo |= RHD_PM_UVD_SUPPORT_MODE;
+}
+
+static void
+rhdAtomStorePowerMode_v1(ATOM_POWERMODE_INFO *info, RHDPowerMode *mode)
+{
+ mode->engineClock = info->usEngineClock * 10;
+ mode->memoryClock = info->usMemoryClock * 10;
+ mode->pcieLanes = info->ucNumPciELanes;
+ mode->voltageDrop.index = info->ucVoltageDropIndex;
+ mode->clockInfo = 0;
+ mode->voltageInfo = 0;
+ mode->capInfo = 0;
+ rhdAtomStorePowerModeMisc1(info->ulMiscInfo, mode);
+}
+
+static void
+rhdAtomStorePowerMode_v2(ATOM_POWERMODE_INFO_V2 *info, RHDPowerMode *mode)
+{
+ mode->engineClock = info->ulEngineClock * 10;
+ mode->memoryClock = info->ulMemoryClock * 10;
+ mode->pcieLanes = info->ucNumPciELanes;
+ mode->voltageDrop.index = info->ucVoltageDropIndex;
+ mode->clockInfo = 0;
+ mode->voltageInfo = 0;
+ mode->capInfo = 0;
+ rhdAtomStorePowerModeMisc1(info->ulMiscInfo, mode);
+ rhdAtomStorePowerModeMisc2(info->ulMiscInfo2, mode);
+}
+
+static void
+rhdAtomStorePowerMode_v3(ATOM_POWERMODE_INFO_V3 *info, RHDPowerMode *mode)
+{
+ mode->engineClock = info->ulEngineClock * 10;
+ mode->memoryClock = info->ulMemoryClock * 10;
+ mode->pcieLanes = info->ucNumPciELanes;
+ mode->clockInfo = 0;
+ mode->voltageInfo = 0;
+ mode->capInfo = 0;
+ /* FIXME */
+ /*mode->voltageDrop.index = info->ucVoltageDropIndex;*/
+ rhdAtomStorePowerModeMisc1(info->ulMiscInfo, mode);
+ rhdAtomStorePowerModeMisc2(info->ulMiscInfo2, mode);
+}
+
+static void
dumpAtomPowerV2Mode(int scrnIndex, ATOM_POWERMODE_INFO_V2 *info, int i)
{
xf86DrvMsg(scrnIndex, X_INFO,
@@ -5345,10 +5467,8 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
dumpAtomPowerV1Mode(handle->scrnIndex,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i],
i);
- rhdPtr->PowerPlayTable.modes[i].engineClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usEngineClock * 10;
- rhdPtr->PowerPlayTable.modes[i].memoryClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i].usMemoryClock * 10;
+
rhdAtomStorePowerMode_v1(&atomDataPtr->PowerPlayInfo.PowerPlayInfo->asPowerPlayInfo[i],
+ &rhdPtr->PowerPlayTable.modes[i]);
}
break;
case 2:
@@ -5356,10 +5476,8 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
dumpAtomPowerV2Mode(handle->scrnIndex,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i],
i);
- rhdPtr->PowerPlayTable.modes[i].engineClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulEngineClock *
10;
- rhdPtr->PowerPlayTable.modes[i].memoryClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i].ulMemoryClock *
10;
+
rhdAtomStorePowerMode_v2(&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v2->asPowerPlayInfo[i],
+ &rhdPtr->PowerPlayTable.modes[i]);
}
break;
case 3:
@@ -5367,10 +5485,8 @@ rhdAtomPowerPlayInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
dumpAtomPowerV3Mode(handle->scrnIndex,

&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i],
i);
- rhdPtr->PowerPlayTable.modes[i].engineClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulEngineClock *
10;
- rhdPtr->PowerPlayTable.modes[i].memoryClock =
-
atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i].ulMemoryClock *
10;
+
rhdAtomStorePowerMode_v3(&atomDataPtr->PowerPlayInfo.PowerPlayInfo_v3->asPowerPlayInfo[i],
+ &rhdPtr->PowerPlayTable.modes[i]);
}
break;
}
@@ -5431,11 +5547,10 @@ static AtomBiosResult
rhdAtomGetEngineClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
{
AtomBiosArgRec idx;
+ GET_ENGINE_CLOCK_PARAMETERS p;

RHDFUNC(handle);

- GET_ENGINE_CLOCK_PARAMETERS p;
-
idx.exec.dataSpace = NULL;
idx.exec.index = GetIndexIntoMasterTable(COMMAND, GetEngineClock);
idx.exec.pspace = &p;
@@ -5452,11 +5567,10 @@ static AtomBiosResult
rhdAtomGetMemoryClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data)
{
AtomBiosArgRec idx;
+ GET_MEMORY_CLOCK_PARAMETERS p;

RHDFUNC(handle);

- GET_MEMORY_CLOCK_PARAMETERS p;
-
idx.exec.dataSpace = NULL;
idx.exec.index = GetIndexIntoMasterTable(COMMAND, GetMemoryClock);
idx.exec.pspace = &p;
diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index df14819..d9ec31f 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -763,17 +763,8 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)
#endif

#ifdef ATOM_BIOS
- if (rhdPtr->atomBIOS) {
- AtomBiosArgRec atomBiosArg;
-
- if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
- ATOM_POWERPLAY_MODES, &atomBiosArg)
- == ATOM_SUCCESS) {
- }
- }
- else {
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
- }
+ if (!rhdInitPowerPlay(rhdPtr))
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay failed to
initialize\n");
#else
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
#endif
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index f030dd5..39160b6 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -22,6 +22,7 @@
#define RHDSetCCRegIndexRO(ptr, index) RHDRegMask(ptr, CLOCK_CNTL_INDEX,
index, PLL_ADDR|PLL_WR_EN)
#define RHDCCRegWrite(ptr, data) RHDRegWrite(ptr, CLOCK_CNTL_DATA, data)

+void rhdDumpPowerPlayModes(RHDPtr rhdPtr);
void rhdInitPowerManagement_r5xx(RHDPtr rhdPtr);

void
@@ -35,6 +36,25 @@ rhdInitPowerManagement(RHDPtr rhdPtr)

}

+Bool
+rhdInitPowerPlay(RHDPtr rhdPtr)
+{
+ AtomBiosArgRec atomBiosArg;
+
+ if (rhdPtr->atomBIOS) {
+ if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_POWERPLAY_MODES, &atomBiosArg)
+ != ATOM_SUCCESS) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Failed to read PowerPlay
table\n");
+ return FALSE;
+ }
+ }
+ else
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
+
+ rhdDumpPowerPlayModes(rhdPtr);
+ return TRUE;
+}
+

void
rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
@@ -51,6 +71,9 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)

xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Switching to PowerPlay mode %d\n",
mode);

+ if (mode >= rhdPtr->PowerPlayTable.numOfModes)
+ return FALSE;
+
atomBiosArg.clockValue = rhdPtr->PowerPlayTable.modes[mode].engineClock;
if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_ENGINE_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
return FALSE;
@@ -65,4 +88,10 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
return TRUE;
}

+void
+rhdDumpPowerPlayModes(RHDPtr rhdPtr)
+{
+ /* FIXME */
+}
+
#endif /* ATOM_BIOS && ATOM_BIOS_PARSER */
diff --git a/src/rhd_powerplay.h b/src/rhd_powerplay.h
index 4920052..2444ad7 100644
--- a/src/rhd_powerplay.h
+++ b/src/rhd_powerplay.h
@@ -3,6 +3,7 @@
# define _RHD_POWERPLAY_H

void rhdInitPowerManagement(RHDPtr rhdPtr);
+Bool rhdInitPowerPlay(RHDPtr rhdPtr);

Bool rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode);

--
1.5.6.4

From ad9a476b9769f5d599a5217f4a2c3cdfe541a12e Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 14:08:29 -0700
Subject: [PATCH] PowerPlay: move all init logic into own function

---
src/rhd_driver.c | 7 +------
src/rhd_powerplay.c | 7 +++++++
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index d9ec31f..d28fbd7 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -762,12 +762,7 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)
}
#endif

-#ifdef ATOM_BIOS
- if (!rhdInitPowerPlay(rhdPtr))
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay failed to
initialize\n");
-#else
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
-#endif
+ rhdInitPowerPlay(rhdPtr);

#ifdef USE_DRI
RHDDRIPreInit(pScrn);
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 39160b6..bd38b3b 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -39,7 +39,9 @@ rhdInitPowerManagement(RHDPtr rhdPtr)
Bool
rhdInitPowerPlay(RHDPtr rhdPtr)
{
+#ifdef ATOM_BIOS
AtomBiosArgRec atomBiosArg;
+ rhdPtr->PowerPlayTable.numOfModes = 0;

if (rhdPtr->atomBIOS) {
if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_POWERPLAY_MODES, &atomBiosArg)
@@ -53,6 +55,11 @@ rhdInitPowerPlay(RHDPtr rhdPtr)

rhdDumpPowerPlayModes(rhdPtr);
return TRUE;
+
+#else
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
+ return FALSE;
+#endif
}


--
1.5.6.4

From e03edaa4255a5ddd7a4ddf3b3b36a26ec4a89a99 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 14:09:37 -0700
Subject: [PATCH] PowerPlay: store group and mode information

---
src/rhd_atombios.c | 40 +++++++++++++++++++++++++++++++++++++---
src/rhd_powerplay.c | 1 +
2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index fe3b30d..90dcdea 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5166,7 +5166,7 @@ dumpAtomPowerV1Mode(int scrnIndex, ATOM_POWERMODE_INFO
*info, int i)
"PowerPlay mode %d (%s)\n\tengine:%dkHz memory:%dkHz\n"
"\tVoltage GPIO entry:%d Panel Refresh:%d Temp range:%d-%d PCIe
lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
- info->usEngineClock, info->usMemoryClock,
+ info->usEngineClock * 10, info->usMemoryClock * 10,
info->ucVoltageDropIndex,
info->ucSelectedPanel_RefreshRate,
info->ucMinTemperature, info->ucMaxTemperature,
@@ -5253,6 +5253,34 @@ rhdAtomStorePowerModeMisc2(ULONG info, RHDPowerMode
*mode)
}

static void
+rhdAtomStorePowerModeGroup(unsigned long miscInfo, RHDPowerMode *mode)
+{
+ switch ((miscInfo & ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_MASK) >>
ATOM_PM_MISCINFO_POWERPLAY_SETTINGS_GROUP_SHIFT) {
+ case 0: mode->group = RHD_PM_AUTOMATIC; break;
+ case 1: mode->group = RHD_PM_OPTIMAL_BATTERY; break;
+ case 2: mode->group = RHD_PM_HIGH_BATTERY; break;
+ case 3: mode->group = RHD_PM_BALANCED; break;
+ case 4: mode->group = RHD_PM_HIGH_PERFORMANCE; break;
+ case 5: mode->group = RHD_PM_OPTIMAL_PERFORMANCE; break;
+ }
+}
+
+static void
+rhdAtomStorePowerModeMode(unsigned long miscInfo, RHDPowerMode *mode)
+{
+ if (miscInfo & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE)
+ mode->mode = RHD_PM_DEFAULT_MODE;
+ if (miscInfo & ATOM_PM_MISCINFO_OVER_CLOCK_MODE)
+ mode->mode = RHD_PM_OVER_CLOCK_MODE;
+ if (miscInfo & ATOM_PM_MISCINFO_OVER_DRIVE_MODE)
+ mode->mode = RHD_PM_OVER_DRIVE_MODE;
+ if (miscInfo & ATOM_PM_MISCINFO_POWER_SAVING_MODE)
+ mode->mode = RHD_PM_POWER_SAVING_MODE;
+ if (miscInfo & ATOM_PM_MISCINFO_THERMAL_DIODE_MODE)
+ mode->mode = RHD_PM_THERMAL_DIODE_MODE;
+}
+
+static void
rhdAtomStorePowerMode_v1(ATOM_POWERMODE_INFO *info, RHDPowerMode *mode)
{
mode->engineClock = info->usEngineClock * 10;
@@ -5262,6 +5290,8 @@ rhdAtomStorePowerMode_v1(ATOM_POWERMODE_INFO *info,
RHDPowerMode *mode)
mode->clockInfo = 0;
mode->voltageInfo = 0;
mode->capInfo = 0;
+ rhdAtomStorePowerModeGroup(info->ulMiscInfo, mode);
+ rhdAtomStorePowerModeMode(info->ulMiscInfo, mode);
rhdAtomStorePowerModeMisc1(info->ulMiscInfo, mode);
}

@@ -5275,6 +5305,8 @@ rhdAtomStorePowerMode_v2(ATOM_POWERMODE_INFO_V2 *info,
RHDPowerMode *mode)
mode->clockInfo = 0;
mode->voltageInfo = 0;
mode->capInfo = 0;
+ rhdAtomStorePowerModeGroup(info->ulMiscInfo, mode);
+ rhdAtomStorePowerModeMode(info->ulMiscInfo, mode);
rhdAtomStorePowerModeMisc1(info->ulMiscInfo, mode);
rhdAtomStorePowerModeMisc2(info->ulMiscInfo2, mode);
}
@@ -5290,6 +5322,8 @@ rhdAtomStorePowerMode_v3(ATOM_POWERMODE_INFO_V3 *info,
RHDPowerMode *mode)
mode->capInfo = 0;
/* FIXME */
/*mode->voltageDrop.index = info->ucVoltageDropIndex;*/
+ rhdAtomStorePowerModeGroup(info->ulMiscInfo, mode);
+ rhdAtomStorePowerModeMode(info->ulMiscInfo, mode);
rhdAtomStorePowerModeMisc1(info->ulMiscInfo, mode);
rhdAtomStorePowerModeMisc2(info->ulMiscInfo2, mode);
}
@@ -5301,7 +5335,7 @@ dumpAtomPowerV2Mode(int scrnIndex, ATOM_POWERMODE_INFO_V2
*info, int i)
"PowerPlay mode %d (%s)\n\tengine:%dkHz memory:%dkHz\n"
"\tVoltage GPIO entry:%d Panel Refresh:%d Temp range:%d-%d PCIe
lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
- info->ulEngineClock, info->ulMemoryClock,
+ info->ulEngineClock * 10, info->ulMemoryClock * 10,
info->ucVoltageDropIndex,
info->ucSelectedPanel_RefreshRate,
info->ucMinTemperature, info->ucMaxTemperature,
@@ -5318,7 +5352,7 @@ dumpAtomPowerV3Mode(int scrnIndex, ATOM_POWERMODE_INFO_V3
*info, int i)
"\tIndex to core VDCC voltage table:%d Index to VDDCI voltage
table: %d\n"
"Panel Refresh:%d Temp range:%d-%d PCIe lanes:%d\n",
i, rhdAtomPowerPlayTypeName(info->ulMiscInfo),
- info->ulEngineClock, info->ulMemoryClock,
+ info->ulEngineClock * 10, info->ulMemoryClock * 10,
info->ucVoltageDropIndex, info->ucVDDCI_VoltageDropIndex,
info->ucSelectedPanel_RefreshRate,
info->ucMinTemperature, info->ucMaxTemperature,
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index bd38b3b..50d86f1 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -52,6 +52,7 @@ rhdInitPowerPlay(RHDPtr rhdPtr)
}
else
xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
+ rhdAtomStorePowerModeMode(info->ulMiscInfo, mode);

rhdDumpPowerPlayModes(rhdPtr);
return TRUE;
--
1.5.6.4

From 5ddf0ac606b92f37b27519635363e3d074df737a Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 14:46:00 -0700
Subject: [PATCH] PowerPlay: remove bad line from last commit

---
src/rhd_powerplay.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 50d86f1..bd38b3b 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -52,7 +52,6 @@ rhdInitPowerPlay(RHDPtr rhdPtr)
}
else
xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
- rhdAtomStorePowerModeMode(info->ulMiscInfo, mode);

rhdDumpPowerPlayModes(rhdPtr);
return TRUE;
--
1.5.6.4

From 31277863e9437926865cdd0aa3dca406c768ff9a Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 14:53:48 -0700
Subject: [PATCH] PowerPlay: add rhdDumpPowerPlayModes()

---
src/rhd_powerplay.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 55 insertions(+), 1 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index bd38b3b..d387c0c 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -98,7 +98,61 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
void
rhdDumpPowerPlayModes(RHDPtr rhdPtr)
{
- /* FIXME */
+ unsigned char modeNum;
+ int sidx = rhdPtr->scrnIndex;
+ char *groupName, *modeName;
+ unsigned int numOfModes = rhdPtr->PowerPlayTable.numOfModes;
+ RHDPowerMode *mode;
+
+ xf86DrvMsg(sidx, X_INFO, "%d PowerPlay modes available\n", numOfModes);
+
+ for (modeNum = 0; modeNum < numOfModes; modeNum++) {
+ mode = &(rhdPtr->PowerPlayTable.modes[modeNum]);
+
+ switch (mode->group) {
+ case RHD_PM_AUTOMATIC: groupName = "Automatic?"; break;
+ case RHD_PM_OPTIMAL_BATTERY: groupName = "Optimal battery"; break;
+ case RHD_PM_HIGH_BATTERY: groupName = "High battery"; break;
+ case RHD_PM_BALANCED: groupName = "Balanced"; break;
+ case RHD_PM_HIGH_PERFORMANCE: groupName = "High performance"; break;
+ case RHD_PM_OPTIMAL_PERFORMANCE: groupName = "Optimal performance";
break;
+ }
+
+ switch (mode->mode) {
+ case RHD_PM_DEFAULT_MODE: modeName = "default"; break;
+ case RHD_PM_OVER_CLOCK_MODE: modeName = "over clock"; break;
+ case RHD_PM_OVER_DRIVE_MODE: modeName = "over drive"; break;
+ case RHD_PM_POWER_SAVING_MODE: modeName = "power saving"; break;
+ case RHD_PM_THERMAL_DIODE_MODE: modeName = "thermal diode"; break;
+ }
+
+ xf86DrvMsg(sidx, X_INFO,
+ "PowerPlay Mode %d: %s (%s)\n"
+ "\tEngine: %ldkHz Memory: %ldkHz PCIe lanes: %d Voltage drop
index: %d\n"
+ "%s%s%s%s%s%s%s%s"
+ "%s%s%s%s%s"
+ "%s%s%s%s",
+ modeNum, groupName, modeName,
+ mode->engineClock, mode->memoryClock, mode->pcieLanes,
mode->voltageDrop.index,
+ (mode->clockInfo & RHD_PM_USING_MCLK_SRC ? "\t USING_MCLK_SRC\n" :
""),
+ (mode->clockInfo & RHD_PM_USING_SCLK_SRC ? "\t USING_SCLK_SRC\n" :
""),
+ (mode->clockInfo & RHD_PM_ENGINE_CLOCK_CONTRL_EN ? "\t
ENGINE_CLOCK_CONTRL_EN\n" : ""),
+ (mode->clockInfo & RHD_PM_MEMORY_CLOCK_CONTRL_EN ? "\t
MEMORY_CLOCK_CONTRL_EN\n" : ""),
+ (mode->clockInfo & RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN ? "\t
ASIC_REDUCED_SPEED_SCLK_EN\n" : ""),
+ (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_3D_IDLE ? "\t
DYNAMIC_CLOCK_3D_IDLE\n" : ""),
+ (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_2\n" : ""),
+ (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_4\n" : ""),
+ (mode->voltageInfo & RHD_PM_PROGRAM_VOLTAGE ? "\t
PROGRAM_VOLTAGE\n" : ""),
+ (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_SUPPORT ? "\t
VOLTAGE_DROP_SUPPORT\n" : ""),
+ (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH ? "\t
VOLTAGE_DROP_ACTIVE_HIGH\n" : ""),
+ (mode->voltageInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
+ (mode->voltageInfo & RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN ? "\t
VDDCI_DYNAMIC_VOLTAGE_EN\n" : ""),
+ (mode->capInfo & RHD_PM_3D_ACCELERATION_EN ? "\t
3D_ACCELERATION_EN\n" : ""),
+ (mode->capInfo & RHD_PM_MULTI_DISPLAY_SUPPORT ? "\t
MULTI_DISPLAY_SUPPORT\n" : ""),
+ (mode->capInfo & RHD_PM_VIDEO_PLAYBACK_CAPABLE ? "\t
VIDEO_PLAYBACK_CAPABLE\n" : ""),
+ (mode->capInfo & RHD_PM_UVD_SUPPORT_MODE ? "\t UVD_SUPPORT_MODE\n"
: "")
+ );
+ }
}

#endif /* ATOM_BIOS && ATOM_BIOS_PARSER */
--
1.5.6.4

From 8f7522ef80d419ebe129bce323ac60a2065a8fb0 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 16:56:43 -0700
Subject: [PATCH] PowerPlay: expose PowerPlay mode setting via RandR

PowerPlay mode can now be set via POWERPLAY property on PANEL.
---
src/rhd_atomout.c | 9 +++++++-
src/rhd_output.h | 3 +-
src/rhd_powerplay.c | 8 +++++++
src/rhd_powerplay.h | 1 +
src/rhd_randr.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/src/rhd_atomout.c b/src/rhd_atomout.c
index f80568c..b2c7872 100644
--- a/src/rhd_atomout.c
+++ b/src/rhd_atomout.c
@@ -45,6 +45,7 @@
#include "rhd_atombios.h"
#include "rhd_atomout.h"
#include "rhd_biosscratch.h"
+#include "rhd_powerplay.h"

#if defined (ATOM_BIOS) && defined (ATOM_BIOS_PARSER)
struct rhdAtomOutputPrivate {
@@ -568,7 +569,8 @@ atomLVDSPropertyControl(struct rhdOutput *Output,
return FALSE;
switch (Property) {
case RHD_OUTPUT_BACKLIGHT:
- return TRUE;
+ case RHD_OUTPUT_POWERPLAY:
+ return TRUE;
default:
return FALSE;
}
@@ -579,6 +581,9 @@ atomLVDSPropertyControl(struct rhdOutput *Output,
case RHD_OUTPUT_BACKLIGHT:
val->integer = Private->BlLevel;
return TRUE;
+ case RHD_OUTPUT_POWERPLAY:
+ val->integer = rhdPowerPlayGetMode(RHDPTRI(Output));
+ return TRUE;
default:
return FALSE;
}
@@ -590,6 +595,8 @@ atomLVDSPropertyControl(struct rhdOutput *Output,
case RHD_OUTPUT_BACKLIGHT:
atomSetBacklight(Output, val->integer);
return TRUE;
+ case RHD_OUTPUT_POWERPLAY:
+ return rhdPowerPlaySetMode(RHDPTRI(Output),
(RHDPowerPlayMode) val->integer);
default:
return FALSE;
}
diff --git a/src/rhd_output.h b/src/rhd_output.h
index acdd9d8..cfaed80 100644
--- a/src/rhd_output.h
+++ b/src/rhd_output.h
@@ -54,7 +54,8 @@ typedef enum rhdSensedOutput {

enum rhdOutputProperty {
RHD_OUTPUT_BACKLIGHT,
- RHD_OUTPUT_COHERENT
+ RHD_OUTPUT_COHERENT,
+ RHD_OUTPUT_POWERPLAY
};

char *rhdPowerString[4];
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index d387c0c..ffae168 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -71,6 +71,12 @@ rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);
}

+RHDPowerPlayMode
+rhdPowerPlayGetMode(RHDPtr rhdPtr)
+{
+ return rhdPtr->PowerPlayMode;
+}
+
Bool
rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
{
@@ -89,6 +95,8 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_MEMORY_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
return FALSE;

+ rhdPtr->PowerPlayMode = mode;
+
RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_ENGINE_CLOCK, &atomBiosArg);
RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_MEMORY_CLOCK, &atomBiosArg);

diff --git a/src/rhd_powerplay.h b/src/rhd_powerplay.h
index 2444ad7..4bb6b24 100644
--- a/src/rhd_powerplay.h
+++ b/src/rhd_powerplay.h
@@ -5,6 +5,7 @@
void rhdInitPowerManagement(RHDPtr rhdPtr);
Bool rhdInitPowerPlay(RHDPtr rhdPtr);

+RHDPowerPlayMode rhdPowerPlayGetMode(RHDPtr rhdPtr);
Bool rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode);

#endif /* _RHD_POWERPLAY_H */
diff --git a/src/rhd_randr.c b/src/rhd_randr.c
index 1d82613..b0f1e7a 100644
--- a/src/rhd_randr.c
+++ b/src/rhd_randr.c
@@ -108,9 +108,11 @@ typedef struct _rhdRandrOutput {
#define ATOM_PANNING_AREA "RANDR_PANNING_AREA"
#define ATOM_BACKLIGHT "BACKLIGHT"
#define ATOM_COHERENT "COHERENT"
+#define ATOM_POWERPLAY "POWERPLAY"

static Atom atomSignalFormat, atomConnectorType, atomConnectorNumber,
- atomOutputNumber, atomPanningArea, atomBacklight, atomCoherent;
+ atomOutputNumber, atomPanningArea, atomBacklight, atomCoherent,
+ atomPowerPlay;


/* Get RandR property values */
@@ -570,6 +572,32 @@ rhdRROutputCreateResources(xf86OutputPtr out)
__func__, err);
}
}
+ if (rout->Output->Property(rout->Output, rhdPropertyCheck,
RHD_OUTPUT_POWERPLAY, NULL)) {
+ atomPowerPlay = MakeAtom(ATOM_POWERPLAY,
+ sizeof(ATOM_POWERPLAY)-1, TRUE);
+
+ range[0] = 0;
+ range[1] = rhdPtr->PowerPlayTable.numOfModes - 1;
+ err = RRConfigureOutputProperty(out->randr_output, atomPowerPlay,
+ FALSE, TRUE, FALSE, 2, range);
+ if (err != 0)
+ xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR,
+ "RRConfigureOutputProperty error: %d\n", err);
+ else {
+ union rhdPropertyData val;
+
+ if (!rout->Output->Property(rout->Output, rhdPropertyGet,
RHD_OUTPUT_POWERPLAY, &val))
+ val.integer = 255;
+
+ err = RRChangeOutputProperty(out->randr_output, atomPowerPlay,
+ XA_INTEGER, 32, PropModeReplace,
+ 1, &val.integer, FALSE, FALSE);
+ if (err != 0)
+ xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR,
+ "In %s RRChangeOutputProperty error: %d\n",
+ __func__, err);
+ }
+ }
}

val = rhdGetSignalFormat(rout);
@@ -1199,6 +1227,19 @@ rhdRROutputSetProperty(xf86OutputPtr out, Atom property,
}
return FALSE;
}
+ else if (property == atomPowerPlay) {
+ if (value->type != XA_INTEGER || value->format != 32) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "%s: wrong value\n",
__func__);
+ return FALSE;
+ }
+ if (rout->Output->Property) {
+ union rhdPropertyData val;
+ val.integer = *(int*)(value->data);
+ return rout->Output->Property(rout->Output, rhdPropertySet,
+ RHD_OUTPUT_POWERPLAY, &val);
+ }
+ return FALSE;
+ }

return FALSE; /* Others are not mutable */
}
@@ -1238,6 +1279,17 @@ rhdRROutputGetProperty(xf86OutputPtr out, Atom property)
XA_INTEGER, 32, PropModeReplace,
1, &val.Bool, FALSE, FALSE);
}
+ else if (property == atomPowerPlay) {
+ if (rout->Output->Property == NULL)
+ return FALSE;
+
+ if (!rout->Output->Property(rout->Output, rhdPropertyGet,
+ RHD_OUTPUT_POWERPLAY, &val))
+ return FALSE;
+ err = RRChangeOutputProperty(out->randr_output, atomPowerPlay,
+ XA_INTEGER, 32, PropModeReplace,
+ 1, &val.integer, FALSE, FALSE);
+ }

if (err != 0) {
xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "In %s RRChangeOutputProperty
error: %d\n", __func__, err);
--
1.5.6.4

From 8e37e54307b7ed0bcc39fe3918f2c3e7da6a228c Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 17:31:14 -0700
Subject: [PATCH] PowerPlay: indentation

---
src/rhd_powerplay.c | 42 +++++++++++++++++++++---------------------
1 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index ffae168..2b3c9aa 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -137,29 +137,29 @@ rhdDumpPowerPlayModes(RHDPtr rhdPtr)
xf86DrvMsg(sidx, X_INFO,
"PowerPlay Mode %d: %s (%s)\n"
"\tEngine: %ldkHz Memory: %ldkHz PCIe lanes: %d Voltage drop
index: %d\n"
- "%s%s%s%s%s%s%s%s"
- "%s%s%s%s%s"
- "%s%s%s%s",
+ "%s%s%s%s%s%s%s%s"
+ "%s%s%s%s%s"
+ "%s%s%s%s",
modeNum, groupName, modeName,
mode->engineClock, mode->memoryClock, mode->pcieLanes,
mode->voltageDrop.index,
- (mode->clockInfo & RHD_PM_USING_MCLK_SRC ? "\t USING_MCLK_SRC\n" :
""),
- (mode->clockInfo & RHD_PM_USING_SCLK_SRC ? "\t USING_SCLK_SRC\n" :
""),
- (mode->clockInfo & RHD_PM_ENGINE_CLOCK_CONTRL_EN ? "\t
ENGINE_CLOCK_CONTRL_EN\n" : ""),
- (mode->clockInfo & RHD_PM_MEMORY_CLOCK_CONTRL_EN ? "\t
MEMORY_CLOCK_CONTRL_EN\n" : ""),
- (mode->clockInfo & RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN ? "\t
ASIC_REDUCED_SPEED_SCLK_EN\n" : ""),
- (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_3D_IDLE ? "\t
DYNAMIC_CLOCK_3D_IDLE\n" : ""),
- (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_2\n" : ""),
- (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_4\n" : ""),
- (mode->voltageInfo & RHD_PM_PROGRAM_VOLTAGE ? "\t
PROGRAM_VOLTAGE\n" : ""),
- (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_SUPPORT ? "\t
VOLTAGE_DROP_SUPPORT\n" : ""),
- (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH ? "\t
VOLTAGE_DROP_ACTIVE_HIGH\n" : ""),
- (mode->voltageInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
- (mode->voltageInfo & RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN ? "\t
VDDCI_DYNAMIC_VOLTAGE_EN\n" : ""),
- (mode->capInfo & RHD_PM_3D_ACCELERATION_EN ? "\t
3D_ACCELERATION_EN\n" : ""),
- (mode->capInfo & RHD_PM_MULTI_DISPLAY_SUPPORT ? "\t
MULTI_DISPLAY_SUPPORT\n" : ""),
- (mode->capInfo & RHD_PM_VIDEO_PLAYBACK_CAPABLE ? "\t
VIDEO_PLAYBACK_CAPABLE\n" : ""),
- (mode->capInfo & RHD_PM_UVD_SUPPORT_MODE ? "\t UVD_SUPPORT_MODE\n"
: "")
- );
+ (mode->clockInfo & RHD_PM_USING_MCLK_SRC ? "\t USING_MCLK_SRC\n"
: ""),
+ (mode->clockInfo & RHD_PM_USING_SCLK_SRC ? "\t USING_SCLK_SRC\n"
: ""),
+ (mode->clockInfo & RHD_PM_ENGINE_CLOCK_CONTRL_EN ? "\t
ENGINE_CLOCK_CONTRL_EN\n" : ""),
+ (mode->clockInfo & RHD_PM_MEMORY_CLOCK_CONTRL_EN ? "\t
MEMORY_CLOCK_CONTRL_EN\n" : ""),
+ (mode->clockInfo & RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN ? "\t
ASIC_REDUCED_SPEED_SCLK_EN\n" : ""),
+ (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_3D_IDLE ? "\t
DYNAMIC_CLOCK_3D_IDLE\n" : ""),
+ (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_2\n" : ""),
+ (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_4\n" : ""),
+ (mode->voltageInfo & RHD_PM_PROGRAM_VOLTAGE ? "\t
PROGRAM_VOLTAGE\n" : ""),
+ (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_SUPPORT ? "\t
VOLTAGE_DROP_SUPPORT\n" : ""),
+ (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH ? "\t
VOLTAGE_DROP_ACTIVE_HIGH\n" : ""),
+ (mode->voltageInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
+ (mode->voltageInfo & RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN ? "\t
VDDCI_DYNAMIC_VOLTAGE_EN\n" : ""),
+ (mode->capInfo & RHD_PM_3D_ACCELERATION_EN ? "\t
3D_ACCELERATION_EN\n" : ""),
+ (mode->capInfo & RHD_PM_MULTI_DISPLAY_SUPPORT ? "\t
MULTI_DISPLAY_SUPPORT\n" : ""),
+ (mode->capInfo & RHD_PM_VIDEO_PLAYBACK_CAPABLE ? "\t
VIDEO_PLAYBACK_CAPABLE\n" : ""),
+ (mode->capInfo & RHD_PM_UVD_SUPPORT_MODE ? "\t
UVD_SUPPORT_MODE\n" : "")
+ );
}
}

--
1.5.6.4

From 18b9c12631dee6be2c037ad9b2a2e4ad91e2479e Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 30 Sep 2008 17:44:16 -0700
Subject: [PATCH] PowerPlay: bring everything down before applying PowerPlay mode

Memory clock is potentially changed during mode switch, which will cause
corruption and lock-up.
---
src/rhd_powerplay.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 2b3c9aa..522208b 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -15,6 +15,8 @@
#include "rhd_powerplay.h"
#include "rhd_regs.h"
#include "rhd_mc.h"
+#include "rhd_vga.h"
+#include "xf86Crtc.h"
#if defined (ATOM_BIOS) && defined (ATOM_BIOS_PARSER)
# include "rhd_atombios.h"

@@ -81,12 +83,23 @@ Bool
rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
{
AtomBiosArgRec atomBiosArg;
+ ScrnInfoPtr pScrn = xf86Screens[rhdPtr->scrnIndex];

xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Switching to PowerPlay mode %d\n",
mode);

+ if (!rhdPtr->randr) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "Needs RandR support to switch
PowerPlay mode\n");
+ return FALSE;
+ }
+
if (mode >= rhdPtr->PowerPlayTable.numOfModes)
return FALSE;

+ /* Take screens down */
+ RHDVGADisable(rhdPtr);
+ RHDAllIdle(pScrn);
+
+
atomBiosArg.clockValue = rhdPtr->PowerPlayTable.modes[mode].engineClock;
if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_ENGINE_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
return FALSE;
@@ -100,6 +113,15 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_ENGINE_CLOCK, &atomBiosArg);
RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_MEMORY_CLOCK, &atomBiosArg);

+ /* Bring screens up again */
+ RHDMCSetup(rhdPtr);
+ xf86SetDesiredModes(pScrn);
+ /*
+ else
+ rhdSetMode(pScrn, mode);
+ rhdModeInit(pScrn, pScrn->currentMode);
+ */
+
return TRUE;
}

--
1.5.6.4

From 7f1325d38ebde1cf10a969327a88ce1b86319e54 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 13:23:03 -0700
Subject: [PATCH] PowerPlay: make POWERPLAY property available on all connectors

---
src/rhd_atomout.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/rhd_atomout.c b/src/rhd_atomout.c
index b2c7872..d1cd588 100644
--- a/src/rhd_atomout.c
+++ b/src/rhd_atomout.c
@@ -619,6 +619,7 @@ atomTMDSPropertyControl(struct rhdOutput *Output,
case rhdPropertyCheck:
switch (Property) {
case RHD_OUTPUT_COHERENT:
+ case RHD_OUTPUT_POWERPLAY:
return TRUE;
default:
return FALSE;
--
1.5.6.4

From 61d9816ae103d812b06cb1b78d761b98d50c34aa Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 13:50:07 -0700
Subject: [PATCH] PowerPlay: cleanup rhdPowerPlaySetMode()

Separated engine and memory clock setting into rhdSetEngineClock() and
rhdSetMemoryClock(), plus some trivial things.
---
src/rhd_powerplay.c | 37 ++++++++++++++++++++++++-------------
src/rhd_powerplay.h | 5 +++++
2 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 522208b..3d9a62c 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -80,12 +80,13 @@ rhdPowerPlayGetMode(RHDPtr rhdPtr)
}

Bool
-rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
+rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)
{
AtomBiosArgRec atomBiosArg;
ScrnInfoPtr pScrn = xf86Screens[rhdPtr->scrnIndex];
+ RHDPowerMode *mode;

- xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Switching to PowerPlay mode %d\n",
mode);
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Switching to PowerPlay mode %d\n",
modeNum);

if (!rhdPtr->randr) {
xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "Needs RandR support to switch
PowerPlay mode\n");
@@ -95,20 +96,19 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
if (mode >= rhdPtr->PowerPlayTable.numOfModes)
return FALSE;

+ mode = &rhdPtr->PowerPlayTable.modes[modeNum];
+
/* Take screens down */
RHDVGADisable(rhdPtr);
RHDAllIdle(pScrn);

-
- atomBiosArg.clockValue = rhdPtr->PowerPlayTable.modes[mode].engineClock;
- if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_ENGINE_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
+ if (!rhdSetEngineClock(rhdPtr, mode->engineClock))
return FALSE;

- atomBiosArg.clockValue = rhdPtr->PowerPlayTable.modes[mode].memoryClock;
- if (!RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_MEMORY_CLOCK, &atomBiosArg) == ATOM_SUCCESS)
+ if (!rhdSetMemoryClock(rhdPtr, mode->memoryClock))
return FALSE;

- rhdPtr->PowerPlayMode = mode;
+ rhdPtr->PowerPlayMode = modeNum;

RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_ENGINE_CLOCK, &atomBiosArg);
RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_MEMORY_CLOCK, &atomBiosArg);
@@ -116,15 +116,26 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode)
/* Bring screens up again */
RHDMCSetup(rhdPtr);
xf86SetDesiredModes(pScrn);
- /*
- else
- rhdSetMode(pScrn, mode);
- rhdModeInit(pScrn, pScrn->currentMode);
- */

return TRUE;
}

+Bool
+rhdSetEngineClock(RHDPtr rhdPtr, unsigned long engineClock)
+{
+ AtomBiosArgRec arg;
+ arg.clockValue = engineClock;
+ return RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_ENGINE_CLOCK, &arg) == ATOM_SUCCESS;
+}
+
+Bool
+rhdSetMemoryClock(RHDPtr rhdPtr, unsigned long memoryClock)
+{
+ AtomBiosArgRec arg;
+ arg.clockValue = memoryClock;
+ return RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_MEMORY_CLOCK, &arg) == ATOM_SUCCESS;
+}
+
void
rhdDumpPowerPlayModes(RHDPtr rhdPtr)
{
diff --git a/src/rhd_powerplay.h b/src/rhd_powerplay.h
index 4bb6b24..46b8f6f 100644
--- a/src/rhd_powerplay.h
+++ b/src/rhd_powerplay.h
@@ -5,8 +5,13 @@
void rhdInitPowerManagement(RHDPtr rhdPtr);
Bool rhdInitPowerPlay(RHDPtr rhdPtr);

+#ifdef ATOM_BIOS
RHDPowerPlayMode rhdPowerPlayGetMode(RHDPtr rhdPtr);
Bool rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode mode);

+Bool rhdSetEngineClock(RHDPtr rhdPtr, unsigned long clock);
+Bool rhdSetMemoryClock(RHDPtr rhdPtr, unsigned long clock);
+#endif /* ATOMBIOS */
+
#endif /* _RHD_POWERPLAY_H */

--
1.5.6.4

From 42a75eebbd4539b7ea366ffb14006ed41dc72b54 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 16:54:25 -0700
Subject: [PATCH] PowerPlay: fix error in last commit

---
src/rhd_powerplay.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 3d9a62c..436510c 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -93,7 +93,7 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)
return FALSE;
}

- if (mode >= rhdPtr->PowerPlayTable.numOfModes)
+ if (modeNum >= rhdPtr->PowerPlayTable.numOfModes)
return FALSE;

mode = &rhdPtr->PowerPlayTable.modes[modeNum];
--
1.5.6.4

From 55a8a5b388694cdf6ffe108654f730c2a0f6d00b Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 18:18:28 -0700
Subject: [PATCH] PowerPlay: no need to call RHDVGADisable() before switching
mode

---
src/rhd_powerplay.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 436510c..4536720 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -99,7 +99,6 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)
mode = &rhdPtr->PowerPlayTable.modes[modeNum];

/* Take screens down */
- RHDVGADisable(rhdPtr);
RHDAllIdle(pScrn);

if (!rhdSetEngineClock(rhdPtr, mode->engineClock))
--
1.5.6.4

From 23e3df32fcf993f0504fc3218dd64f3fe598ca7a Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 18:19:42 -0700
Subject: [PATCH] PowerPlay: PCIe lane width switching

---
src/rhd_powerplay.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/rhd_powerplay.h | 2 +
src/rhd_regs.h | 24 +++++++++++++++++++++
3 files changed, 84 insertions(+), 0 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 4536720..4e4a549 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -24,6 +24,12 @@
#define RHDSetCCRegIndexRO(ptr, index) RHDRegMask(ptr, CLOCK_CNTL_INDEX,
index, PLL_ADDR|PLL_WR_EN)
#define RHDCCRegWrite(ptr, data) RHDRegWrite(ptr, CLOCK_CNTL_DATA, data)

+#define RHDSetPCIERegIndex(ptr, index) _RHDRegWrite((ptr)->scrnIndex,
R5_PCIE_INDEX, ((index) & R5_PCIE_INDEX_MASK))
+#define RHDPCIERegWrite(ptr, value) RHDRegWrite(ptr, R5_PCIE_DATA, (value))
+#define RHDPCIERegMask(ptr, value, mask) RHDRegMask(ptr, R5_PCIE_DATA,
(value), (mask))
+#define RHDPCIERegRead(ptr) RHDRegRead(ptr, R5_PCIE_DATA)
+
+
void rhdDumpPowerPlayModes(RHDPtr rhdPtr);
void rhdInitPowerManagement_r5xx(RHDPtr rhdPtr);

@@ -101,6 +107,8 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)
/* Take screens down */
RHDAllIdle(pScrn);

+ rhdSetPCIeLanes(rhdPtr, mode->pcieLanes);
+
if (!rhdSetEngineClock(rhdPtr, mode->engineClock))
return FALSE;

@@ -135,6 +143,56 @@ rhdSetMemoryClock(RHDPtr rhdPtr, unsigned long memoryClock)
return RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_SET_MEMORY_CLOCK, &arg) == ATOM_SUCCESS;
}

+Bool
+rhdSetPCIeLanes(RHDPtr rhdPtr, unsigned char numLanes)
+{
+ unsigned long regValue = 0;
+ unsigned long lanesRead;
+ switch (numLanes) {
+ case 0: regValue = LC_LINK_WIDTH_X0; break;
+ case 1: regValue = LC_LINK_WIDTH_X1; break;
+ case 2: regValue = LC_LINK_WIDTH_X2; break;
+ case 4: regValue = LC_LINK_WIDTH_X4; break;
+ case 8: regValue = LC_LINK_WIDTH_X8; break;
+ case 12: regValue = LC_LINK_WIDTH_X12; break;
+ case 16: regValue = LC_LINK_WIDTH_X16; break;
+ defualt:
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Invalied PCIe mode: x%d\n",
numLanes);
+ return FALSE;
+ }
+
+ RHDSetPCIERegIndex(rhdPtr, R5_PCIE_LC_LINK_WIDTH_CNTL);
+
+ lanesRead = (RHDPCIERegRead(rhdPtr) >> LC_LINK_WIDTH_RD_SHIFT) &
LC_LINK_WIDTH_MASK;
+ /*xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Read PCIe width bits: %1X\n",
lanesRead);*/
+ /* x16 seems to show up as x0 when read */
+ if (regValue == lanesRead || (regValue == LC_LINK_WIDTH_X16 && lanesRead
== 0)) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "PCIe already set to x%d\n",
numLanes);
+ return TRUE;
+ }
+
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Setting PCIe to x%d\n", numLanes);
+
+ /* This seems to work; undocumented in register ref */
+ RHDPCIERegWrite(rhdPtr, regValue | LC_RECONFIG_NOW);
+
+ /* wait for register to settle */
+ do {
+ lanesRead = (RHDPCIERegRead(rhdPtr) >> LC_LINK_WIDTH_RD_SHIFT) &
LC_LINK_WIDTH_MASK;
+ usleep(1000);
+ } while (lanesRead == LC_LINK_WIDTH_MASK);
+
+ /*xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Read PCIe width bits: %1X\n",
lanesRead);*/
+ if (regValue == lanesRead || (regValue == LC_LINK_WIDTH_X16 && lanesRead
== 0)) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "PCIe successfully set to
x%d\n", numLanes);
+ return TRUE;
+ }
+ else {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Failed to set PCIe mode\n");
+ return FALSE;
+ }
+}
+
void
rhdDumpPowerPlayModes(RHDPtr rhdPtr)
{
diff --git a/src/rhd_powerplay.h b/src/rhd_powerplay.h
index 46b8f6f..fff68f1 100644
--- a/src/rhd_powerplay.h
+++ b/src/rhd_powerplay.h
@@ -11,6 +11,8 @@ Bool rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode
mode);

Bool rhdSetEngineClock(RHDPtr rhdPtr, unsigned long clock);
Bool rhdSetMemoryClock(RHDPtr rhdPtr, unsigned long clock);
+
+Bool rhdSetPCIeLanes(RHDPtr rhdPtr, unsigned char numLanes);
#endif /* ATOMBIOS */

#endif /* _RHD_POWERPLAY_H */
diff --git a/src/rhd_regs.h b/src/rhd_regs.h
index 96ac0db..d43f785 100644
--- a/src/rhd_regs.h
+++ b/src/rhd_regs.h
@@ -680,6 +680,30 @@ enum _r5xxCLKINDRegs {
R5_CG_TC_JTAG_1 = 0x39
};

+/* Registers and offsets related to PCIe on r5xx */
+enum _r5xxPCIERegs {
+ R5_PCIE_INDEX = 0x30,
+ R5_PCIE_DATA = 0x34,
+ R5_PCIE_LC_LINK_WIDTH_CNTL = 0xA2,
+ R5_PCIE_P_CNTL = 0xB0
+};
+#define R5_PCIE_INDEX_MASK 0x3FF
+
+enum R5_PCIE_LC_LINK_WIDTH_CNTL_BITS {
+ LC_LINK_WIDTH_X0 = 0,
+ LC_LINK_WIDTH_X1 = 1,
+ LC_LINK_WIDTH_X2 = 2,
+ LC_LINK_WIDTH_X4 = 3,
+ LC_LINK_WIDTH_X8 = 4,
+ LC_LINK_WIDTH_X12 = 5,
+ LC_LINK_WIDTH_X16 = 6,
+ LC_LINK_WIDTH_MASK = 0x7,
+ LC_RECONFIG_NOW = 1 << 8,
+ LC_RECONFIG_LATER = 1 << 9,
+ LC_SHORT_RECONFIG_EN = 1 << 11
+};
+#define LC_LINK_WIDTH_RD_SHIFT 4
+
enum _r6xxRegs {
/* MCLK */
R6_MCLK_PWRMGT_CNTL = 0x620,
--
1.5.6.4

From d712c13a77d2100018256c34aadf453c0a9ef740 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 22:51:05 -0700
Subject: [PATCH] PowerPlay: separate rhdSetPCIeLanes into r5xx specific version

---
src/rhd_powerplay.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 4e4a549..6af42a7 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -33,6 +33,8 @@
void rhdDumpPowerPlayModes(RHDPtr rhdPtr);
void rhdInitPowerManagement_r5xx(RHDPtr rhdPtr);

+Bool rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char numLanes);
+
void
rhdInitPowerManagement(RHDPtr rhdPtr)
{
@@ -146,6 +148,17 @@ rhdSetMemoryClock(RHDPtr rhdPtr, unsigned long memoryClock)
Bool
rhdSetPCIeLanes(RHDPtr rhdPtr, unsigned char numLanes)
{
+ if (rhdPtr->ChipSet < RHD_R600)
+ return rhdSetPCIeLanes_r5xx(rhdPtr, numLanes);
+ else {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PICe lane width setting now
supported on r600\n");
+ return FALSE;
+ }
+}
+
+Bool
+rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char numLanes)
+{
unsigned long regValue = 0;
unsigned long lanesRead;
switch (numLanes) {
--
1.5.6.4

From 58785da6014b6f57943ed547b96ef1c41154d79c Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Wed, 1 Oct 2008 22:59:35 -0700
Subject: [PATCH] PowerPlay: RHDMCSetup() call not needed for mode switch

---
src/rhd_powerplay.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 6af42a7..c97842f 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -106,7 +106,6 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)

mode = &rhdPtr->PowerPlayTable.modes[modeNum];

- /* Take screens down */
RHDAllIdle(pScrn);

rhdSetPCIeLanes(rhdPtr, mode->pcieLanes);
@@ -123,7 +122,6 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)
RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_MEMORY_CLOCK, &atomBiosArg);

/* Bring screens up again */
- RHDMCSetup(rhdPtr);
xf86SetDesiredModes(pScrn);

return TRUE;
--
1.5.6.4

From 05f003ad7371c079bab282fc178f6a9ddaa5f765 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Thu, 2 Oct 2008 17:30:45 -0700
Subject: [PATCH] PowerPlay: move power management init to before PowerPlay init

---
src/rhd_driver.c | 5 ++---
src/rhd_powerplay.c | 8 ++++----
src/rhd_powerplay.h | 2 +-
3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index d28fbd7..281629b 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -762,6 +762,8 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)
}
#endif

+ /* Initialize power management */
+ rhdInitPowerManagement(rhdPtr);
rhdInitPowerPlay(rhdPtr);

#ifdef USE_DRI
@@ -1252,9 +1254,6 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv)
RADEONInitVideo(pScreen);
}

- /* Initialize power management */
- rhdInitPowerManagement(rhdPtr);
-
/* Switch PowerPlay mode */
rhdPowerPlaySetMode(rhdPtr, rhdPtr->defaultPowerPlayMode.val.integer);

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index c97842f..a9b7f29 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -31,15 +31,15 @@


void rhdDumpPowerPlayModes(RHDPtr rhdPtr);
-void rhdInitPowerManagement_r5xx(RHDPtr rhdPtr);
+Bool rhdInitPowerManagement_r5xx(RHDPtr rhdPtr);

Bool rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char numLanes);

-void
+Bool
rhdInitPowerManagement(RHDPtr rhdPtr)
{
if (rhdPtr->ChipSet < RHD_R600) {
- rhdInitPowerManagement_r5xx(rhdPtr);
+ return rhdInitPowerManagement_r5xx(rhdPtr);
}
else
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Power management not supported
on R600 and greater");
@@ -73,7 +73,7 @@ rhdInitPowerPlay(RHDPtr rhdPtr)
}


-void
+Bool
rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
{
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");
diff --git a/src/rhd_powerplay.h b/src/rhd_powerplay.h
index fff68f1..a485329 100644
--- a/src/rhd_powerplay.h
+++ b/src/rhd_powerplay.h
@@ -2,7 +2,7 @@
#ifndef _RHD_POWERPLAY_H
# define _RHD_POWERPLAY_H

-void rhdInitPowerManagement(RHDPtr rhdPtr);
+Bool rhdInitPowerManagement(RHDPtr rhdPtr);
Bool rhdInitPowerPlay(RHDPtr rhdPtr);

#ifdef ATOM_BIOS
--
1.5.6.4

From d9ea7469efd7e4561aba7da88b3973225f5deabc Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Thu, 2 Oct 2008 17:31:50 -0700
Subject: [PATCH] PowerPlay: dump VoltageObjectInfo from table

---
src/rhd_atombios.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/rhd_atombios.h | 1 +
src/rhd_powerplay.c | 12 ++++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 90dcdea..e9d2432 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -139,6 +139,9 @@ rhdAtomGetEngineClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios
static AtomBiosResult
rhdAtomGetMemoryClock(atomBiosHandlePtr handle, AtomBiosRequestID func,
AtomBiosArgPtr data);

+static AtomBiosResult
+rhdAtomVoltageObjectInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID
func, AtomBiosArgPtr data);
+
enum msgDataFormat {
MSG_FORMAT_NONE,
MSG_FORMAT_HEX,
@@ -292,6 +295,8 @@ struct atomBIOSRequests {
"Get Engine Clock", MSG_FORMAT_DEC},
{ATOM_GET_MEMORY_CLOCK, rhdAtomGetMemoryClock,
"Get Memory Clock", MSG_FORMAT_DEC},
+ {ATOM_GET_VOLTAGE_OBJECT_INFO, rhdAtomVoltageObjectInfoQuery,
+ "VoltageObjectInfo contents", MSG_FORMAT_NONE},
{FUNC_END, NULL,
NULL, MSG_FORMAT_NONE}
};
@@ -5617,6 +5622,48 @@ rhdAtomGetMemoryClock(atomBiosHandlePtr handle,
AtomBiosRequestID func, AtomBios
return ATOM_FAILED;
}

+static AtomBiosResult
+rhdAtomVoltageObjectInfoQuery(atomBiosHandlePtr handle, AtomBiosRequestID
func, AtomBiosArgPtr data)
+{
+ atomDataTablesPtr atomDataPtr;
+ CARD8 crev, frev;
+ ATOM_VOLTAGE_OBJECT *obj;
+ int i;
+
+ RHDFUNC(handle);
+
+ atomDataPtr = handle->atomDataPtr;
+
+ if
(!rhdAtomGetTableRevisionAndSize(&(atomDataPtr->VoltageObjectInfo->sHeader),
+ &crev,&frev,NULL)) {
+ return ATOM_NOT_IMPLEMENTED;
+ }
+
+ for (i = 0; i < 3; i++) {
+ obj = &(atomDataPtr->VoltageObjectInfo->asVoltageObj[i]);
+ xf86DrvMsg(handle->scrnIndex, X_INFO, "Voltage object %d\n"
+ "\tControl: 0x%02X line:0x%02X addr:0x%02X offset:0x%02X\n"
+ "\t GPIO Pin - AIndex:0x%04X BitShift: %d %d %d %d %d %d %d
%d\n",
+ "\t Voltage formula: base %dmV %d %smV steps BaseVID:%d\n",
+ i,
+ obj->asControl.ucVoltageControlId,
+ obj->asControl.ucVoltageControlI2cLine,
+ obj->asControl.ucVoltageControlAddress,
+ obj->asControl.ucVoltageControlOffset,
+ obj->asControl.usGpioPin_AIndex,
+ obj->asControl.ucGpioPinBitShift[0],
obj->asControl.ucGpioPinBitShift[1],
+ obj->asControl.ucGpioPinBitShift[2],
obj->asControl.ucGpioPinBitShift[3],
+ obj->asControl.ucGpioPinBitShift[4],
obj->asControl.ucGpioPinBitShift[5],
+ obj->asControl.ucGpioPinBitShift[6],
obj->asControl.ucGpioPinBitShift[7],
+ obj->asFormula.usVoltageBaseLevel,
+ obj->asFormula.usVoltageStep,
+ (obj->asFormula.ucFlag | 0x01 ? "0.5" : "1"),
+ obj->asFormula.ucBaseVID);
+ }
+
+ return ATOM_SUCCESS;
+}
+
/*
*
*/
diff --git a/src/rhd_atombios.h b/src/rhd_atombios.h
index 93cf88b..d767760 100644
--- a/src/rhd_atombios.h
+++ b/src/rhd_atombios.h
@@ -106,6 +106,7 @@ typedef enum _AtomBiosRequestID {
ATOM_SET_MEMORY_CLOCK,
ATOM_GET_ENGINE_CLOCK,
ATOM_GET_MEMORY_CLOCK,
+ ATOM_GET_VOLTAGE_OBJECT_INFO,
FUNC_END
} AtomBiosRequestID;

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index a9b7f29..0a5595c 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -76,6 +76,18 @@ rhdInitPowerPlay(RHDPtr rhdPtr)
Bool
rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
{
+ AtomBiosArgRec atomBiosArg;
+ /* Read VoltageObjectInfo from table */
+ if (rhdPtr->atomBIOS) {
+ if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_VOLTAGE_OBJECT_INFO, &atomBiosArg)
+ != ATOM_SUCCESS) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Failed to read
VoltageObjectInfo\n");
+ return FALSE;
+ }
+ }
+ else
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
+
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");
RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);
--
1.5.6.4

From 6848205137056da226da012c96946106e7d881cd Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Thu, 2 Oct 2008 17:44:16 -0700
Subject: [PATCH] PowerPlay: fix syntax error in VoltageObjectInfo dump

---
src/rhd_atombios.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index e9d2432..aeab4d3 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5643,7 +5643,7 @@ rhdAtomVoltageObjectInfoQuery(atomBiosHandlePtr handle,
AtomBiosRequestID func,
obj = &(atomDataPtr->VoltageObjectInfo->asVoltageObj[i]);
xf86DrvMsg(handle->scrnIndex, X_INFO, "Voltage object %d\n"
"\tControl: 0x%02X line:0x%02X addr:0x%02X offset:0x%02X\n"
- "\t GPIO Pin - AIndex:0x%04X BitShift: %d %d %d %d %d %d %d
%d\n",
+ "\t GPIO Pin - AIndex:0x%04X BitShift: %d %d %d %d %d %d %d %d\n"
"\t Voltage formula: base %dmV %d %smV steps BaseVID:%d\n",
i,
obj->asControl.ucVoltageControlId,
--
1.5.6.4

From 0cc0005bfdb5b276f9f245077dbad287ec2196b8 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Fri, 3 Oct 2008 16:23:56 -0700
Subject: [PATCH] Power Management: set a few registers to values that may help
with PM

---
src/rhd_powerplay.c | 13 +++++++++++++
src/rhd_regs.h | 18 ++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 0a5595c..b359b59 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -23,6 +23,8 @@
#define RHDSetCCRegIndex(ptr, index) RHDRegMask(ptr, CLOCK_CNTL_INDEX,
index|PLL_WR_EN, PLL_ADDR|PLL_WR_EN)
#define RHDSetCCRegIndexRO(ptr, index) RHDRegMask(ptr, CLOCK_CNTL_INDEX,
index, PLL_ADDR|PLL_WR_EN)
#define RHDCCRegWrite(ptr, data) RHDRegWrite(ptr, CLOCK_CNTL_DATA, data)
+#define RHDCCRegMask(ptr, data, mask) RHDRegMask(ptr, CLOCK_CNTL_DATA, (data),
(mask))
+#define RHDCCRegRead(ptr) RHDRegRead(ptr, CLOCK_CNTL_DATA)

#define RHDSetPCIERegIndex(ptr, index) _RHDRegWrite((ptr)->scrnIndex,
R5_PCIE_INDEX, ((index) & R5_PCIE_INDEX_MASK))
#define RHDPCIERegWrite(ptr, value) RHDRegWrite(ptr, R5_PCIE_DATA, (value))
@@ -91,6 +93,17 @@ rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");
RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);
+
+ /* Enable clock gating? */
+ RHDSetCCRegIndex(rhdPtr, R5_DYN_PWRMGT_SCLK_CNTL);
+ RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN,
+ ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN);
+
+ /* Ties voltage to SCLK? */
+ RHDSetCCRegIndex(rhdPtr, R5_DYN_SCLK_VOL_CNTL);
+ RHDCCRegMask(rhdPtr, IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC,
IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC);
+
+ return TRUE;
}

RHDPowerPlayMode
diff --git a/src/rhd_regs.h b/src/rhd_regs.h
index d43f785..0ca6945 100644
--- a/src/rhd_regs.h
+++ b/src/rhd_regs.h
@@ -680,6 +680,24 @@ enum _r5xxCLKINDRegs {
R5_CG_TC_JTAG_1 = 0x39
};

+enum R5_SCLK_PWRMGT_CNTL_BITS {
+ SCLK_PWRMGT_OFF = 1 << 0,
+ SCLK_TURNOFF = 1 << 1,
+ SPLL_TURNOFF = 1 << 2
+};
+
+enum R5_DYN_PWRMGT_SCKL_CNTL_BITS {
+ ENGINE_DYNCLK_MODE = 1 << 0,
+ STATIC_SCREEN_EN = 1 << 20,
+ CLIENT_SELECT_POWER_EN = 1 << 21,
+ SW_NORMAL_POWER = 1 << 24
+};
+
+enum R5_DYN_SCLK_VOL_CNTL_BITS {
+ IO_CG_VOLTAGE_DROP = 1 << 0,
+ VOLTAGE_DROP_SYNC = 1 << 2
+};
+
/* Registers and offsets related to PCIe on r5xx */
enum _r5xxPCIERegs {
R5_PCIE_INDEX = 0x30,
--
1.5.6.4

From 27f678a2659bd444bdfa0d9d13caa106535bb09f Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Fri, 3 Oct 2008 16:36:01 -0700
Subject: [PATCH] PowerPlay: trivial cosmetic, typo, and message order fixes

---
src/rhd_atombios.c | 2 +-
src/rhd_powerplay.c | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index aeab4d3..b33cfd7 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -296,7 +296,7 @@ struct atomBIOSRequests {
{ATOM_GET_MEMORY_CLOCK, rhdAtomGetMemoryClock,
"Get Memory Clock", MSG_FORMAT_DEC},
{ATOM_GET_VOLTAGE_OBJECT_INFO, rhdAtomVoltageObjectInfoQuery,
- "VoltageObjectInfo contents", MSG_FORMAT_NONE},
+ "VoltageObjectInfo contents", MSG_FORMAT_NONE},
{FUNC_END, NULL,
NULL, MSG_FORMAT_NONE}
};
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index b359b59..a09f505 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -46,6 +46,7 @@ rhdInitPowerManagement(RHDPtr rhdPtr)
else
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Power management not supported
on R600 and greater");

+ return FALSE;
}

Bool
@@ -79,6 +80,9 @@ Bool
rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
{
AtomBiosArgRec atomBiosArg;
+
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");
+
/* Read VoltageObjectInfo from table */
if (rhdPtr->atomBIOS) {
if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_VOLTAGE_OBJECT_INFO, &atomBiosArg)
@@ -88,9 +92,8 @@ rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
}
}
else
- xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Could not read
VoltageObjectInfo: requires AtomBIOS\n");

- xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");
RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);

@@ -192,7 +195,7 @@ rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char numLanes)
case 8: regValue = LC_LINK_WIDTH_X8; break;
case 12: regValue = LC_LINK_WIDTH_X12; break;
case 16: regValue = LC_LINK_WIDTH_X16; break;
- defualt:
+ default:
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Invalied PCIe mode: x%d\n",
numLanes);
return FALSE;
}
--
1.5.6.4

From c675c1c19c612eafb6b174a429091374a72128f8 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Fri, 3 Oct 2008 17:27:19 -0700
Subject: [PATCH] PowerPlay: clean-up default PowerPlay mode setting code

No longer attempt to mode switch regardless whether it's actually set in
xorg.conf.

RandR property is also properly initialized to the AtomBIOS table
default mode.
---
src/rhd.h | 2 +-
src/rhd_driver.c | 5 +++--
src/rhd_powerplay.c | 11 +++++++++++
3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/rhd.h b/src/rhd.h
index 6f06f1b..8754ace 100644
--- a/src/rhd.h
+++ b/src/rhd.h
@@ -196,7 +196,7 @@ enum AccelMethod {

/* PowerPlay related structs */
typedef unsigned char RHDPowerPlayMode;
-#define RHD_POWERPLAY_USE_DEFAULT_MODE 255
+#define RHD_POWERPLAY_USE_ATOM_DEFAULT 255
#define RHD_POWERPLAY_MAX_MODES 8

enum RHDPowerModeGroup {
diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index 281629b..47c62c4 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -1020,7 +1020,7 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)

/* Handle PowerPlayMode option */
if (!rhdPtr->defaultPowerPlayMode.set) {
- rhdPtr->defaultPowerPlayMode.val.integer =
RHD_POWERPLAY_USE_DEFAULT_MODE;
+ rhdPtr->defaultPowerPlayMode.val.integer =
RHD_POWERPLAY_USE_ATOM_DEFAULT;
}
else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Setting default PowerPlay mode
to %d\n", rhdPtr->defaultPowerPlayMode.val.integer);
@@ -1255,7 +1255,8 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
char **argv)
}

/* Switch PowerPlay mode */
- rhdPowerPlaySetMode(rhdPtr, rhdPtr->defaultPowerPlayMode.val.integer);
+ if (rhdPtr->defaultPowerPlayMode.val.integer !=
RHD_POWERPLAY_USE_ATOM_DEFAULT)
+ rhdPowerPlaySetMode(rhdPtr, rhdPtr->defaultPowerPlayMode.val.integer);

/* Wrap the current CloseScreen function */
rhdPtr->CloseScreen = pScreen->CloseScreen;
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index a09f505..a926090 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -54,6 +54,8 @@ rhdInitPowerPlay(RHDPtr rhdPtr)
{
#ifdef ATOM_BIOS
AtomBiosArgRec atomBiosArg;
+ int i;
+
rhdPtr->PowerPlayTable.numOfModes = 0;

if (rhdPtr->atomBIOS) {
@@ -66,6 +68,15 @@ rhdInitPowerPlay(RHDPtr rhdPtr)
else
xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PowerPlay disabled: requires
AtomBIOS\n");

+ /* Find what the default mode is */
+ for (i = 0; i < rhdPtr->PowerPlayTable.numOfModes; i++) {
+ if (rhdPtr->PowerPlayTable.modes[i].mode == RHD_PM_DEFAULT_MODE) {
+ rhdPtr->PowerPlayMode = i;
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "AtomBIOS default PowerPlay
mode is %d\n", rhdPtr->PowerPlayMode);
+ break;
+ }
+ }
+
rhdDumpPowerPlayModes(rhdPtr);
return TRUE;

--
1.5.6.4

From 9291cdb24b0900a250171205ba5b58bfd5496b7b Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Sun, 5 Oct 2008 09:42:57 -0700
Subject: [PATCH] PowerPlay: merge RHDPowerModeClockInfo and
RHDPowerModeVoltageInfo

The line between the two wasn't entirely clear; they are now one as
RHDPowerModeControlInfo.

A few more MiscInfo flags are accounted for.
---
src/rhd.h | 38 ++++++++++++++++++-------------
src/rhd_atombios.c | 62 ++++++++++++++++++++++++++++-----------------------
src/rhd_powerplay.c | 39 +++++++++++++++++++-------------
3 files changed, 79 insertions(+), 60 deletions(-)

diff --git a/src/rhd.h b/src/rhd.h
index 8754ace..5782669 100644
--- a/src/rhd.h
+++ b/src/rhd.h
@@ -216,30 +216,37 @@ enum RHDPowerModeMode {
RHD_PM_THERMAL_DIODE_MODE
};

-enum RHDPowerModeClockInfo {
+enum RHDPowerModeControlInfo {
RHD_PM_USING_MCLK_SRC = 1 << 0,
RHD_PM_USING_SCLK_SRC = 1 << 1,
RHD_PM_ENGINE_CLOCK_CONTRL_EN = 1 << 9,
RHD_PM_MEMORY_CLOCK_CONTRL_EN = 1 << 10,
- RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN = 1 << 16,
- RHD_PM_DYNAMIC_CLOCK_3D_IDLE = 1 << 24,
- RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 = 1 << 25,
- RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 = 1 << 26
-};
-
-enum RHDPowerModeVoltageInfo {
- RHD_PM_PROGRAM_VOLTAGE = 1 << 0,
- RHD_PM_VOLTAGE_DROP_SUPPORT = 1 << 1,
- RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH = 1 << 2,
- RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN = 1 << 3,
- RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN = 1 << 4
+ RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN = 1 << 11,
+ RHD_PM_DYNAMIC_CLOCK_3D_IDLE = 1 << 12,
+ RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 = 1 << 13,
+ RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 = 1 << 14,
+ RHD_PM_PROGRAM_VOLTAGE = 1 << 16,
+ RHD_PM_VOLTAGE_DROP_SUPPORT = 1 << 17,
+ RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH = 1 << 18,
+ RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN = 1 << 19,
+ RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN = 1 << 20,
+ RHD_PM_DEFAULT_DC_STATE_ENTRY_TRUE = 1 << 21,
+ RHD_PM_DEFAULT_LOW_DC_STATE_ENTRY_TRUE = 1 << 22,
+ RHD_PM_DYNAMIC_HDP_BLOCK_EN = 1 << 23,
+ RHD_PM_DYNAMIC_MC_HOST_BLOCK_EN = 1 << 24,
+ RHD_PM_ENABLE_BACK_BIAS = 1 << 25,
+ RHD_PM_DYNAMIC_BACK_BIAS_EN = 1 << 26
};

enum RHDPowerModeCapabilitiesInfo {
RHD_PM_3D_ACCELERATION_EN = 1 << 0,
RHD_PM_MULTI_DISPLAY_SUPPORT = 1 << 1,
RHD_PM_VIDEO_PLAYBACK_CAPABLE = 1 << 2,
- RHD_PM_UVD_SUPPORT_MODE = 1 << 3
+ RHD_PM_UVD_SUPPORT_MODE = 1 << 3,
+ RHD_PM_ASIC_SLEEP_MODE_EN = 1 << 4,
+ RHD_PM_LOAD_PERFORMANCE_EN = 1 << 6,
+ RHD_PM_LOAD_BALANCE_EN = 1 << 7,
+ RHD_PM_LOW_LCD_REFRESH_RATE = 1 << 8
};

typedef struct _RHDPowerMode {
@@ -254,8 +261,7 @@ typedef struct _RHDPowerMode {
unsigned short level;
} voltageDrop;

- enum RHDPowerModeClockInfo clockInfo;
- enum RHDPowerModeVoltageInfo voltageInfo;
+ enum RHDPowerModeControlInfo controlInfo;
enum RHDPowerModeCapabilitiesInfo capInfo;
} RHDPowerMode;

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index b33cfd7..983fb8f 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5183,28 +5183,33 @@ static void
rhdAtomStorePowerModeMisc1(ULONG info, RHDPowerMode *mode)
{
if (info & ATOM_PM_MISCINFO_USING_MCLK_SRC)
- mode->clockInfo |= RHD_PM_USING_MCLK_SRC;
+ mode->controlInfo |= RHD_PM_USING_MCLK_SRC;
if (info & ATOM_PM_MISCINFO_USING_SCLK_SRC)
- mode->clockInfo |= RHD_PM_USING_SCLK_SRC;
+ mode->controlInfo |= RHD_PM_USING_SCLK_SRC;
if (info & ATOM_PM_MISCINFO_VOLTAGE_DROP_SUPPORT)
- mode->voltageInfo |= RHD_PM_VOLTAGE_DROP_SUPPORT;
+ mode->controlInfo |= RHD_PM_VOLTAGE_DROP_SUPPORT;
if (info & ATOM_PM_MISCINFO_VOLTAGE_DROP_ACTIVE_HIGH)
- mode->voltageInfo |= RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH;
- /*if (info & ATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN)*/
+ mode->controlInfo |= RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH;
+ if (info & ATOM_PM_MISCINFO_LOAD_PERFORMANCE_EN)
+ mode->capInfo |= RHD_PM_LOAD_PERFORMANCE_EN;
if (info & ATOM_PM_MISCINFO_ENGINE_CLOCK_CONTRL_EN)
- mode->clockInfo |= RHD_PM_ENGINE_CLOCK_CONTRL_EN;
+ mode->controlInfo |= RHD_PM_ENGINE_CLOCK_CONTRL_EN;
if (info & ATOM_PM_MISCINFO_MEMORY_CLOCK_CONTRL_EN)
- mode->clockInfo |= RHD_PM_MEMORY_CLOCK_CONTRL_EN;
+ mode->controlInfo |= RHD_PM_MEMORY_CLOCK_CONTRL_EN;
if (info & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE)
- mode->voltageInfo |= RHD_PM_PROGRAM_VOLTAGE;
+ mode->controlInfo |= RHD_PM_PROGRAM_VOLTAGE;
if (info & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN)
- mode->clockInfo |= RHD_PM_USING_SCLK_SRC;
+ mode->controlInfo |= RHD_PM_USING_SCLK_SRC;
if (info & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN)
- mode->voltageInfo |= RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN;
- /*if (info & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)*/
- /*if (info & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)*/
- /*if (info & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)*/
- /*if (info & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)*/
+ mode->controlInfo |= RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN;
+ if (info & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)
+ mode->capInfo |= RHD_PM_ASIC_SLEEP_MODE_EN;
+ if (info & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
+ mode->capInfo |= RHD_PM_LOAD_BALANCE_EN;
+ if (info & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
+ mode->controlInfo |= RHD_PM_DEFAULT_DC_STATE_ENTRY_TRUE;
+ if (info & ATOM_PM_MISCINFO_DEFAULT_LOW_DC_STATE_ENTRY_TRUE)
+ mode->controlInfo |= RHD_PM_DEFAULT_LOW_DC_STATE_ENTRY_TRUE;
/*if (info & ATOM_PM_MISCINFO_LOW_LCD_REFRESH_RATE)*/
if (info & ATOM_PM_MISCINFO_DRIVER_DEFAULT_MODE)
mode->mode = RHD_PM_DEFAULT_MODE;
@@ -5226,16 +5231,19 @@ rhdAtomStorePowerModeMisc1(ULONG info, RHDPowerMode
*mode)
}
*/
if (info & ATOM_PM_MISCINFO_DYN_CLK_3D_IDLE)
- mode->clockInfo |= RHD_PM_DYNAMIC_CLOCK_3D_IDLE;
+ mode->controlInfo |= RHD_PM_DYNAMIC_CLOCK_3D_IDLE;
if (info & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_2)
- mode->clockInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2;
+ mode->controlInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2;
if (info & ATOM_PM_MISCINFO_DYNAMIC_CLOCK_DIVIDER_BY_4)
- mode->clockInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4;
- /*if (info & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN)*/
- /*if (info & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN)*/
+ mode->controlInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4;
+ if (info & ATOM_PM_MISCINFO_DYNAMIC_HDP_BLOCK_EN)
+ mode->controlInfo |= RHD_PM_DYNAMIC_HDP_BLOCK_EN;
+ if (info & ATOM_PM_MISCINFO_DYNAMIC_MC_HOST_BLOCK_EN)
+ mode->controlInfo |= RHD_PM_DYNAMIC_MC_HOST_BLOCK_EN;
if (info & ATOM_PM_MISCINFO_3D_ACCELERATION_EN)
mode->capInfo |= RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4;
- /*if (info & ATOM_PM_MISCINFO_ENABLE_BACK_BIAS)*/
+ if (info & ATOM_PM_MISCINFO_ENABLE_BACK_BIAS)
+ mode->controlInfo |= RHD_PM_ENABLE_BACK_BIAS;
}

static void
@@ -5244,11 +5252,12 @@ rhdAtomStorePowerModeMisc2(ULONG info, RHDPowerMode
*mode)
/*if (info & ATOM_PM_MISCINFO2_SYSTEM_AC_LITE_MODE)*/
if (info & ATOM_PM_MISCINFO2_MULTI_DISPLAY_SUPPORT)
mode->capInfo |= RHD_PM_MULTI_DISPLAY_SUPPORT;
- /*if (info & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN)*/
+ if (info & ATOM_PM_MISCINFO2_DYNAMIC_BACK_BIAS_EN)
+ mode->controlInfo |= RHD_PM_DYNAMIC_BACK_BIAS_EN;
/*if (info & ATOM_PM_MISCINFO2_FS3D_OVERDRIVE_INFO)*/
/*if (info & ATOM_PM_MISCINFO2_FORCEDLOWPWR_MODE)*/
if (info & ATOM_PM_MISCINFO2_VDDCI_DYNAMIC_VOLTAGE_EN)
- mode->voltageInfo |= RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN;
+ mode->controlInfo |= RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN;
if (info & ATOM_PM_MISCINFO2_VIDEO_PLAYBACK_CAPABLE)
mode->capInfo |= RHD_PM_VIDEO_PLAYBACK_CAPABLE;
/*if (info & ATOM_PM_MISCINFO2_NOT_VALID_ON_DC)*/
@@ -5292,8 +5301,7 @@ rhdAtomStorePowerMode_v1(ATOM_POWERMODE_INFO *info,
RHDPowerMode *mode)
mode->memoryClock = info->usMemoryClock * 10;
mode->pcieLanes = info->ucNumPciELanes;
mode->voltageDrop.index = info->ucVoltageDropIndex;
- mode->clockInfo = 0;
- mode->voltageInfo = 0;
+ mode->controlInfo = 0;
mode->capInfo = 0;
rhdAtomStorePowerModeGroup(info->ulMiscInfo, mode);
rhdAtomStorePowerModeMode(info->ulMiscInfo, mode);
@@ -5307,8 +5315,7 @@ rhdAtomStorePowerMode_v2(ATOM_POWERMODE_INFO_V2 *info,
RHDPowerMode *mode)
mode->memoryClock = info->ulMemoryClock * 10;
mode->pcieLanes = info->ucNumPciELanes;
mode->voltageDrop.index = info->ucVoltageDropIndex;
- mode->clockInfo = 0;
- mode->voltageInfo = 0;
+ mode->controlInfo = 0;
mode->capInfo = 0;
rhdAtomStorePowerModeGroup(info->ulMiscInfo, mode);
rhdAtomStorePowerModeMode(info->ulMiscInfo, mode);
@@ -5322,8 +5329,7 @@ rhdAtomStorePowerMode_v3(ATOM_POWERMODE_INFO_V3 *info,
RHDPowerMode *mode)
mode->engineClock = info->ulEngineClock * 10;
mode->memoryClock = info->ulMemoryClock * 10;
mode->pcieLanes = info->ucNumPciELanes;
- mode->clockInfo = 0;
- mode->voltageInfo = 0;
+ mode->controlInfo = 0;
mode->capInfo = 0;
/* FIXME */
/*mode->voltageDrop.index = info->ucVoltageDropIndex;*/
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index a926090..1a0887f 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -253,7 +253,7 @@ rhdDumpPowerPlayModes(RHDPtr rhdPtr)
RHDPowerMode *mode;

xf86DrvMsg(sidx, X_INFO, "%d PowerPlay modes available\n", numOfModes);
-
+
for (modeNum = 0; modeNum < numOfModes; modeNum++) {
mode = &(rhdPtr->PowerPlayTable.modes[modeNum]);

@@ -277,24 +277,31 @@ rhdDumpPowerPlayModes(RHDPtr rhdPtr)
xf86DrvMsg(sidx, X_INFO,
"PowerPlay Mode %d: %s (%s)\n"
"\tEngine: %ldkHz Memory: %ldkHz PCIe lanes: %d Voltage drop
index: %d\n"
- "%s%s%s%s%s%s%s%s"
- "%s%s%s%s%s"
+ "%s%s""%s%s""%s%s%s%s"
+ "%s%s%s""%s%s""%s%s"
+ "%s%s""%s%s"
"%s%s%s%s",
modeNum, groupName, modeName,
mode->engineClock, mode->memoryClock, mode->pcieLanes,
mode->voltageDrop.index,
- (mode->clockInfo & RHD_PM_USING_MCLK_SRC ? "\t USING_MCLK_SRC\n"
: ""),
- (mode->clockInfo & RHD_PM_USING_SCLK_SRC ? "\t USING_SCLK_SRC\n"
: ""),
- (mode->clockInfo & RHD_PM_ENGINE_CLOCK_CONTRL_EN ? "\t
ENGINE_CLOCK_CONTRL_EN\n" : ""),
- (mode->clockInfo & RHD_PM_MEMORY_CLOCK_CONTRL_EN ? "\t
MEMORY_CLOCK_CONTRL_EN\n" : ""),
- (mode->clockInfo & RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN ? "\t
ASIC_REDUCED_SPEED_SCLK_EN\n" : ""),
- (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_3D_IDLE ? "\t
DYNAMIC_CLOCK_3D_IDLE\n" : ""),
- (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_2\n" : ""),
- (mode->clockInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_4\n" : ""),
- (mode->voltageInfo & RHD_PM_PROGRAM_VOLTAGE ? "\t
PROGRAM_VOLTAGE\n" : ""),
- (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_SUPPORT ? "\t
VOLTAGE_DROP_SUPPORT\n" : ""),
- (mode->voltageInfo & RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH ? "\t
VOLTAGE_DROP_ACTIVE_HIGH\n" : ""),
- (mode->voltageInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
- (mode->voltageInfo & RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN ? "\t
VDDCI_DYNAMIC_VOLTAGE_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_USING_MCLK_SRC ? "\t
USING_MCLK_SRC\n" : ""),
+ (mode->controlInfo & RHD_PM_USING_SCLK_SRC ? "\t
USING_SCLK_SRC\n" : ""),
+ (mode->controlInfo & RHD_PM_ENGINE_CLOCK_CONTRL_EN ? "\t
ENGINE_CLOCK_CONTRL_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_MEMORY_CLOCK_CONTRL_EN ? "\t
MEMORY_CLOCK_CONTRL_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN ? "\t
ASIC_REDUCED_SPEED_SCLK_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_DYNAMIC_CLOCK_3D_IDLE ? "\t
DYNAMIC_CLOCK_3D_IDLE\n" : ""),
+ (mode->controlInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_2\n" : ""),
+ (mode->controlInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_4\n" : ""),
+ (mode->controlInfo & RHD_PM_PROGRAM_VOLTAGE ? "\t
PROGRAM_VOLTAGE\n" : ""),
+ (mode->controlInfo & RHD_PM_VOLTAGE_DROP_SUPPORT ? "\t
VOLTAGE_DROP_SUPPORT\n" : ""),
+ (mode->controlInfo & RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH ? "\t
VOLTAGE_DROP_ACTIVE_HIGH\n" : ""),
+ (mode->controlInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN ? "\t
VDDCI_DYNAMIC_VOLTAGE_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_DEFAULT_DC_STATE_ENTRY_TRUE ? "\t
DEFAULT_DC_STATE_ENTRY_TRUE\n" : ""),
+ (mode->controlInfo & RHD_PM_DEFAULT_LOW_DC_STATE_ENTRY_TRUE ? "\t
DEFAULT_LOW_DC_STATE_ENTRY_TRUE\n" : ""),
+ (mode->controlInfo & RHD_PM_DYNAMIC_HDP_BLOCK_EN ? "\t
DYNAMIC_HDP_BLOCK_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_DYNAMIC_MC_HOST_BLOCK_EN ? "\t
DYNAMIC_MC_HOST_BLOCK_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_ENABLE_BACK_BIAS ? "\t
ENABLE_BACK_BIAS\n" : ""),
+ (mode->controlInfo & RHD_PM_DYNAMIC_BACK_BIAS_EN ? "\t
DYNAMIC_BACK_BIAS_EN\n" : ""),
(mode->capInfo & RHD_PM_3D_ACCELERATION_EN ? "\t
3D_ACCELERATION_EN\n" : ""),
(mode->capInfo & RHD_PM_MULTI_DISPLAY_SUPPORT ? "\t
MULTI_DISPLAY_SUPPORT\n" : ""),
(mode->capInfo & RHD_PM_VIDEO_PLAYBACK_CAPABLE ? "\t
VIDEO_PLAYBACK_CAPABLE\n" : ""),
--
1.5.6.4

From e0a2763f105461cb89683509090a159abcd49593 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Mon, 6 Oct 2008 16:05:46 -0700
Subject: [PATCH] Power management: clean-up initialiation path; also logging
corrections

rhdInitPowerPlay() is now called by rhdInitPowerManagement()

Parsing of VoltageObject table is correctly relocated to general
AtomBIOS section instead of r5xx specific.
---
src/rhd_driver.c | 17 ++++++-----------
src/rhd_powerplay.c | 39 +++++++++++++++++++++------------------
2 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/src/rhd_driver.c b/src/rhd_driver.c
index 47c62c4..fa00423 100644
--- a/src/rhd_driver.c
+++ b/src/rhd_driver.c
@@ -764,7 +764,6 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)

/* Initialize power management */
rhdInitPowerManagement(rhdPtr);
- rhdInitPowerPlay(rhdPtr);

#ifdef USE_DRI
RHDDRIPreInit(pScrn);
@@ -1018,14 +1017,6 @@ RHDPreInit(ScrnInfoPtr pScrn, int flags)
RHDDebug(pScrn->scrnIndex, "Free FB offset 0x%08X (size = 0x%08X)\n",
rhdPtr->FbFreeStart, rhdPtr->FbFreeSize);

- /* Handle PowerPlayMode option */
- if (!rhdPtr->defaultPowerPlayMode.set) {
- rhdPtr->defaultPowerPlayMode.val.integer =
RHD_POWERPLAY_USE_ATOM_DEFAULT;
- }
- else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Setting default PowerPlay mode
to %d\n", rhdPtr->defaultPowerPlayMode.val.integer);
- }
-
ret = TRUE;

error1:
@@ -1254,9 +1245,13 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int
argc, char **argv)
RADEONInitVideo(pScreen);
}

- /* Switch PowerPlay mode */
+ /* Switch PowerPlay mode
+ * If not configured, apply driver default PowerPlay so that all settings
+ * are applied */
if (rhdPtr->defaultPowerPlayMode.val.integer !=
RHD_POWERPLAY_USE_ATOM_DEFAULT)
rhdPowerPlaySetMode(rhdPtr, rhdPtr->defaultPowerPlayMode.val.integer);
+ else
+ rhdPowerPlaySetMode(rhdPtr, rhdPtr->PowerPlayMode);

/* Wrap the current CloseScreen function */
rhdPtr->CloseScreen = pScreen->CloseScreen;
@@ -2767,7 +2762,7 @@ rhdProcessOptions(ScrnInfoPtr pScrn)
RhdGetOptValBool (rhdPtr->Options, OPTION_USE_ATOMBIOS,
&rhdPtr->UseAtomBIOS, FALSE);
RhdGetOptValInteger(rhdPtr->Options, OPTION_POWERPLAY_MODE,
- &rhdPtr->defaultPowerPlayMode, 0);
+ &rhdPtr->defaultPowerPlayMode,
RHD_POWERPLAY_USE_ATOM_DEFAULT);

#ifdef ATOM_BIOS
rhdParseAtomBIOSUsage(pScrn);
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 1a0887f..988bf18 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -40,13 +40,27 @@ Bool rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char
numLanes);
Bool
rhdInitPowerManagement(RHDPtr rhdPtr)
{
+ AtomBiosArgRec atomBiosArg;
+
if (rhdPtr->ChipSet < RHD_R600) {
- return rhdInitPowerManagement_r5xx(rhdPtr);
+ rhdInitPowerManagement_r5xx(rhdPtr);
}
else
- xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Power management not supported
on R600 and greater");
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Power management for R600
and greater not tested");

- return FALSE;
+ /* Read VoltageObjectInfo from table */
+ if (rhdPtr->atomBIOS) {
+ if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_VOLTAGE_OBJECT_INFO, &atomBiosArg)
+ != ATOM_SUCCESS) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Failed to read
VoltageObjectInfo\n");
+ }
+ }
+ else
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Could not read
VoltageObjectInfo: requires AtomBIOS\n");
+
+ rhdInitPowerPlay(rhdPtr);
+
+ return TRUE;
}

Bool
@@ -90,21 +104,9 @@ rhdInitPowerPlay(RHDPtr rhdPtr)
Bool
rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
{
- AtomBiosArgRec atomBiosArg;
-
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");

- /* Read VoltageObjectInfo from table */
- if (rhdPtr->atomBIOS) {
- if (RHDAtomBiosFunc(rhdPtr->scrnIndex, rhdPtr->atomBIOS,
ATOM_GET_VOLTAGE_OBJECT_INFO, &atomBiosArg)
- != ATOM_SUCCESS) {
- xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Failed to read
VoltageObjectInfo\n");
- return FALSE;
- }
- }
- else
- xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Could not read
VoltageObjectInfo: requires AtomBIOS\n");
-
+#if 0
RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);

@@ -116,6 +118,7 @@ rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
/* Ties voltage to SCLK? */
RHDSetCCRegIndex(rhdPtr, R5_DYN_SCLK_VOL_CNTL);
RHDCCRegMask(rhdPtr, IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC,
IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC);
+#endif

return TRUE;
}
@@ -188,7 +191,7 @@ rhdSetPCIeLanes(RHDPtr rhdPtr, unsigned char numLanes)
if (rhdPtr->ChipSet < RHD_R600)
return rhdSetPCIeLanes_r5xx(rhdPtr, numLanes);
else {
- xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PICe lane width setting now
supported on r600\n");
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "PICe lane width setting not
supported on r600\n");
return FALSE;
}
}
@@ -207,7 +210,7 @@ rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char numLanes)
case 12: regValue = LC_LINK_WIDTH_X12; break;
case 16: regValue = LC_LINK_WIDTH_X16; break;
default:
- xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Invalied PCIe mode: x%d\n",
numLanes);
+ xf86DrvMsg(rhdPtr->scrnIndex, X_ERROR, "Invalied PCIe mode: x%d\n",
numLanes);
return FALSE;
}

--
1.5.6.4

From 3d30b85d959adfd984da73ce5bb1fc4ab7a6f1ee Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Mon, 6 Oct 2008 16:09:20 -0700
Subject: [PATCH] PowerPlay: set registers according to MiscInfo* flags

Not sure if they're correct, but doesn't seem to cause and problems,
except DYN_PWRMGT_SCLK_CNTL. It's disabled for now.
---
src/rhd_powerplay.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++-
src/rhd_regs.h | 18 ++++++++++++++++-
2 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 988bf18..fa066e6 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -35,6 +35,7 @@
void rhdDumpPowerPlayModes(RHDPtr rhdPtr);
Bool rhdInitPowerManagement_r5xx(RHDPtr rhdPtr);

+Bool rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode);
Bool rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char numLanes);

Bool
@@ -150,6 +151,13 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode
modeNum)

RHDAllIdle(pScrn);

+ if (rhdPtr->ChipSet < RHD_R600) {
+ rhdApplyPMControls_r5xx(rhdPtr, mode);
+ }
+ else {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Only applying engine and
memory clock changes\n");
+ }
+
rhdSetPCIeLanes(rhdPtr, mode->pcieLanes);

if (!rhdSetEngineClock(rhdPtr, mode->engineClock))
@@ -241,11 +249,55 @@ rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char
numLanes)
return TRUE;
}
else {
- xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Failed to set PCIe mode\n");
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "Failed to set PCIe mode\n");
return FALSE;
}
}

+Bool
+rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)
+{
+ /* Not sure if register saving can get these indirect ones
+ * Explicitly set everytime for now */
+ RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
+ RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);
+
+ /* XXX: Un-set options when not present? */
+
+ /* SCLK */
+ /* causes corruption
+ RHDSetCCRegIndex(rhdPtr, R5_DYN_PWRMGT_SCLK_CNTL);
+ RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN,
+ ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN);
+ */
+
+ /* Core voltage */
+ /* FIXME: which of the flags are actually relevant here? */
+ if (mode->controlInfo & (RHD_PM_VOLTAGE_DROP_SUPPORT |
RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH |
+ RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN |
RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN)) {
+ RHDSetCCRegIndex(rhdPtr, R5_DYN_SCLK_VOL_CNTL);
+ RHDCCRegMask(rhdPtr, IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC,
IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC);
+ }
+
+ /* Back-bias controls */
+ /* XXX: untested */
+ /* FIXME: what's the interaction between ENABLE_BACK_BIAS and
DYNAMIC_BACK_BIAS_EN? */
+ if (mode->controlInfo & RHD_PM_ENABLE_BACK_BIAS || mode->controlInfo &
RHD_PM_DYNAMIC_BACK_BIAS_EN) {
+ RHDSetCCRegIndex(rhdPtr, R5_DYN_BACKBIAS_CNTL);
+ RHDCCRegWrite(rhdPtr, IO_CG_BACKBIAS_EN | BACKBIAS_SYNC);
+ }
+
+ /* Dynamic HDP block */
+ /* XXX: referring to PCIe control? */
+ if (mode->controlInfo & RHD_PM_DYNAMIC_HDP_BLOCK_EN) {
+ RHDSetPCIERegIndex(rhdPtr, R5_PCIE_CLK_CNTL);
+ RHDPCIERegMask(rhdPtr, SEL_HDP_CLK | ~SEL_HDP_CLK_IN_VOLTAGE_DROP |
~SEL_HDP_CLK_IN_STATIC_SCREEN,
+ R5_PCIE_CLK_CNTL_HDP_MASK);
+ }
+
+ return TRUE;
+}
+
void
rhdDumpPowerPlayModes(RHDPtr rhdPtr)
{
diff --git a/src/rhd_regs.h b/src/rhd_regs.h
index 0ca6945..8193618 100644
--- a/src/rhd_regs.h
+++ b/src/rhd_regs.h
@@ -698,12 +698,18 @@ enum R5_DYN_SCLK_VOL_CNTL_BITS {
VOLTAGE_DROP_SYNC = 1 << 2
};

+enum R5_DYN_BACKBIAS_CNTL_BITS {
+ IO_CG_BACKBIAS_EN = 1 << 0,
+ BACKBIAS_SYNC = 1 << 1
+};
+
/* Registers and offsets related to PCIe on r5xx */
enum _r5xxPCIERegs {
R5_PCIE_INDEX = 0x30,
R5_PCIE_DATA = 0x34,
R5_PCIE_LC_LINK_WIDTH_CNTL = 0xA2,
- R5_PCIE_P_CNTL = 0xB0
+ R5_PCIE_P_CNTL = 0xB0,
+ R5_PCIE_CLK_CNTL = 0x400
};
#define R5_PCIE_INDEX_MASK 0x3FF

@@ -722,6 +728,16 @@ enum R5_PCIE_LC_LINK_WIDTH_CNTL_BITS {
};
#define LC_LINK_WIDTH_RD_SHIFT 4

+enum R5_PCIE_CLK_CNTL_BITS {
+ FORCE_BIF_TXCLK = 1 << 0,
+ FORCE_BIF_TXCLK_IN_L0S = 1 << 1,
+ SEL_HDP_CLK = 1 << 2,
+ SEL_HDP_CLK_IN_VOLTAGE_DROP = 1 << 3,
+ SEL_HDP_CLK_IN_STATIC_SCREEN = 1 << 4,
+ FORCE_RXCLK = 1 << 5
+};
+#define R5_PCIE_CLK_CNTL_HDP_MASK 0x16
+
enum _r6xxRegs {
/* MCLK */
R6_MCLK_PWRMGT_CNTL = 0x620,
--
1.5.6.4

From 105a5f7b3304dc3215d5876f0ab579b32be8bcdf Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 00:32:12 -0700
Subject: [PATCH] PowerPlay: get controlInfo setting to a usable state

Moved some operations out to rhdPowerManagementInit_r5xx again, and
implemented a couple more.

Some operations are causing consistent bugs, but they're identified.
---
src/rhd_powerplay.c | 49 +++++++++++++++++++++++--------------------------
src/rhd_regs.h | 13 +++++++++++++
2 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index fa066e6..3779c98 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -107,19 +107,20 @@ rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)
{
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Initializing power management
functionalities\n");

-#if 0
RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
- RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);
+ RHDCCRegMask(rhdPtr, GLOBAL_PWRMGT_EN, GLOBAL_PWRMGT_EN);

- /* Enable clock gating? */
+ /* Enable dynamic clock gating */
RHDSetCCRegIndex(rhdPtr, R5_DYN_PWRMGT_SCLK_CNTL);
+ RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE, ENGINE_DYNCLK_MODE);
+ /*
RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN,
ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN);
+ */

- /* Ties voltage to SCLK? */
- RHDSetCCRegIndex(rhdPtr, R5_DYN_SCLK_VOL_CNTL);
- RHDCCRegMask(rhdPtr, IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC,
IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC);
-#endif
+ /* MCLK */
+ RHDSetCCRegIndex(rhdPtr, R5_MCLK_PWRMGT_CNTL);
+ RHDCCRegMask(rhdPtr, ~MPLL_PWRMGT_OFF, MPLL_PWRMGT_OFF);

return TRUE;
}
@@ -257,18 +258,22 @@ rhdSetPCIeLanes_r5xx(RHDPtr rhdPtr, unsigned char
numLanes)
Bool
rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)
{
- /* Not sure if register saving can get these indirect ones
- * Explicitly set everytime for now */
- RHDSetCCRegIndex(rhdPtr, R5_GENERAL_PWRMGT);
- RHDCCRegWrite(rhdPtr, GLOBAL_PWRMGT_EN);
-
- /* XXX: Un-set options when not present? */
+ /* Dynamic MC host block */
+ /* FIXME: this corrupts mouse cursor
+ if (mode->controlInfo & RHD_PM_DYNAMIC_MC_HOST_BLOCK_EN) {
+ RHDSetCCRegIndex(rhdPtr, R5_MC_HOST_DYN_CNTL);
+ RHDCCRegMask(rhdPtr, ~R5_DYN_CNTL_FORCE, R5_DYN_CNTL_FORCE);
+ }
+ */

- /* SCLK */
- /* causes corruption
- RHDSetCCRegIndex(rhdPtr, R5_DYN_PWRMGT_SCLK_CNTL);
- RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN,
- ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN);
+ /* Dynamic HDP block */
+ /* XXX: referring to PCIe control? */
+ /*
+ if (mode->controlInfo & RHD_PM_DYNAMIC_HDP_BLOCK_EN) {
+ RHDSetPCIERegIndex(rhdPtr, R5_PCIE_CLK_CNTL);
+ RHDPCIERegMask(rhdPtr, SEL_HDP_CLK | ~SEL_HDP_CLK_IN_VOLTAGE_DROP |
~SEL_HDP_CLK_IN_STATIC_SCREEN,
+ R5_PCIE_CLK_CNTL_HDP_MASK);
+ }
*/

/* Core voltage */
@@ -287,14 +292,6 @@ rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)
RHDCCRegWrite(rhdPtr, IO_CG_BACKBIAS_EN | BACKBIAS_SYNC);
}

- /* Dynamic HDP block */
- /* XXX: referring to PCIe control? */
- if (mode->controlInfo & RHD_PM_DYNAMIC_HDP_BLOCK_EN) {
- RHDSetPCIERegIndex(rhdPtr, R5_PCIE_CLK_CNTL);
- RHDPCIERegMask(rhdPtr, SEL_HDP_CLK | ~SEL_HDP_CLK_IN_VOLTAGE_DROP |
~SEL_HDP_CLK_IN_STATIC_SCREEN,
- R5_PCIE_CLK_CNTL_HDP_MASK);
- }
-
return TRUE;
}

diff --git a/src/rhd_regs.h b/src/rhd_regs.h
index 8193618..83a4793 100644
--- a/src/rhd_regs.h
+++ b/src/rhd_regs.h
@@ -686,6 +686,9 @@ enum R5_SCLK_PWRMGT_CNTL_BITS {
SPLL_TURNOFF = 1 << 2
};

+enum R5_MCLK_PWRMGT_CNTL_BITS {
+ MPLL_PWRMGT_OFF = 1 << 0
+};
enum R5_DYN_PWRMGT_SCKL_CNTL_BITS {
ENGINE_DYNCLK_MODE = 1 << 0,
STATIC_SCREEN_EN = 1 << 20,
@@ -698,6 +701,16 @@ enum R5_DYN_SCLK_VOL_CNTL_BITS {
VOLTAGE_DROP_SYNC = 1 << 2
};

+/* TCL_DYN_CNTL, MC_GUI_DYN_CNTL, MC_HOST_DYN_CNTL, and MC_RBS_DYN_CNTL
+ * share a common structure */
+enum R5_DYN_CNTL_BITS {
+ R5_DYN_CNTL_FORCE = 1 << 0,
+ R5_DYN_CNTL_MAX_DYN_STOP_LAT = 1 << 1,
+ R5_DYN_CNTL_PROG_SHUTOFF = 1 << 3
+};
+#define R5_DYN_CNTL_DELAY_VALUE_MASK 0xF
+#define R5_DYN_CNTL_DELAY_VALUE_SHIFT 4
+
enum R5_DYN_BACKBIAS_CNTL_BITS {
IO_CG_BACKBIAS_EN = 1 << 0,
BACKBIAS_SYNC = 1 << 1
--
1.5.6.4

From 130fb119b70dcc9e5da7ae092d05cddb4e11262e Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 14:23:28 -0700
Subject: [PATCH] PowerPlay: do not return prematurely from rhdPowerPlaySetMode()

---
src/rhd_powerplay.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 3779c98..5674774 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -137,6 +137,7 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)
AtomBiosArgRec atomBiosArg;
ScrnInfoPtr pScrn = xf86Screens[rhdPtr->scrnIndex];
RHDPowerMode *mode;
+ Bool r = TRUE;

xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Switching to PowerPlay mode %d\n",
modeNum);

@@ -162,10 +163,10 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode
modeNum)
rhdSetPCIeLanes(rhdPtr, mode->pcieLanes);

if (!rhdSetEngineClock(rhdPtr, mode->engineClock))
- return FALSE;
+ r = FALSE;

if (!rhdSetMemoryClock(rhdPtr, mode->memoryClock))
- return FALSE;
+ r = FALSE;

rhdPtr->PowerPlayMode = modeNum;

@@ -175,7 +176,7 @@ rhdPowerPlaySetMode(RHDPtr rhdPtr, RHDPowerPlayMode modeNum)
/* Bring screens up again */
xf86SetDesiredModes(pScrn);

- return TRUE;
+ return r;
}

Bool
--
1.5.6.4

From e7c006186cc7a72e0b356ee56bd07aeb88cff47c Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 14:25:10 -0700
Subject: [PATCH] PowerPlay: fix a couple controlInfo flags not being set/dumped
properly

---
src/rhd_atombios.c | 2 +-
src/rhd_powerplay.c | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index 983fb8f..bde88ed 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5199,7 +5199,7 @@ rhdAtomStorePowerModeMisc1(ULONG info, RHDPowerMode *mode)
if (info & ATOM_PM_MISCINFO_PROGRAM_VOLTAGE)
mode->controlInfo |= RHD_PM_PROGRAM_VOLTAGE;
if (info & ATOM_PM_MISCINFO_ASIC_REDUCED_SPEED_SCLK_EN)
- mode->controlInfo |= RHD_PM_USING_SCLK_SRC;
+ mode->controlInfo |= RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN;
if (info & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN)
mode->controlInfo |= RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN;
if (info & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 5674774..118b54c 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -347,6 +347,7 @@ rhdDumpPowerPlayModes(RHDPtr rhdPtr)
(mode->controlInfo & RHD_PM_PROGRAM_VOLTAGE ? "\t
PROGRAM_VOLTAGE\n" : ""),
(mode->controlInfo & RHD_PM_VOLTAGE_DROP_SUPPORT ? "\t
VOLTAGE_DROP_SUPPORT\n" : ""),
(mode->controlInfo & RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH ? "\t
VOLTAGE_DROP_ACTIVE_HIGH\n" : ""),
+ (mode->controlInfo & RHD_PM_ASIC_SLEEP_MODE_EN ? "\t
ASIC_SLEEP_MODE_EN\n" : ""),
(mode->controlInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
(mode->controlInfo & RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN ? "\t
VDDCI_DYNAMIC_VOLTAGE_EN\n" : ""),
(mode->controlInfo & RHD_PM_DEFAULT_DC_STATE_ENTRY_TRUE ? "\t
DEFAULT_DC_STATE_ENTRY_TRUE\n" : ""),
--
1.5.6.4

From 6965349f1e103bd95ed15eb9354c6ce39c57a21b Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 14:37:27 -0700
Subject: [PATCH] PowerPlay: ASIC_SLEEP_MODE_EN belongs in controInfo

---
src/rhd.h | 2 +-
src/rhd_atombios.c | 2 +-
src/rhd_powerplay.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/rhd.h b/src/rhd.h
index 5782669..9c74b58 100644
--- a/src/rhd.h
+++ b/src/rhd.h
@@ -221,6 +221,7 @@ enum RHDPowerModeControlInfo {
RHD_PM_USING_SCLK_SRC = 1 << 1,
RHD_PM_ENGINE_CLOCK_CONTRL_EN = 1 << 9,
RHD_PM_MEMORY_CLOCK_CONTRL_EN = 1 << 10,
+ RHD_PM_ASIC_SLEEP_MODE_EN = 1 << 4,
RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN = 1 << 11,
RHD_PM_DYNAMIC_CLOCK_3D_IDLE = 1 << 12,
RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 = 1 << 13,
@@ -243,7 +244,6 @@ enum RHDPowerModeCapabilitiesInfo {
RHD_PM_MULTI_DISPLAY_SUPPORT = 1 << 1,
RHD_PM_VIDEO_PLAYBACK_CAPABLE = 1 << 2,
RHD_PM_UVD_SUPPORT_MODE = 1 << 3,
- RHD_PM_ASIC_SLEEP_MODE_EN = 1 << 4,
RHD_PM_LOAD_PERFORMANCE_EN = 1 << 6,
RHD_PM_LOAD_BALANCE_EN = 1 << 7,
RHD_PM_LOW_LCD_REFRESH_RATE = 1 << 8
diff --git a/src/rhd_atombios.c b/src/rhd_atombios.c
index bde88ed..b9ef9b6 100644
--- a/src/rhd_atombios.c
+++ b/src/rhd_atombios.c
@@ -5203,7 +5203,7 @@ rhdAtomStorePowerModeMisc1(ULONG info, RHDPowerMode *mode)
if (info & ATOM_PM_MISCINFO_ASIC_DYNAMIC_VOLTAGE_EN)
mode->controlInfo |= RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN;
if (info & ATOM_PM_MISCINFO_ASIC_SLEEP_MODE_EN)
- mode->capInfo |= RHD_PM_ASIC_SLEEP_MODE_EN;
+ mode->controlInfo |= RHD_PM_ASIC_SLEEP_MODE_EN;
if (info & ATOM_PM_MISCINFO_LOAD_BALANCE_EN)
mode->capInfo |= RHD_PM_LOAD_BALANCE_EN;
if (info & ATOM_PM_MISCINFO_DEFAULT_DC_STATE_ENTRY_TRUE)
diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 118b54c..9c2aa23 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -341,14 +341,14 @@ rhdDumpPowerPlayModes(RHDPtr rhdPtr)
(mode->controlInfo & RHD_PM_ENGINE_CLOCK_CONTRL_EN ? "\t
ENGINE_CLOCK_CONTRL_EN\n" : ""),
(mode->controlInfo & RHD_PM_MEMORY_CLOCK_CONTRL_EN ? "\t
MEMORY_CLOCK_CONTRL_EN\n" : ""),
(mode->controlInfo & RHD_PM_ASIC_REDUCED_SPEED_SCLK_EN ? "\t
ASIC_REDUCED_SPEED_SCLK_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_ASIC_SLEEP_MODE_EN ? "\t
ASIC_SLEEP_MODE_EN\n" : ""),
+ (mode->controlInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
(mode->controlInfo & RHD_PM_DYNAMIC_CLOCK_3D_IDLE ? "\t
DYNAMIC_CLOCK_3D_IDLE\n" : ""),
(mode->controlInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_2 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_2\n" : ""),
(mode->controlInfo & RHD_PM_DYNAMIC_CLOCK_DIVIDER_BY_4 ? "\t
DYNAMIC_CLOCK_DIVIDER_BY_4\n" : ""),
(mode->controlInfo & RHD_PM_PROGRAM_VOLTAGE ? "\t
PROGRAM_VOLTAGE\n" : ""),
(mode->controlInfo & RHD_PM_VOLTAGE_DROP_SUPPORT ? "\t
VOLTAGE_DROP_SUPPORT\n" : ""),
(mode->controlInfo & RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH ? "\t
VOLTAGE_DROP_ACTIVE_HIGH\n" : ""),
- (mode->controlInfo & RHD_PM_ASIC_SLEEP_MODE_EN ? "\t
ASIC_SLEEP_MODE_EN\n" : ""),
- (mode->controlInfo & RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN ? "\t
ASIC_DYNAMIC_VOLTAGE_EN\n" : ""),
(mode->controlInfo & RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN ? "\t
VDDCI_DYNAMIC_VOLTAGE_EN\n" : ""),
(mode->controlInfo & RHD_PM_DEFAULT_DC_STATE_ENTRY_TRUE ? "\t
DEFAULT_DC_STATE_ENTRY_TRUE\n" : ""),
(mode->controlInfo & RHD_PM_DEFAULT_LOW_DC_STATE_ENTRY_TRUE ? "\t
DEFAULT_LOW_DC_STATE_ENTRY_TRUE\n" : ""),
--
1.5.6.4

From 12a3792e8e0a8839b6b69f4948f6cac226a5027c Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 16:20:50 -0700
Subject: [PATCH] PowerPlay: log controlInfo flags being applied

---
src/rhd_powerplay.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 9c2aa23..41e23e1 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -262,6 +262,7 @@ rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)
/* Dynamic MC host block */
/* FIXME: this corrupts mouse cursor
if (mode->controlInfo & RHD_PM_DYNAMIC_MC_HOST_BLOCK_EN) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Enable MC host block clock
gating\n");
RHDSetCCRegIndex(rhdPtr, R5_MC_HOST_DYN_CNTL);
RHDCCRegMask(rhdPtr, ~R5_DYN_CNTL_FORCE, R5_DYN_CNTL_FORCE);
}
@@ -271,6 +272,7 @@ rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)
/* XXX: referring to PCIe control? */
/*
if (mode->controlInfo & RHD_PM_DYNAMIC_HDP_BLOCK_EN) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Enable dynamic HDP block\n");
RHDSetPCIERegIndex(rhdPtr, R5_PCIE_CLK_CNTL);
RHDPCIERegMask(rhdPtr, SEL_HDP_CLK | ~SEL_HDP_CLK_IN_VOLTAGE_DROP |
~SEL_HDP_CLK_IN_STATIC_SCREEN,
R5_PCIE_CLK_CNTL_HDP_MASK);
@@ -281,6 +283,7 @@ rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)
/* FIXME: which of the flags are actually relevant here? */
if (mode->controlInfo & (RHD_PM_VOLTAGE_DROP_SUPPORT |
RHD_PM_VOLTAGE_DROP_ACTIVE_HIGH |
RHD_PM_ASIC_DYNAMIC_VOLTAGE_EN |
RHD_PM_VDDCI_DYNAMIC_VOLTAGE_EN)) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Enable voltage drop\n");
RHDSetCCRegIndex(rhdPtr, R5_DYN_SCLK_VOL_CNTL);
RHDCCRegMask(rhdPtr, IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC,
IO_CG_VOLTAGE_DROP | VOLTAGE_DROP_SYNC);
}
@@ -289,6 +292,7 @@ rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)
/* XXX: untested */
/* FIXME: what's the interaction between ENABLE_BACK_BIAS and
DYNAMIC_BACK_BIAS_EN? */
if (mode->controlInfo & RHD_PM_ENABLE_BACK_BIAS || mode->controlInfo &
RHD_PM_DYNAMIC_BACK_BIAS_EN) {
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Enable dynamic back-bias\n");
RHDSetCCRegIndex(rhdPtr, R5_DYN_BACKBIAS_CNTL);
RHDCCRegWrite(rhdPtr, IO_CG_BACKBIAS_EN | BACKBIAS_SYNC);
}
--
1.5.6.4

From 1f0b00c27f2223e9cce43d028ccc67c041725749 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 16:31:07 -0700
Subject: [PATCH] PowerPlay: enable setting dynamic HDP block

---
src/rhd_powerplay.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 41e23e1..34db11d 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -270,14 +270,13 @@ rhdApplyPMControls_r5xx(RHDPtr rhdPtr, RHDPowerMode *mode)

/* Dynamic HDP block */
/* XXX: referring to PCIe control? */
- /*
+ /* TODO: static screen seems to be tricky; investigate others */
if (mode->controlInfo & RHD_PM_DYNAMIC_HDP_BLOCK_EN) {
xf86DrvMsg(rhdPtr->scrnIndex, X_INFO, "Enable dynamic HDP block\n");
RHDSetPCIERegIndex(rhdPtr, R5_PCIE_CLK_CNTL);
- RHDPCIERegMask(rhdPtr, SEL_HDP_CLK | ~SEL_HDP_CLK_IN_VOLTAGE_DROP |
~SEL_HDP_CLK_IN_STATIC_SCREEN,
- R5_PCIE_CLK_CNTL_HDP_MASK);
+ RHDPCIERegMask(rhdPtr, SEL_HDP_CLK | ~SEL_HDP_CLK_IN_VOLTAGE_DROP,
+ SEL_HDP_CLK | SEL_HDP_CLK_IN_VOLTAGE_DROP);
}
- */

/* Core voltage */
/* FIXME: which of the flags are actually relevant here? */
--
1.5.6.4

From 754fa3a6dea4a6d2b1c136c751d47cccd2ffe51a Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 17:20:59 -0700
Subject: [PATCH] PowerPlay: CLIENT_SELECT_POWER_EN is safe to enable

---
src/rhd_powerplay.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/rhd_powerplay.c b/src/rhd_powerplay.c
index 34db11d..bd95aae 100644
--- a/src/rhd_powerplay.c
+++ b/src/rhd_powerplay.c
@@ -112,7 +112,8 @@ rhdInitPowerManagement_r5xx(RHDPtr rhdPtr)

/* Enable dynamic clock gating */
RHDSetCCRegIndex(rhdPtr, R5_DYN_PWRMGT_SCLK_CNTL);
- RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE, ENGINE_DYNCLK_MODE);
+ RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE | CLIENT_SELECT_POWER_EN,
+ ENGINE_DYNCLK_MODE | CLIENT_SELECT_POWER_EN);
/*
RHDCCRegMask(rhdPtr, ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN,
ENGINE_DYNCLK_MODE | STATIC_SCREEN_EN |
CLIENT_SELECT_POWER_EN);
--
1.5.6.4

From ac7083cb25b1ff906276e955ecceb2be79816673 Mon Sep 17 00:00:00 2001
From: Yang Zhao <yang@xxxxxxxxxx>
Date: Tue, 7 Oct 2008 20:09:08 -0700
Subject: [PATCH] PowerPlay: connect PowerPlay property to TMDS outputs

---
src/rhd_atomout.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/rhd_atomout.c b/src/rhd_atomout.c
index d1cd588..74e3ba2 100644
--- a/src/rhd_atomout.c
+++ b/src/rhd_atomout.c
@@ -629,6 +629,9 @@ atomTMDSPropertyControl(struct rhdOutput *Output,
case RHD_OUTPUT_COHERENT:
val->Bool = Private->Coherent;
return TRUE;
+ case RHD_OUTPUT_POWERPLAY:
+ val->integer = rhdPowerPlayGetMode(RHDPTRI(Output));
+ return TRUE;
default:
return FALSE;
}
@@ -640,6 +643,8 @@ atomTMDSPropertyControl(struct rhdOutput *Output,
Output->Mode(Output, Private->Mode);
Output->Power(Output, RHD_POWER_ON);
break;
+ case RHD_OUTPUT_POWERPLAY:
+ return rhdPowerPlaySetMode(RHDPTRI(Output),
(RHDPowerPlayMode) val->integer);
default:
return FALSE;
}
--
1.5.6.4

< Previous Next >
References