|
|
@ -1,397 +0,0 @@ |
|
|
|
# --- ROCK-COPYRIGHT-NOTE-BEGIN --- |
|
|
|
# |
|
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
|
|
# Please add additional copyright information _after_ the line containing |
|
|
|
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by |
|
|
|
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text! |
|
|
|
# |
|
|
|
# ROCK Linux: rock-src/package/rene/cpufreqd/pmu-official.patch |
|
|
|
# ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf |
|
|
|
# |
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
|
|
# it under the terms of the GNU General Public License as published by |
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
|
|
# (at your option) any later version. A copy of the GNU General Public |
|
|
|
# License can be found at Documentation/COPYING. |
|
|
|
# |
|
|
|
# Many people helped and are helping developing ROCK Linux. Please |
|
|
|
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM |
|
|
|
# file for details. |
|
|
|
# |
|
|
|
# --- ROCK-COPYRIGHT-NOTE-END --- |
|
|
|
|
|
|
|
|
|
|
|
Author: |
|
|
|
Copyright (C) 2003 Rene Rebe (rene@rocklinux.org) |
|
|
|
|
|
|
|
diff -urN cpufreqd-1.0/AUTHORS cpufreqd-1.0-pmu/AUTHORS
|
|
|
|
--- cpufreqd-1.0/AUTHORS 2003-06-23 11:15:02.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/AUTHORS 2003-07-24 19:58:50.000000000 +0200
|
|
|
|
@@ -1,2 +1,3 @@
|
|
|
|
Mattia Dongili <dongili@supereva.it> |
|
|
|
George Staikos <staikos@0wned.org> |
|
|
|
+Rene Rebe <rene@rocklinux.org>
|
|
|
|
diff -urN cpufreqd-1.0/Makefile.am cpufreqd-1.0-pmu/Makefile.am
|
|
|
|
--- cpufreqd-1.0/Makefile.am 2003-06-23 21:35:40.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/Makefile.am 2003-07-24 18:25:15.000000000 +0200
|
|
|
|
@@ -13,7 +13,8 @@
|
|
|
|
|
|
|
|
lib_LTLIBRARIES = \ |
|
|
|
libsys_acpi.la \ |
|
|
|
- libsys_apm.la
|
|
|
|
+ libsys_apm.la \
|
|
|
|
+ libsys_pmu.la
|
|
|
|
|
|
|
|
libsys_acpi_la_SOURCES=libsys_acpi.c |
|
|
|
libsys_acpi_la_LDFLAGS=-module -avoid-version |
|
|
|
@@ -21,6 +22,10 @@
|
|
|
|
libsys_apm_la_SOURCES=libsys_apm.c |
|
|
|
libsys_apm_la_LDFLAGS=-module -avoid-version |
|
|
|
|
|
|
|
+libsys_pmu_la_SOURCES=libsys_pmu.c
|
|
|
|
+libsys_pmu_la_LDFLAGS=-module -avoid-version
|
|
|
|
+
|
|
|
|
+
|
|
|
|
noinst_HEADERS = \ |
|
|
|
config_parser.h \ |
|
|
|
cpufreqd.h \ |
|
|
|
diff -urN cpufreqd-1.0/config_parser.c cpufreqd-1.0-pmu/config_parser.c
|
|
|
|
--- cpufreqd-1.0/config_parser.c 2003-06-23 11:15:02.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/config_parser.c 2003-07-24 19:59:36.000000000 +0200
|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
/* |
|
|
|
* Copyright (C) 2002-2003 Mattia Dongili<dongili@supereva.it> |
|
|
|
* George Staikos <staikos@0wned.org> |
|
|
|
+ * Rene Rebe <rene@rocklinux.org>
|
|
|
|
* |
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
@@ -194,7 +195,12 @@
|
|
|
|
g->poll_interval = 1; |
|
|
|
} |
|
|
|
} else if (strcmp(name,"pm_type") == 0) { |
|
|
|
- g->pm_type = strcmp(value,"apm")==0 ? PM_TYPE_APM : PM_TYPE_ACPI;
|
|
|
|
+ if (strcmp(value,"acpi")==0)
|
|
|
|
+ g->pm_type = PM_TYPE_ACPI;
|
|
|
|
+ else if (strcmp(value,"pmu")==0)
|
|
|
|
+ g->pm_type = PM_TYPE_PMU;
|
|
|
|
+ else
|
|
|
|
+ g->pm_type = PM_TYPE_APM;
|
|
|
|
} else if (strcmp(name,"pidfile") == 0) { |
|
|
|
strncpy(g->pidfile, value, 511); |
|
|
|
g->pidfile[511] = 0; |
|
|
|
diff -urN cpufreqd-1.0/cpufreqd.conf cpufreqd-1.0-pmu/cpufreqd.conf
|
|
|
|
--- cpufreqd-1.0/cpufreqd.conf 2003-06-23 14:18:19.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/cpufreqd.conf 2003-07-24 18:35:49.000000000 +0200
|
|
|
|
@@ -26,7 +26,7 @@
|
|
|
|
[General] |
|
|
|
pidfile=/var/run/cpufreqd.pid |
|
|
|
poll_interval=2 |
|
|
|
- pm_type=acpi # (apm/acpi) (default: apm)
|
|
|
|
+ pm_type=apm # (apm/acpi/pmu) (default: apm)
|
|
|
|
|
|
|
|
|
|
|
|
[Profile] |
|
|
|
diff -urN cpufreqd-1.0/main.c cpufreqd-1.0-pmu/main.c
|
|
|
|
--- cpufreqd-1.0/main.c 2003-06-23 16:53:17.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/main.c 2003-07-24 18:41:45.000000000 +0200
|
|
|
|
@@ -138,6 +138,9 @@
|
|
|
|
const char* error; /* pointer to an error message, if any */ |
|
|
|
|
|
|
|
switch (configuration->pm_type) { |
|
|
|
+ case PM_TYPE_PMU:
|
|
|
|
+ snprintf(libsysname, 512, CPUFREQD_LIBDIR"libsys_%s.so", "pmu");
|
|
|
|
+ break;
|
|
|
|
case PM_TYPE_ACPI: |
|
|
|
snprintf(libsysname, 512, CPUFREQD_LIBDIR"libsys_%s.so", "acpi"); |
|
|
|
break; |
|
|
|
diff -urN cpufreqd-1.0/manpages/cpufreqd.1 cpufreqd-1.0-pmu/manpages/cpufreqd.1
|
|
|
|
--- cpufreqd-1.0/manpages/cpufreqd.1 2003-06-23 20:31:34.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/manpages/cpufreqd.1 2003-07-24 18:38:36.000000000 +0200
|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
.\" Copyright 2002-2003, George Staikos (staikos@0wned.org) |
|
|
|
.\" Mattia Dongili (dongili@supereva.it) |
|
|
|
+.\" Rene Rebe (rene@rocklinux.org)
|
|
|
|
.\" This file may be used subject to the terms and conditions of the |
|
|
|
.\" GNU General Public License Version 2, or any later version |
|
|
|
.\" at your option, as published by the Free Software Foundation. |
|
|
|
@@ -55,6 +56,10 @@
|
|
|
|
.I /proc/acpi |
|
|
|
kernel power management interface (ACPI) |
|
|
|
.TP |
|
|
|
+.I /proc/pmu
|
|
|
|
+kernel power management interface (PMU)
|
|
|
|
+
|
|
|
|
+.TP
|
|
|
|
.I /etc/cpufreqd.conf |
|
|
|
.B cpufreqd |
|
|
|
configuration file |
|
|
|
@@ -68,4 +73,5 @@
|
|
|
|
George Staikos <staikos@0wned.org> |
|
|
|
.TP |
|
|
|
Mattia Dongili <dongili@supereva.it> |
|
|
|
-
|
|
|
|
+.TP
|
|
|
|
+Rene Rebe <rene@rocklinux.org>
|
|
|
|
diff -urN cpufreqd-1.0/manpages/cpufreqd.conf.5 cpufreqd-1.0-pmu/manpages/cpufreqd.conf.5
|
|
|
|
--- cpufreqd-1.0/manpages/cpufreqd.conf.5 2003-06-23 11:15:02.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/manpages/cpufreqd.conf.5 2003-07-24 18:39:03.000000000 +0200
|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
.\" Copyright 2002-2003, George Staikos (staikos@0wned.org) |
|
|
|
.\" Mattia Dongili (dongili@supereva.it) |
|
|
|
+.\" Rene Rebe (rene@rocklinux.org)
|
|
|
|
.\" This file may be used subject to the terms and conditions of the |
|
|
|
.\" GNU General Public License Version 2, or any later version |
|
|
|
.\" at your option, as published by the Free Software Foundation. |
|
|
|
@@ -65,11 +66,12 @@
|
|
|
|
.B "pm_type" |
|
|
|
Can be either |
|
|
|
.B "apm" |
|
|
|
-or
|
|
|
|
-.B "acpi".
|
|
|
|
+.B "acpi"
|
|
|
|
+or
|
|
|
|
+.B "pmu".
|
|
|
|
Depending on this value |
|
|
|
.B cpufreqd |
|
|
|
-will try to read from /proc/apm or /proc/acpi. You will need to enable power
|
|
|
|
+will try to read from /proc/apm, /proc/acpi or /proc/pmu. You will need to enable power
|
|
|
|
management in you kernel configuration. (default: apm) |
|
|
|
|
|
|
|
.TP |
|
|
|
--- cpufreqd-1.0/libsys_pmu.c 1970-01-01 01:00:00.000000000 +0100
|
|
|
|
+++ cpufreqd-1.0-pmu//libsys_pmu.c 2003-07-25 23:30:37.000000000 +0200
|
|
|
|
@@ -0,0 +1,197 @@
|
|
|
|
+/*
|
|
|
|
+ * Copyright (C) 2003 Rene Rebe <rene@rocklinux.org>
|
|
|
|
+ *
|
|
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
|
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+ * (at your option) any later version.
|
|
|
|
+ *
|
|
|
|
+ * This program is distributed in the hope that it will be useful,
|
|
|
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
+ * GNU General Public License for more details.
|
|
|
|
+ *
|
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
|
+ * along with this program; if not, write to the Free Software
|
|
|
|
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
+ *
|
|
|
|
+ * Based upon the acpi version:
|
|
|
|
+ * Copyright (C) 2002-2003 Mattia Dongili<dongili@supereva.it>
|
|
|
|
+ * George Staikos <staikos@0wned.org>
|
|
|
|
+ */
|
|
|
|
+#include "cpufreqd.h"
|
|
|
|
+
|
|
|
|
+#define DEBUG_PMU 1
|
|
|
|
+
|
|
|
|
+char info_file[255];
|
|
|
|
+char bat_file[255];
|
|
|
|
+char tag[255];
|
|
|
|
+char val[255];
|
|
|
|
+char version[101];
|
|
|
|
+short int err = 0;
|
|
|
|
+int bat_num = 0;
|
|
|
|
+
|
|
|
|
+int tokenize (FILE *fp, char *t, char *v) {
|
|
|
|
+ char *str, *str2;
|
|
|
|
+ *t = 0; *v = 0;
|
|
|
|
+
|
|
|
|
+ if (fgets(t, 255, fp) == NULL)
|
|
|
|
+ return EOF;
|
|
|
|
+
|
|
|
|
+ /* remove trailing newline */
|
|
|
|
+ str = t + strlen (t);
|
|
|
|
+ if (str != t) {
|
|
|
|
+ --str;
|
|
|
|
+ if (*str == '\n')
|
|
|
|
+ *str = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* search the first ':' - the seperator */
|
|
|
|
+ for (str = t ; str != t + strlen (t); ++str)
|
|
|
|
+ if (*str == ':')
|
|
|
|
+ break;
|
|
|
|
+ str2 = str;
|
|
|
|
+
|
|
|
|
+ /* skip the ':' and normally present ' ' */
|
|
|
|
+ if (*str == ':')
|
|
|
|
+ ++str;
|
|
|
|
+ if (*str == ' ')
|
|
|
|
+ ++str;
|
|
|
|
+
|
|
|
|
+ /* the string can not be longer than 255 chars - anyway */
|
|
|
|
+ strncpy (v, str, 255);
|
|
|
|
+
|
|
|
|
+ /* skip the ':' the pointer should point to */
|
|
|
|
+ if (*str2 == ':')
|
|
|
|
+ --str2;
|
|
|
|
+
|
|
|
|
+ /* remove trailing spaces from the tag */
|
|
|
|
+ for ( ; str2 != t ; --str2) {
|
|
|
|
+ if ( *str2 == ' ')
|
|
|
|
+ *str2 = 0;
|
|
|
|
+ else
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* void libsys_init(void)
|
|
|
|
+ *
|
|
|
|
+ * Initialize local variables.
|
|
|
|
+ */
|
|
|
|
+void libsys_init(void) {
|
|
|
|
+
|
|
|
|
+ FILE *fp;
|
|
|
|
+
|
|
|
|
+ snprintf(info_file, 255, "%s/info", PMU_PROC_DIR);
|
|
|
|
+ snprintf(bat_file, 255, "%s/battery_0", PMU_PROC_DIR);
|
|
|
|
+
|
|
|
|
+ fp = fopen(info_file, "r");
|
|
|
|
+ if (!fp) {
|
|
|
|
+ syslog(LOG_ERR, "libsys_init(): %s: %s\n", info_file, strerror(errno));
|
|
|
|
+ err++;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ while (tokenize(fp, tag, val) != EOF) {
|
|
|
|
+
|
|
|
|
+ if (strcmp (tag, "PMU driver version") == 0) {
|
|
|
|
+ sprintf (version, "%s - ", val);
|
|
|
|
+ }
|
|
|
|
+ else if (strcmp (tag, "PMU firmware version") == 0) {
|
|
|
|
+ strcat (version, val);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fclose(fp);
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* void libsys_fini (void)
|
|
|
|
+ *
|
|
|
|
+ * Free allocated structures.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+void libsys_fini (void) {
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* int scan_system_info(sys_info *s)
|
|
|
|
+ *
|
|
|
|
+ * Reads PMU info and fills the input sys_info struct.
|
|
|
|
+ * Implements the prototype needed by cpufreqd to get
|
|
|
|
+ * info from the PM layer.
|
|
|
|
+ *
|
|
|
|
+ * Returns 0 on success, -1 otherwise
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+int scan_system_info(sys_info *s) {
|
|
|
|
+
|
|
|
|
+ FILE *fp;
|
|
|
|
+
|
|
|
|
+ float bat_charge = .0;
|
|
|
|
+ float bat_max_charge = .0;
|
|
|
|
+
|
|
|
|
+ /* check if _init was successful */
|
|
|
|
+ if (err>0)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ /* set version information */
|
|
|
|
+ strncpy(s->version, version, 101);
|
|
|
|
+
|
|
|
|
+ /** /proc/pmu/info **/
|
|
|
|
+ fp = fopen(info_file, "r");
|
|
|
|
+ if (!fp) {
|
|
|
|
+ syslog(LOG_ERR, "libsys_init(): %s: %s\n", info_file, strerror(errno));
|
|
|
|
+ err++;
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ while (tokenize(fp, tag, val) != EOF) {
|
|
|
|
+
|
|
|
|
+ if (strcmp (tag, "AC Power") == 0) {
|
|
|
|
+ s->ac = atoi (val);
|
|
|
|
+ }
|
|
|
|
+ else if (strcmp (tag, "Battery count") == 0) {
|
|
|
|
+ s->has_battery = atoi (val);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ fclose(fp);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /** /proc/pmu/battery_0 **/
|
|
|
|
+ fp = fopen(bat_file, "r");
|
|
|
|
+ if (!fp) {
|
|
|
|
+ syslog(LOG_ERR, "scan_system_info(): %s: %s\n", bat_file, strerror(errno));
|
|
|
|
+ return(-1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ while (tokenize(fp, tag, val) != EOF) {
|
|
|
|
+ if (strcmp (tag, "charge") == 0) {
|
|
|
|
+ bat_charge = atof (val);
|
|
|
|
+ }
|
|
|
|
+ else if (strcmp (tag, "max_charge") == 0) {
|
|
|
|
+ bat_max_charge = atof (val);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ s->battery_percent = 100 * (bat_charge / bat_max_charge);
|
|
|
|
+
|
|
|
|
+#ifdef DEBUG_PMU
|
|
|
|
+ syslog(LOG_INFO, "scan_system_info(): battery %s - %d - %s\n",
|
|
|
|
+ s->has_battery?"present":"absent",
|
|
|
|
+ s->battery_percent,
|
|
|
|
+ s->ac?"on-line":"off-line");
|
|
|
|
+#endif
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#ifdef DEBUG_PMU
|
|
|
|
+int main ()
|
|
|
|
+{
|
|
|
|
+ sys_info info;
|
|
|
|
+
|
|
|
|
+ libsys_init();
|
|
|
|
+ scan_system_info (&info);
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
--- cpufreqd-1.0/cpufreqd.h 2003-06-23 16:10:48.000000000 +0200
|
|
|
|
+++ cpufreqd-1.0-pmu/cpufreqd.h 2003-07-25 23:32:42.000000000 +0200
|
|
|
|
@@ -1,6 +1,7 @@
|
|
|
|
/* |
|
|
|
* Copyright (C) 2002-2003 Mattia Dongili<dongili@supereva.it> |
|
|
|
* George Staikos <staikos@0wned.org> |
|
|
|
+ * Rene Rebe <rene@rocklinux.org>
|
|
|
|
* |
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
|
|
* it under the terms of the GNU General Public License as published by |
|
|
|
@@ -60,6 +61,7 @@
|
|
|
|
#define ACPI_PROC_DIR "/proc/acpi/" |
|
|
|
#define ACPI_BATTERY_DIR "/proc/acpi/battery/" |
|
|
|
#define ACPI_AC_DIR "/proc/acpi/ac_adapter/" |
|
|
|
+#define PMU_PROC_DIR "/proc/pmu"
|
|
|
|
|
|
|
|
#define CPUFREQ_SYSFS_INTERFACE "/sys/devices/sys/cpu0" |
|
|
|
#define CPUFREQ_SYSFS_INTERFACE_POLICY "/sys/devices/sys/cpu0/scaling_governor" |
|
|
|
@@ -72,6 +74,7 @@
|
|
|
|
|
|
|
|
#define PM_TYPE_APM 0 |
|
|
|
#define PM_TYPE_ACPI 1 |
|
|
|
+#define PM_TYPE_PMU 2
|
|
|
|
|
|
|
|
typedef struct { |
|
|
|
short int min; |
|
|
|
@@ -109,9 +112,6 @@
|
|
|
|
char time[101]; |
|
|
|
} sys_info; |
|
|
|
|
|
|
|
-#define PM_TYPE_APM 0
|
|
|
|
-#define PM_TYPE_ACPI 1
|
|
|
|
-
|
|
|
|
#define MATCH_AC 4 |
|
|
|
#define MATCH_BATTERY 2 |
|
|
|
#define MATCH_PROG 1 |