Module Name: xsrc
Committed By: snj
Date: Mon Jan 11 00:20:32 UTC 2010
Added Files:
xsrc/external/mit/xf86-video-radeonhd/dist [netbsd-5]: acinclude.m4
shave-libtool.in shave.in
xsrc/external/mit/xf86-video-radeonhd/dist/src [netbsd-5]:
atombios_rev.h rhd_acpi.c rhd_acpi.h rhd_pm.c rhd_pm.h
Log Message:
Apply patch (requested by veego in ticket #1233):
Update xf86-video-radeonhd to 1.3.0.
To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1.1.1.2.2 \
xsrc/external/mit/xf86-video-radeonhd/dist/acinclude.m4 \
xsrc/external/mit/xf86-video-radeonhd/dist/shave-libtool.in \
xsrc/external/mit/xf86-video-radeonhd/dist/shave.in
cvs rdiff -u -r0 -r1.1.1.1.2.2 \
xsrc/external/mit/xf86-video-radeonhd/dist/src/atombios_rev.h \
xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.c \
xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.h \
xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.c \
xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Added files:
Index: xsrc/external/mit/xf86-video-radeonhd/dist/acinclude.m4
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/acinclude.m4:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/acinclude.m4 Mon Jan 11 00:20:32 2010
@@ -0,0 +1,77 @@
+dnl Make automake/libtool output more friendly to humans
+dnl Damien Lespiau <[email protected]>
+dnl
+dnl SHAVE_INIT([shavedir],[default_mode])
+dnl
+dnl shavedir: the directory where the shave scripts are, it defaults to
+dnl $(top_builddir)
+dnl default_mode: (enable|disable) default shave mode. This parameter
+dnl controls shave's behaviour when no option has been
+dnl given to configure. It defaults to disable.
+dnl
+dnl * SHAVE_INIT should be called late in your configure.(ac|in) file (just
+dnl before AC_CONFIG_FILE/AC_OUTPUT is perfect. This macro rewrites CC and
+dnl LIBTOOL, you don't want the configure tests to have these variables
+dnl re-defined.
+dnl * This macro requires GNU make's -s option.
+
+AC_DEFUN([_SHAVE_ARG_ENABLE],
+[
+ AC_ARG_ENABLE([shave],
+ AS_HELP_STRING(
+ [--enable-shave],
+ [use shave to make the build pretty [[default=$1]]]),,
+ [enable_shave=$1]
+ )
+])
+
+AC_DEFUN([SHAVE_INIT],
+[
+ dnl you can tweak the default value of enable_shave
+ m4_if([$2], [enable], [_SHAVE_ARG_ENABLE(yes)], [_SHAVE_ARG_ENABLE(no)])
+
+ if test x"$enable_shave" = xyes; then
+ dnl where can we find the shave scripts?
+ m4_if([$1],,
+ [shavedir="$ac_pwd"],
+ [shavedir="$ac_pwd/$1"])
+ AC_SUBST(shavedir)
+
+ dnl make is now quiet
+ AC_SUBST([MAKEFLAGS], [-s])
+ AC_SUBST([AM_MAKEFLAGS], ['`test -z $V && echo -s`'])
+
+ dnl we need sed
+ AC_CHECK_PROG(SED,sed,sed,false)
+
+ dnl substitute libtool
+ SHAVE_SAVED_LIBTOOL=$LIBTOOL
+ LIBTOOL="${SHELL} ${shavedir}/shave-libtool '${SHAVE_SAVED_LIBTOOL}'"
+ AC_SUBST(LIBTOOL)
+
+ dnl substitute cc/cxx
+ SHAVE_SAVED_CC=$CC
+ SHAVE_SAVED_CXX=$CXX
+ SHAVE_SAVED_FC=$FC
+ SHAVE_SAVED_F77=$F77
+ SHAVE_SAVED_OBJC=$OBJC
+ CC="${SHELL} ${shavedir}/shave cc ${SHAVE_SAVED_CC}"
+ CXX="${SHELL} ${shavedir}/shave cxx ${SHAVE_SAVED_CXX}"
+ FC="${SHELL} ${shavedir}/shave fc ${SHAVE_SAVED_FC}"
+ F77="${SHELL} ${shavedir}/shave f77 ${SHAVE_SAVED_F77}"
+ OBJC="${SHELL} ${shavedir}/shave objc ${SHAVE_SAVED_OBJC}"
+ AC_SUBST(CC)
+ AC_SUBST(CXX)
+ AC_SUBST(FC)
+ AC_SUBST(F77)
+ AC_SUBST(OBJC)
+
+ V=@
+ else
+ V=1
+ fi
+ Q='$(V:1=)'
+ AC_SUBST(V)
+ AC_SUBST(Q)
+])
+
Index: xsrc/external/mit/xf86-video-radeonhd/dist/shave-libtool.in
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/shave-libtool.in:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/shave-libtool.in Mon Jan 11 00:20:32 2010
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+# we need sed
+s...@sed@
+if test -z "$SED" ; then
+SED=sed
+fi
+
+lt_unmangle ()
+{
+ last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'`
+}
+
+# the real libtool to use
+LIBTOOL="$1"
+shift
+
+# if 1, don't print anything, the underlaying wrapper will do it
+pass_though=0
+
+# scan the arguments, keep the right ones for libtool, and discover the mode
+preserved_args=
+while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --mode=*)
+ mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'`
+ preserved_args="$preserved_args $opt"
+ ;;
+ -o)
+ lt_output="$1"
+ preserved_args="$preserved_args $opt"
+ ;;
+ *)
+ preserved_args="$preserved_args $opt"
+ ;;
+ esac
+done
+
+case "$mode" in
+compile)
+ # shave will be called and print the actual CC/CXX/LINK line
+ preserved_args="$preserved_args --shave-mode=$mode"
+ pass_though=1
+ ;;
+link)
+ preserved_args="$preserved_args --shave-mode=$mode"
+ Q=" LINK "
+ ;;
+*)
+ # let's u
+ # echo "*** libtool: Unimplemented mode: $mode, fill a bug report"
+ ;;
+esac
+
+lt_unmangle "$lt_output"
+output=$last_result
+
+if test -z $V; then
+ if test $pass_though -eq 0; then
+ echo "$Q$output"
+ fi
+ $LIBTOOL --silent $preserved_args
+else
+ echo $LIBTOOL $preserved_args
+ $LIBTOOL $preserved_args
+fi
Index: xsrc/external/mit/xf86-video-radeonhd/dist/shave.in
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/shave.in:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/shave.in Mon Jan 11 00:20:32 2010
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+# we need sed
+s...@sed@
+if test -z "$SED" ; then
+SED=sed
+fi
+
+lt_unmangle ()
+{
+ last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'`
+}
+
+# the tool to wrap (cc, cxx, ar, ranlib, ..)
+tool="$1"
+shift
+
+# the reel tool (to call)
+REEL_TOOL="$1"
+shift
+
+pass_through=0
+preserved_args=
+while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --shave-mode=*)
+ mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'`
+ ;;
+ -o)
+ lt_output="$1"
+ preserved_args="$preserved_args $opt"
+ ;;
+ *)
+ preserved_args="$preserved_args $opt"
+ ;;
+ esac
+done
+
+# mode=link is handled in the libtool wrapper
+case "$mode,$tool" in
+link,*)
+ pass_through=1
+ ;;
+*,cxx)
+ Q=" CXX "
+ ;;
+*,cc)
+ Q=" CC "
+ ;;
+*,fc)
+ Q=" FC "
+ ;;
+*,f77)
+ Q=" F77 "
+ ;;
+*,objc)
+ Q=" OBJC "
+ ;;
+*,*)
+ # should not happen
+ Q=" CC "
+ ;;
+esac
+
+lt_unmangle "$lt_output"
+output=$last_result
+
+if test -z $V; then
+ if test $pass_through -eq 0; then
+ echo "$Q$output"
+ fi
+ $REEL_TOOL $preserved_args
+else
+ echo $REEL_TOOL $preserved_args
+ $REEL_TOOL $preserved_args
+fi
Index: xsrc/external/mit/xf86-video-radeonhd/dist/src/atombios_rev.h
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/src/atombios_rev.h:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/src/atombios_rev.h Mon Jan 11 00:20:32 2010
@@ -0,0 +1,199 @@
+/*
+ * Copyright 2007-2009 Luc Verhaegen <[email protected]>
+ * Copyright 2007-2009 Matthias Hopf <[email protected]>
+ * Copyright 2007-2009 Egbert Eich <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Reverse engineered AtomBIOS entries.
+ * Plus addon information for dynamic data tables.
+ */
+
+/*
+ * Dynamic data tables:
+ * Modify table sizes and offset positions by replacing access code
+ * (e.g. &d->asPowerUnknownInfo[i]) by custom code.
+ * d is the current data structure, data as a char *,
+ * start the main data structure as char *, i is counter.
+ *
+ * #pragma count ATOM_POWERPLAY_INFO_V4 asPowerIndexInfo (d->NumPowerIndexEntries)
+ * #pragma offset ATOM_POWERPLAY_INFO_V4 asPowerIndexInfo (data + d->OffsetPowerIndexEntries + i*d->SizeOfPowerIndexEntry)
+ * #pragma return ATOM_POWERPLAY_INFO_V4 - (d->OffsetPowerUnknownEntries + ATOM_MAX_NUMBEROF_POWERUNKNOWN_BLOCK_V4*d->SizeOfPowerUnknownEntry)
+ *
+ * Has to be issued *before* the offset is encountered. And outside structures.
+ */
+
+typedef struct
+{
+ unsigned char u[2];
+} U16;
+#define _U16(x) (((x).u[1]<<8)|(x).u[0])
+
+typedef struct
+{
+ unsigned char u[3];
+} U24;
+#define _U24(x) (((x).u[2]<<16)|((x).u[1]<<8)|(x).u[0])
+
+#include <stddef.h> /* offsetof() */
+#define COUNT_REMAINDER(s,m,e) ((((ATOM_COMMON_TABLE_HEADER*)d)->usStructureSize-offsetof(s,m)) / sizeof(e))
+#define RETURN_REMAINDER(s,m,e) (d ? (offsetof(s,m) + COUNT_REMAINDER(s,m,e) * sizeof(e)) : 0)
+#define COUNT_ALL(s,e) ((((ATOM_COMMON_TABLE_HEADER*)d)->usStructureSize-sizeof(ATOM_COMMON_TABLE_HEADER)) / sizeof(e))
+#define RETURN_ALL(s,e) (d ? (sizeof(ATOM_COMMON_TABLE_HEADER) + COUNT_ALL(s,e) * sizeof(e)) : 0)
+
+
+/*
+ * Dynamic additions to generic atombios.h
+ */
+#pragma count ATOM_GPIO_I2C_INFO asGPIO_Info COUNT_ALL (ATOM_GPIO_I2C_INFO, ATOM_GPIO_I2C_ASSIGMENT)
+#pragma return ATOM_GPIO_I2C_INFO asGPIO_Info RETURN_ALL (ATOM_GPIO_I2C_INFO, ATOM_GPIO_I2C_ASSIGMENT)
+
+#pragma count ATOM_GPIO_PIN_LUT asGPIO_Pin COUNT_ALL (ATOM_GPIO_PIN_LUT, ATOM_GPIO_PIN_ASSIGNMENT)
+#pragma return ATOM_GPIO_PIN_LUT asGPIO_Pin RETURN_ALL (ATOM_GPIO_PIN_LUT, ATOM_GPIO_PIN_ASSIGNMENT)
+
+#pragma count ATOM_VESA_TO_INTENAL_MODE_LUT asVESA_ToExtendedModeInfo COUNT_ALL (ATOM_VESA_TO_INTENAL_MODE_LUT, ATOM_VESA_TO_EXTENDED_MODE)
+#pragma return ATOM_VESA_TO_INTENAL_MODE_LUT asVESA_ToExtendedModeInfo RETURN_ALL (ATOM_VESA_TO_INTENAL_MODE_LUT, ATOM_VESA_TO_EXTENDED_MODE)
+
+#pragma count ATOM_COMPONENT_VIDEO_INFO aWbGpioStateBlock (d->ucNumOfWbGpioBlocks)
+#pragma count ATOM_COMPONENT_VIDEO_INFO aModeTimings COUNT_REMAINDER (ATOM_COMPONENT_VIDEO_INFO, aModeTimings[0], ATOM_DTD_FORMAT)
+#pragma return ATOM_COMPONENT_VIDEO_INFO - RETURN_REMAINDER (ATOM_COMPONENT_VIDEO_INFO, aModeTimings[0], ATOM_DTD_FORMAT)
+#pragma count ATOM_COMPONENT_VIDEO_INFO_V21 aWbGpioStateBlock (d->ucNumOfWbGpioBlocks)
+#pragma count ATOM_COMPONENT_VIDEO_INFO_V21 aModeTimings COUNT_REMAINDER (ATOM_COMPONENT_VIDEO_INFO_V21, aModeTimings[0], ATOM_DTD_FORMAT)
+#pragma return ATOM_COMPONENT_VIDEO_INFO_V21 - RETURN_REMAINDER (ATOM_COMPONENT_VIDEO_INFO_V21, aModeTimings[0], ATOM_DTD_FORMAT)
+
+#pragma count INDIRECT_IO_ACCESS IOAccessSequence -1 /* No useful information */
+#pragma return INDIRECT_IO_ACCESS IOAccessSequence RETURN_ALL (ATOM_INDIRECT_IO_ACCESS, UCHAR)
+
+#pragma offset ATOM_VRAM_INFO_V3 aVramInfo *(offset_ATOM_VRAM_INFO_V3_aVramInfo(d,i))
+#pragma count ATOM_VRAM_INFO_V3 aVramInfo (count_ATOM_VRAM_INFO_V3_aVramInfo(d))
+#pragma offset ATOM_VRAM_INFO_V3 asMemPatch *(data + d->usMemClkPatchTblOffset)
+/* Needs more love */
+#pragma return ATOM_VRAM_INFO_V3 - 0
+
+/* Doesn't look completely reasonable, but seems ok... */
+#pragma count ATOM_ASIC_PROFILE_VOLTAGE asLeakVol ((d->usSize - offsetof(ATOM_ASIC_PROFILE_VOLTAGE,asLeakVol)) / sizeof(ATOM_LEAKID_VOLTAGE))
+
+#pragma count ATOM_VOLTAGE_FORMULA ucVIDAdjustEntries (d->ucNumOfVoltageEntries)
+#pragma offset ATOM_VOLTAGE_OBJECT_INFO asVoltageObj *(offset_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(d,i))
+#pragma count ATOM_VOLTAGE_OBJECT_INFO asVoltageObj (count_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(d))
+#pragma return ATOM_VOLTAGE_OBJECT_INFO - 0
+
+#pragma count ATOM_POWER_SOURCE_INFO asPwrObj COUNT_REMAINDER (ATOM_POWER_SOURCE_INFO, asPwrObj[0], ATOM_POWER_SOURCE_OBJECT)
+#pragma return ATOM_POWER_SOURCE_INFO - RETURN_REMAINDER (ATOM_POWER_SOURCE_INFO, asPwrObj[0], ATOM_POWER_SOURCE_OBJECT)
+
+/*
+ * Generic atombios.h
+ */
+#include "atombios.h"
+
+static inline char *offset_ATOM_VRAM_INFO_V3_aVramInfo(ATOM_VRAM_INFO_V3 *d, int i) {
+ char *r = (char *)&d->aVramInfo[0];
+ while (i-- > 0)
+ r += ((ATOM_VRAM_MODULE_V3 *)r)->usSize;
+ return r;
+}
+static inline int count_ATOM_VRAM_INFO_V3_aVramInfo(ATOM_VRAM_INFO_V3 *d) {
+ int i=0;
+ char *last = 0, *next;
+ while ( (next = offset_ATOM_VRAM_INFO_V3_aVramInfo(d,i)) - (char*)d < d->usMemAdjustTblOffset && next != last) {
+ last = next;
+ i++;
+ }
+ return i;
+}
+static inline char *offset_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(ATOM_VOLTAGE_OBJECT_INFO *d, int i) {
+ char *r = (char *)&d->asVoltageObj[0];
+ while (i-- > 0)
+ r += ((ATOM_VOLTAGE_OBJECT *)r)->ucSize;
+ return r;
+}
+static inline int count_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(ATOM_VOLTAGE_OBJECT_INFO *d) {
+ int i=0;
+ char *last=0, *next;
+ while ( (next = offset_ATOM_VOLTAGE_OBJECT_INFO_asVoltageObj(d,i)) - (char*)d < d->sHeader.usStructureSize && next != last) {
+ last = next;
+ i++;
+ }
+ return i;
+}
+
+
+/*
+ * Reverse engineered tables
+ */
+
+/* ucTableFormatRevision=4 / ucTableContentRevision=1 */
+
+#pragma count ATOM_POWERINDEX_INFO_V4 Index (((ATOM_POWERPLAY_INFO_V4*)start)->SizeOfPowerIndexEntry-1)
+typedef struct _ATOM_POWERINDEX_INFO_V4
+{
+ UCHAR Type;
+ UCHAR Index[3];
+}ATOM_POWERINDEX_INFO_V4;
+
+typedef struct _ATOM_POWERMODE_INFO_V4
+{
+ U24 engineClock;
+ U24 memoryClock;
+ U16 voltage;
+ U16 unknown8;
+ U16 unknown10;
+ U16 unknown12Flags;
+ U16 unknown14;
+}ATOM_POWERMODE_INFO_V4;
+
+#pragma count ATOM_POWERUNKNOWN_INFO_V4 unknown (((ATOM_POWERPLAY_INFO_V4*)start)->SizeOfPowerUnknownEntry)
+typedef struct _ATOM_POWERUNKNOWN_INFO_V4
+{
+ UCHAR unknown[12];
+}ATOM_POWERUNKNOWN_INFO_V4;
+
+#pragma count ATOM_POWERPLAY_INFO_V4 asPowerIndexInfo (d->NumPowerIndexEntries)
+#pragma offset ATOM_POWERPLAY_INFO_V4 asPowerIndexInfo *(data + _U16(d->OffsetPowerIndexEntries) + i*d->SizeOfPowerIndexEntry)
+#pragma count ATOM_POWERPLAY_INFO_V4 asPowerModeInfo ((_U16(d->OffsetPowerUnknownEntries) - _U16(d->OffsetPowerModeEntries)) / d->SizeOfPowerModeEntry)
+#pragma offset ATOM_POWERPLAY_INFO_V4 asPowerModeInfo *(data + _U16(d->OffsetPowerModeEntries) + i*d->SizeOfPowerModeEntry)
+#pragma count ATOM_POWERPLAY_INFO_V4 asPowerUnknownInfo ((d->sHeader.usStructureSize - _U16(d->OffsetPowerUnknownEntries)) / d->SizeOfPowerUnknownEntry)
+#pragma offset ATOM_POWERPLAY_INFO_V4 asPowerUnknownInfo *(data + _U16(d->OffsetPowerUnknownEntries) + i*d->SizeOfPowerUnknownEntry)
+#pragma return ATOM_POWERPLAY_INFO_V4 - (d ? (_U16(d->OffsetPowerUnknownEntries) + ((d->sHeader.usStructureSize - _U16(d->OffsetPowerUnknownEntries)) / d->SizeOfPowerUnknownEntry)*d->SizeOfPowerUnknownEntry) : 0)
+
+typedef struct _ATOM_POWERPLAY_INFO_V4
+{
+ ATOM_COMMON_TABLE_HEADER sHeader;
+ UCHAR unknown4;
+ UCHAR NumPowerIndexEntries;
+ UCHAR SizeOfPowerIndexEntry;
+ UCHAR SizeOfPowerModeEntry;
+ UCHAR SizeOfPowerUnknownEntry;
+ U16 OffsetPowerIndexEntries;
+ U16 OffsetPowerModeEntries;
+ U16 OffsetPowerUnknownEntries;
+ U16 unknown15[3];
+ U16 unknownFlags;
+ U16 unknown23[5];
+ U16 OffsetPowerModeEntries2;
+ U16 OffsetPowerUnknownEntries2;
+ UCHAR unknown37[3]; /* Only on some BIOSes (e.g. RV770) */
+ ATOM_POWERINDEX_INFO_V4 asPowerIndexInfo[4];
+ ATOM_POWERMODE_INFO_V4 asPowerModeInfo[10];
+ ATOM_POWERUNKNOWN_INFO_V4 asPowerUnknownInfo[4];
+}ATOM_POWERPLAY_INFO_V4;
+
+
Index: xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.c
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.c:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.c Mon Jan 11 00:20:32 2010
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2009 Luc Verhaegen <[email protected]>
+ * Copyright 2009 Matthias Hopf <[email protected]>
+ * Copyright 2009 Egbert Eich <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if HAVE_XF86_ANSIC_H
+# include "xf86_ansic.h"
+#else
+# include <unistd.h>
+# include <sys/types.h>
+# include <dirent.h>
+# include <sys/stat.h>
+# include <fcntl.h>
+# include <stdio.h>
+# include <string.h>
+# include <errno.h>
+#endif
+
+#include "xf86.h"
+
+#include "rhd.h"
+#include "rhd_connector.h"
+#include "rhd_output.h"
+#include "rhd_acpi.h"
+
+
+#define ACPI_PATH "/sys/class/backlight"
+
+/*
+ *
+ */
+static Bool
+rhdDoBacklight(struct rhdOutput *Output, Bool do_write, int *val)
+{
+ DIR *dir = opendir(ACPI_PATH);
+ struct dirent *dirent;
+ char buf[10];
+ RHDFUNC(Output);
+
+ if (!dir)
+ return -1;
+
+ while ((dirent = readdir(dir)) != NULL) {
+ char path[PATH_MAX];
+ int fd_max;
+
+ snprintf(path,PATH_MAX,"%s/%s/max_brightness",ACPI_PATH,dirent->d_name);
+ if ((fd_max = open(path, O_RDONLY)) > 0) {
+ int max_val;
+
+ while ((read(fd_max,buf,9) == -1)
+ && (errno == EINTR || errno == EAGAIN)) {};
+ close (fd_max);
+
+ if (sscanf(buf,"%i\n",&max_val) == 1) {
+ int fd;
+
+ snprintf(path,PATH_MAX,"%s/%s/%s",ACPI_PATH,dirent->d_name,
+ do_write ? "brightness" : "actual_brightness");
+ if ((fd = open(path, do_write ? O_WRONLY : O_RDONLY)) > 0) {
+
+ if (do_write) {
+
+ snprintf(buf,10,"%i\n",(*val * max_val) / RHD_BACKLIGHT_PROPERTY_MAX);
+ while ((write(fd,buf,strlen(buf)) <= 0)
+ && (errno == EINTR || errno == EAGAIN)) {};
+
+ close (fd);
+ closedir (dir);
+ RHDDebug(Output->scrnIndex,"%s: Wrote value %i to %s\n",
+ __func__,*val,path);
+
+ return TRUE;
+ } else {
+ memset(buf,0,10);
+
+ while ((read(fd,buf,9) == -1)
+ && (errno == EINTR || errno == EAGAIN)) {};
+
+ if (sscanf(buf,"%i\n",val) == 1) {
+ *val = (*val * RHD_BACKLIGHT_PROPERTY_MAX) / max_val;
+
+ close(fd);
+ closedir(dir);
+ RHDDebug(Output->scrnIndex,"%s: Read value %i from %s\n",
+ __func__,*val,path);
+
+ return TRUE;
+ }
+ }
+ close (fd);
+ }
+ }
+ }
+ }
+ closedir(dir);
+
+ return FALSE;
+}
+
+/*
+ * RhdACPIGetBacklightControl(): return backlight value in range 0..255;
+ * -1 means no ACPI BL support.
+ */
+int
+RhdACPIGetBacklightControl(struct rhdOutput *Output)
+{
+#ifdef __linux__
+ int ret;
+ RHDFUNC(Output);
+ if (rhdDoBacklight(Output, FALSE, &ret))
+ return ret;
+#endif
+ return -1;
+}
+
+/*
+ *
+ */
+void
+RhdACPISetBacklightControl(struct rhdOutput *Output, int val)
+{
+ RHDFUNC(Output);
+#ifdef __linux__
+ rhdDoBacklight(Output, TRUE, &val);
+#endif
+}
Index: xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.h
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.h:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_acpi.h Mon Jan 11 00:20:32 2010
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2009 Luc Verhaegen <[email protected]>
+ * Copyright 2009 Matthias Hopf <[email protected]>
+ * Copyright 2009 Egbert Eich <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef RHD_ACPI_H
+# define RHD_ACPI_H
+
+int RhdACPIGetBacklightControl(struct rhdOutput *Output);
+void RhdACPISetBacklightControl(struct rhdOutput *Output, int val);
+
+#endif
Index: xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.c
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.c:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.c Mon Jan 11 00:20:32 2010
@@ -0,0 +1,475 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
+ * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Yang Zhao <[email protected]>
+ * Matthias Hopf <[email protected]>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "xf86.h"
+
+#include "rhd.h"
+#include "rhd_pm.h"
+
+#include "rhd_atombios.h"
+
+#ifdef ATOM_BIOS
+
+#define COMPARE_MIN_ENGINE_CLOCK 100000
+#define SAVE_MIN_ENGINE_CLOCK 200000
+#define COMPARE_MAX_ENGINE_CLOCK 3000000
+#define COMPARE_MIN_MEMORY_CLOCK 100000
+#define SAVE_MIN_MEMORY_CLOCK 200000
+#define COMPARE_MAX_MEMORY_CLOCK 3000000
+#define COMPARE_MIN_VOLTAGE 500
+#define COMPARE_MAX_VOLTAGE 2000
+
+static char *PmLevels[] = {
+ "Off", "Idle", "Slow2D", "Fast2D", "Slow3D", "Fast3D", "Max3D", "User"
+} ;
+
+
+static void
+rhdPmPrint (struct rhdPm *Pm, char *name, struct rhdPowerState *state)
+{
+ xf86DrvMsg(Pm->scrnIndex, X_INFO, " %-8s %8d kHz / %8d kHz / %6.3f V\n",
+ name, (int) state->EngineClock, (int) state->MemoryClock,
+ state->VDDCVoltage / 1000.0);
+}
+
+/* Certain clocks require certain voltage settings */
+/* TODO: So far we only know few safe points. Interpolate? */
+static void rhdPmValidateSetting (struct rhdPm *Pm, struct rhdPowerState *setting, int forceVoltage)
+{
+ /* CARD32 compare = setting->VDDCVoltage ? setting->VDDCVoltage : Pm->Current.VDDCVoltage; */
+ if (! setting->EngineClock)
+ setting->EngineClock = Pm->Current.EngineClock;
+ if (setting->EngineClock < Pm->Minimum.EngineClock)
+ setting->EngineClock = Pm->Minimum.EngineClock;
+ if (setting->EngineClock < COMPARE_MIN_ENGINE_CLOCK)
+ setting->EngineClock = SAVE_MIN_ENGINE_CLOCK;
+ if (setting->EngineClock > Pm->Maximum.EngineClock && Pm->Maximum.EngineClock)
+ setting->EngineClock = Pm->Maximum.EngineClock;
+ if (setting->EngineClock > COMPARE_MAX_ENGINE_CLOCK)
+ setting->EngineClock = Pm->Default.EngineClock;
+ if (setting->EngineClock > COMPARE_MAX_ENGINE_CLOCK)
+ setting->EngineClock = 0;
+ if (! setting->MemoryClock)
+ setting->MemoryClock = Pm->Current.MemoryClock;
+ if (setting->MemoryClock < Pm->Minimum.MemoryClock)
+ setting->MemoryClock = Pm->Minimum.MemoryClock;
+ if (setting->MemoryClock < COMPARE_MIN_MEMORY_CLOCK)
+ setting->MemoryClock = SAVE_MIN_MEMORY_CLOCK;
+ if (setting->MemoryClock > Pm->Maximum.MemoryClock && Pm->Maximum.MemoryClock)
+ setting->MemoryClock = Pm->Maximum.MemoryClock;
+ if (setting->MemoryClock > COMPARE_MAX_MEMORY_CLOCK)
+ setting->MemoryClock = Pm->Default.MemoryClock;
+ if (setting->MemoryClock > COMPARE_MAX_MEMORY_CLOCK)
+ setting->MemoryClock = 0;
+ if (! setting->VDDCVoltage)
+ setting->VDDCVoltage = Pm->Current.VDDCVoltage;
+ if (setting->VDDCVoltage < Pm->Minimum.VDDCVoltage)
+ setting->VDDCVoltage = Pm->Minimum.VDDCVoltage;
+ if (setting->VDDCVoltage < COMPARE_MIN_VOLTAGE)
+ setting->VDDCVoltage = Pm->Current.VDDCVoltage;
+ if (setting->VDDCVoltage < COMPARE_MIN_VOLTAGE)
+ setting->VDDCVoltage = 0;
+ if (setting->VDDCVoltage > Pm->Maximum.VDDCVoltage && Pm->Maximum.VDDCVoltage)
+ setting->VDDCVoltage = Pm->Maximum.VDDCVoltage;
+ if (setting->VDDCVoltage > COMPARE_MAX_VOLTAGE)
+ setting->VDDCVoltage = Pm->Default.VDDCVoltage;
+ if (setting->VDDCVoltage > COMPARE_MAX_VOLTAGE)
+ setting->VDDCVoltage = 0;
+ /* TODO: voltage adaption logic missing */
+ /* Only set to lower Voltages than compare if 0 */
+}
+
+static void rhdPmValidateMinMax (struct rhdPm *Pm)
+{
+ if (Pm->Maximum.EngineClock < Pm->Default.EngineClock)
+ Pm->Maximum.EngineClock = Pm->Default.EngineClock;
+ if (Pm->Maximum.MemoryClock < Pm->Default.MemoryClock)
+ Pm->Maximum.MemoryClock = Pm->Default.MemoryClock;
+ if (Pm->Maximum.VDDCVoltage < Pm->Default.VDDCVoltage)
+ Pm->Maximum.VDDCVoltage = Pm->Default.VDDCVoltage;
+ if (Pm->Maximum.EngineClock < Pm->Current.EngineClock)
+ Pm->Maximum.EngineClock = Pm->Current.EngineClock;
+ if (Pm->Maximum.MemoryClock < Pm->Current.MemoryClock)
+ Pm->Maximum.MemoryClock = Pm->Current.MemoryClock;
+ if (Pm->Maximum.VDDCVoltage < Pm->Current.VDDCVoltage)
+ Pm->Maximum.VDDCVoltage = Pm->Current.VDDCVoltage;
+ if((Pm->Minimum.EngineClock > Pm->Default.EngineClock && Pm->Default.EngineClock) || ! Pm->Minimum.EngineClock)
+ Pm->Minimum.EngineClock = Pm->Default.EngineClock;
+ if((Pm->Minimum.MemoryClock > Pm->Default.MemoryClock && Pm->Default.MemoryClock) || ! Pm->Minimum.MemoryClock)
+ Pm->Minimum.MemoryClock = Pm->Default.MemoryClock;
+ if((Pm->Minimum.VDDCVoltage > Pm->Default.VDDCVoltage && Pm->Default.VDDCVoltage) || ! Pm->Minimum.VDDCVoltage)
+ Pm->Minimum.VDDCVoltage = Pm->Default.VDDCVoltage;
+ if((Pm->Minimum.EngineClock > Pm->Current.EngineClock && Pm->Current.EngineClock) || ! Pm->Minimum.EngineClock)
+ Pm->Minimum.EngineClock = Pm->Current.EngineClock;
+ if((Pm->Minimum.MemoryClock > Pm->Current.MemoryClock && Pm->Current.MemoryClock) || ! Pm->Minimum.MemoryClock)
+ Pm->Minimum.MemoryClock = Pm->Current.MemoryClock;
+ if((Pm->Minimum.VDDCVoltage > Pm->Current.VDDCVoltage && Pm->Current.VDDCVoltage) || ! Pm->Minimum.VDDCVoltage)
+ Pm->Minimum.VDDCVoltage = Pm->Current.VDDCVoltage;
+ rhdPmValidateSetting (Pm, &Pm->Maximum, 1);
+ rhdPmValidateSetting (Pm, &Pm->Minimum, 1);
+ rhdPmValidateSetting (Pm, &Pm->Default, 1);
+
+ if (Pm->NumKnown) {
+ int i;
+ for (i = 0; i < Pm->NumKnown; i++) {
+ if (Pm->Maximum.EngineClock < Pm->Known[i].EngineClock)
+ Pm->Maximum.EngineClock = Pm->Known[i].EngineClock;
+ if (Pm->Maximum.MemoryClock < Pm->Known[i].MemoryClock)
+ Pm->Maximum.MemoryClock = Pm->Known[i].MemoryClock;
+ if (Pm->Maximum.VDDCVoltage < Pm->Known[i].VDDCVoltage)
+ Pm->Maximum.VDDCVoltage = Pm->Known[i].VDDCVoltage;
+ if (Pm->Minimum.EngineClock > Pm->Known[i].EngineClock && Pm->Known[i].EngineClock)
+ Pm->Minimum.EngineClock = Pm->Known[i].EngineClock;
+ if (Pm->Minimum.MemoryClock > Pm->Known[i].MemoryClock && Pm->Known[i].MemoryClock)
+ Pm->Minimum.MemoryClock = Pm->Known[i].MemoryClock;
+ if (Pm->Minimum.VDDCVoltage > Pm->Known[i].VDDCVoltage && Pm->Known[i].VDDCVoltage)
+ Pm->Minimum.VDDCVoltage = Pm->Known[i].VDDCVoltage;
+ }
+ }
+
+ if (Pm->Minimum.VDDCVoltage == Pm->Maximum.VDDCVoltage)
+ Pm->Minimum.VDDCVoltage = Pm->Maximum.VDDCVoltage = Pm->Default.VDDCVoltage = 0;
+}
+
+/* Some AtomBIOSes provide broken current clocks (esp. memory) */
+static void rhdPmValidateClearSetting (struct rhdPm *Pm, struct rhdPowerState *setting)
+{
+ if (setting->EngineClock < COMPARE_MIN_ENGINE_CLOCK)
+ setting->EngineClock = 0;
+ if (setting->EngineClock > COMPARE_MAX_ENGINE_CLOCK)
+ setting->EngineClock = 0;
+ if (setting->MemoryClock < COMPARE_MIN_MEMORY_CLOCK)
+ setting->MemoryClock = 0;
+ if (setting->MemoryClock > COMPARE_MAX_MEMORY_CLOCK)
+ setting->MemoryClock = 0;
+ if (setting->VDDCVoltage < COMPARE_MIN_VOLTAGE)
+ setting->VDDCVoltage = 0;
+ if (setting->VDDCVoltage > COMPARE_MAX_VOLTAGE)
+ setting->VDDCVoltage = 0;
+}
+
+/* Have: a list of possible power settings, eventual minimum and maximum settings.
+ * Want: all rhdPowerState_e settings */
+static void rhdPmSelectSettings (RHDPtr rhdPtr)
+{
+ int i;
+ struct rhdPm *Pm = rhdPtr->Pm;
+
+ /* Initialize with default; STORED state is special */
+ for (i = 0; i < RHD_PM_NUM_STATES; i++)
+ memcpy (&Pm->States[i], &Pm->Default, sizeof(struct rhdPowerState));
+
+ /* TODO: This still needs a lot of work */
+
+ /* RHD_PM_OFF: minimum */
+ memcpy (&Pm->States[RHD_PM_OFF], &Pm->Minimum, sizeof (struct rhdPowerState));
+
+ if (rhdPtr->lowPowerMode.val.bool) {
+ /* TODO: copy lowest config with default Voltage/Mem setting? */
+ if (!rhdPtr->lowPowerModeEngineClock.val.integer) {
+ Pm->States[RHD_PM_IDLE].EngineClock = Pm->States[RHD_PM_OFF].EngineClock;
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO,
+ "ForceLowPowerMode: calculated engine clock at %dkHz\n",
+ (int) Pm->States[RHD_PM_IDLE].EngineClock);
+ } else {
+ /* TODO: this should actually set the user mode */
+ Pm->States[RHD_PM_IDLE].EngineClock = rhdPtr->lowPowerModeEngineClock.val.integer;
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO,
+ "ForceLowPowerMode: set idle engine clock to %dkHz\n",
+ (int) Pm->States[RHD_PM_IDLE].EngineClock);
+ }
+
+ if (!rhdPtr->lowPowerModeMemoryClock.val.integer) {
+ Pm->States[RHD_PM_IDLE].MemoryClock = Pm->States[RHD_PM_OFF].MemoryClock;
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO,
+ "ForceLowPowerMode: calculated memory clock at %dkHz\n",
+ (int) Pm->States[RHD_PM_IDLE].MemoryClock);
+ } else {
+ Pm->States[RHD_PM_IDLE].MemoryClock = rhdPtr->lowPowerModeMemoryClock.val.integer;
+ xf86DrvMsg(rhdPtr->scrnIndex, X_INFO,
+ "ForceLowPowerMode: set idle memory clock to %dkHz\n",
+ (int) Pm->States[RHD_PM_IDLE].MemoryClock);
+ }
+
+ rhdPmValidateSetting (Pm, &Pm->States[RHD_PM_IDLE], 1);
+
+ if (rhdPtr->lowPowerModeEngineClock.val.integer < 0) {
+ Pm->States[RHD_PM_IDLE].EngineClock = - rhdPtr->lowPowerModeEngineClock.val.integer;
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING,
+ "ForceLowPowerMode: user requested to ignore validation for engine clock\n");
+ }
+ if (rhdPtr->lowPowerModeMemoryClock.val.integer < 0) {
+ Pm->States[RHD_PM_IDLE].MemoryClock = - rhdPtr->lowPowerModeMemoryClock.val.integer;
+ xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING,
+ "ForceLowPowerMode: user requested to ignore validation for memory clock\n");
+ }
+ }
+
+ memcpy (&Pm->States[RHD_PM_MAX_3D], &Pm->Maximum, sizeof (struct rhdPowerState));
+
+ xf86DrvMsg (rhdPtr->scrnIndex, X_INFO,
+ "Power Management: Final Levels\n");
+ ASSERT (sizeof(PmLevels) / sizeof(char *) == RHD_PM_NUM_STATES);
+ for (i = 0; i < RHD_PM_NUM_STATES; i++)
+ rhdPmPrint (Pm, PmLevels[i], &Pm->States[i]);
+}
+
+static void
+rhdPmGetRawState (RHDPtr rhdPtr, struct rhdPowerState *state)
+{
+ union AtomBiosArg data;
+
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_GET_ENGINE_CLOCK, &data) == ATOM_SUCCESS)
+ state->EngineClock = data.clockValue;
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_GET_MEMORY_CLOCK, &data) == ATOM_SUCCESS)
+ state->MemoryClock = data.clockValue;
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_GET_VOLTAGE, &data) == ATOM_SUCCESS)
+ state->VDDCVoltage = data.val;
+}
+
+static Bool
+rhdPmSetRawState (RHDPtr rhdPtr, struct rhdPowerState *state)
+{
+ union AtomBiosArg data;
+ Bool ret = TRUE;
+ struct rhdPowerState dummy;
+
+ /* TODO: Idle first; find which idles are needed and expose them */
+ /* FIXME: Voltage */
+ /* FIXME: If Voltage is to be rised, then do that first, then change frequencies.
+ * If Voltage is to be lowered, do it the other way round. */
+ if (state->EngineClock && state->EngineClock != rhdPtr->Pm->Current.EngineClock) {
+ data.clockValue = state->EngineClock;
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_SET_ENGINE_CLOCK, &data) == ATOM_SUCCESS)
+ rhdPtr->Pm->Current.EngineClock = state->EngineClock;
+ else
+ ret = FALSE;
+ }
+#if 0 /* don't do for the moment */
+ if (state->MemoryClock && state->MemoryClock != rhdPtr->Pm->Current.MemoryClock) {
+ data.clockValue = state->MemoryClock;
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_SET_MEMORY_CLOCK, &data) != ATOM_SUCCESS)
+ rhdPtr->Pm->Current.MemoryClock = state->MemoryClock;
+ else
+ ret = FALSE;
+ }
+#endif
+#if 0 /* don't do for the moment */
+ if (state->VDDCVoltage && state->VDDCVoltage != rhdPtr->Pm->Current.VDDCVoltage) {
+ data.val = state->VDDCVoltage;
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_SET_VOLTAGE, &data) != ATOM_SUCCESS)
+ rhdPtr->Pm->Current.VDDCVoltage = state->VDDCVoltage;
+ else
+ ret = FALSE;
+ }
+#endif
+
+ /* AtomBIOS might change values, so that later comparisons would fail, even
+ * if re-setting wouldn't change the actual values. So don't save real
+ * state in Current, but update only to current values. */
+ rhdPmGetRawState (rhdPtr, &dummy);
+ return ret;
+}
+
+
+/*
+ * API
+ */
+
+static Bool
+rhdPmSelectState (RHDPtr rhdPtr, enum rhdPowerState_e num)
+{
+ return rhdPmSetRawState (rhdPtr, &rhdPtr->Pm->States[num]);
+}
+
+static Bool
+rhdPmDefineState (RHDPtr rhdPtr, enum rhdPowerState_e num, struct rhdPowerState *state)
+{
+ ASSERT(0);
+}
+
+void RHDPmInit(RHDPtr rhdPtr)
+{
+ struct rhdPm *Pm = (struct rhdPm *) xnfcalloc(sizeof(struct rhdPm), 1);
+ union AtomBiosArg data;
+ RHDFUNC(rhdPtr);
+
+ rhdPtr->Pm = Pm;
+
+ Pm->scrnIndex = rhdPtr->scrnIndex;
+ Pm->SelectState = rhdPmSelectState;
+ Pm->DefineState = rhdPmDefineState;
+
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_GET_CHIP_LIMITS, &data) != ATOM_SUCCESS) {
+ /* Not getting the information is fatal */
+ xfree (Pm);
+ rhdPtr->Pm = NULL;
+ return;
+ }
+ memcpy (&Pm->Minimum, &data.chipLimits.Minimum, sizeof (struct rhdPowerState));
+ memcpy (&Pm->Maximum, &data.chipLimits.Maximum, sizeof (struct rhdPowerState));
+ memcpy (&Pm->Default, &data.chipLimits.Default, sizeof (struct rhdPowerState));
+
+ memcpy (&Pm->Current, &Pm->Default, sizeof (Pm->Default));
+ rhdPmGetRawState (rhdPtr, &Pm->Current);
+ rhdPmValidateClearSetting (Pm, &Pm->Current);
+
+ xf86DrvMsg (rhdPtr->scrnIndex, X_INFO,
+ "Power Management: used engine clock / memory clock / core (VDDC) voltage (0: ignore)\n");
+ xf86DrvMsg (rhdPtr->scrnIndex, X_INFO, "Power Management: Raw Ranges\n");
+ rhdPmPrint (Pm, "Minimum", &Pm->Minimum);
+ rhdPmPrint (Pm, "Maximum", &Pm->Maximum);
+ rhdPmPrint (Pm, "Default", &Pm->Default);
+
+ if (RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_GET_CHIP_CONFIGS, &data) == ATOM_SUCCESS) {
+ Pm->NumKnown = data.chipConfigs.num;
+ Pm->Known = data.chipConfigs.Settings;
+ } else
+ xf86DrvMsg (rhdPtr->scrnIndex, X_ERROR,
+ "Power Management: Cannot get known good chip configurations\n");
+
+ /* Validate */
+ if (! Pm->Default.EngineClock || ! Pm->Default.MemoryClock)
+ memcpy (&Pm->Default, &Pm->Current, sizeof (Pm->Current));
+ rhdPmValidateMinMax (Pm);
+ rhdPmValidateSetting (Pm, &Pm->Current, 0);
+
+ xf86DrvMsg (rhdPtr->scrnIndex, X_INFO, "Power Management: Validated Ranges\n");
+ rhdPmPrint (Pm, "Minimum", &Pm->Minimum);
+ rhdPmPrint (Pm, "Maximum", &Pm->Maximum);
+ rhdPmPrint (Pm, "Default", &Pm->Default);
+
+ if (Pm->NumKnown) {
+ int i;
+ xf86DrvMsg (rhdPtr->scrnIndex, X_INFO,
+ "Power Management: Known Good Configurations\n");
+ for (i = 0; i < Pm->NumKnown; i++) {
+ char buf[4]; /* number of known entries is 8bit */
+ snprintf (buf, 4, "%d", i+1);
+ rhdPmPrint (Pm, buf, &Pm->Known[i]);
+ }
+ }
+
+ rhdPmSelectSettings (rhdPtr);
+ /* TODO: cleanup function: xfree(): Pm->Known[], Pm */
+}
+
+#else /* ATOM_BIOS */
+
+void
+RHDPmInit (RHDPtr rhdPtr)
+{
+ rhdPtr->Pm = NULL;
+}
+
+#endif /* ATOM_BIOS */
+
+
+/*
+ * save current engine clock
+ */
+void
+RHDPmSave (RHDPtr rhdPtr)
+{
+ struct rhdPm *Pm = rhdPtr->Pm;
+ RHDFUNC(rhdPtr);
+
+#ifdef ATOM_BIOS
+ /* ATM unconditionally enable power management features
+ * if low power mode requested */
+ if (rhdPtr->atomBIOS) {
+ union AtomBiosArg data;
+
+ data.val = 1;
+ RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_PM_SETUP, &data);
+ if (rhdPtr->ChipSet < RHD_R600) {
+ data.val = 1;
+ RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_PM_CLOCKGATING_SETUP, &data);
+ }
+ }
+#endif
+
+ if (!Pm) return;
+
+ memcpy (&Pm->Stored, &Pm->Default, sizeof (Pm->Default));
+ rhdPmGetRawState (rhdPtr, &Pm->Stored);
+ rhdPmValidateClearSetting (Pm, &Pm->Stored);
+}
+
+/*
+ * restore saved engine clock
+ */
+void
+RHDPmRestore (RHDPtr rhdPtr)
+{
+ struct rhdPm *Pm = rhdPtr->Pm;
+
+ RHDFUNC(rhdPtr);
+
+#ifdef ATOM_BIOS
+ /* Don't know how to save state yet - unconditionally disable */
+ if (rhdPtr->atomBIOS) {
+ union AtomBiosArg data;
+
+ data.val = 0;
+ RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_PM_SETUP, &data);
+ if (rhdPtr->ChipSet < RHD_R600) {
+ data.val = 0;
+ RHDAtomBiosFunc (rhdPtr->scrnIndex, rhdPtr->atomBIOS,
+ ATOM_PM_CLOCKGATING_SETUP, &data);
+ }
+ }
+#endif
+
+ if (!Pm)
+ return;
+
+ if (! Pm->Stored.EngineClock && ! Pm->Stored.MemoryClock) {
+ xf86DrvMsg (Pm->scrnIndex, X_ERROR, "%s: trying to restore "
+ "uninitialized values.\n", __func__);
+ return;
+ }
+ rhdPmSetRawState (rhdPtr, &Pm->Stored);
+}
+
Index: xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.h
diff -u /dev/null xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.h:1.1.1.1.2.2
--- /dev/null Mon Jan 11 00:20:32 2010
+++ xsrc/external/mit/xf86-video-radeonhd/dist/src/rhd_pm.h Mon Jan 11 00:20:32 2010
@@ -0,0 +1,78 @@
+/*
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation on the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial
+ * portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
+ * THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _RHD_PM_H
+# define _RHD_PM_H
+
+/* Note about settings: RHD_PM_OFF may always change the memory clock, while
+ * for the others it remains to be seen whether we can change it without video
+ * disturbance. */
+/* TODO: forced settings overwrite default settings (Q: in which cases? RHD_PM_OFF?) */
+enum rhdPowerState_e {
+ /* DPMS off (Q: what about screensavers, what about 3D offscreen rendering apps) */
+ RHD_PM_OFF,
+ /* DPMS on, no activity for some time */
+ RHD_PM_IDLE,
+ /* Simple 2D activity */
+ RHD_PM_SLOW_2D,
+ /* Advanced 2D activity, e.g. video playback */
+ RHD_PM_FAST_2D,
+ /* Simple 3D activity, e.g. compiz (Q: how to select? indirect rendering only? */
+ RHD_PM_SLOW_3D,
+ /* Fast 3D activity, e.g. games. Usually using default AtomBIOS setting. */
+ RHD_PM_FAST_3D,
+ /* Use theoretical chip maximum, maybe beyond default - not selected automatically */
+ RHD_PM_MAX_3D,
+ /* User supplied */
+ RHD_PM_USER,
+ RHD_PM_NUM_STATES
+};
+
+struct rhdPm {
+ int scrnIndex;
+
+ /* R/O */
+ struct rhdPowerState Default;
+ struct rhdPowerState Minimum;
+ struct rhdPowerState Maximum;
+ /* Known good settings (in addition to Default). May be NULL */
+ int NumKnown;
+ struct rhdPowerState *Known;
+
+ struct rhdPowerState States[RHD_PM_NUM_STATES];
+ struct rhdPowerState Current;
+ struct rhdPowerState Stored;
+
+ Bool (*DefineState) (RHDPtr rhdPtr, enum rhdPowerState_e num, struct rhdPowerState *state);
+ Bool (*SelectState) (RHDPtr rhdPtr, enum rhdPowerState_e num);
+#if 0 /* TODO: expose? */
+ Bool (*SetRawState) (RHDPtr rhdPtr, struct rhdPowerState *state);
+ void (*GetRawState) (RHDPtr rhdPtr, struct rhdPowerState *state);
+#endif
+};
+
+void RHDPmInit(RHDPtr rhdPtr);
+void RHDPmSave(RHDPtr rhdPtr);
+void RHDPmRestore(RHDPtr rhdPtr);
+
+#endif /* _RHD_PM_H */