summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorh8red2015-09-14 22:43:40 +0300
committerh8red2015-09-14 22:43:40 +0300
commitd630474da42dd527731eb8e7cbfc642feb60766c (patch)
treefc04e72acc243427e18506865acdee868e9842f0
downloadaur-d630474da42dd527731eb8e7cbfc642feb60766c.tar.gz
Initial import
-rw-r--r--.SRCINFO26
-rw-r--r--PKGBUILD53
-rw-r--r--cpufreqd35
-rw-r--r--cpufreqd.service10
-rw-r--r--cpufreqd_acpi_battery.c.patch176
-rw-r--r--cpupower.patch24
6 files changed, 324 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..affe722b6cb9
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,26 @@
+pkgbase = cpufreqd
+ pkgdesc = A small daemon to adjust cpu speed (and indeed voltage)
+ pkgver = 2.4.2
+ pkgrel = 9
+ url = http://www.linux.it/~malattia/wiki/index.php/Cpufreqd
+ arch = i686
+ arch = x86_64
+ license = GPL2
+ makedepends = autoconf
+ depends = cpupower
+ depends = lm_sensors
+ options = !libtool
+ backup = etc/cpufreqd.conf
+ source = http://downloads.sourceforge.net/cpufreqd/cpufreqd-2.4.2.tar.bz2
+ source = cpufreqd
+ source = cpufreqd.service
+ source = cpufreqd_acpi_battery.c.patch
+ source = cpupower.patch
+ md5sums = 2ca80a77849c9a69b81e27c1843c97f5
+ md5sums = 4d0fafbdb5f1b7313fdeb6f1250ef34f
+ md5sums = 4213dced234d7700dd012d3f63349cd1
+ md5sums = d0df76dce1bc6cc021b199f820b748b9
+ md5sums = cbc349fa8d4e83a45e9c9e45356648be
+
+pkgname = cpufreqd
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..2b5a6aa94823
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,53 @@
+# Maintainer: h8red h8red at yandex dot ru
+# Contributor: Blaž Tomažič <blaz.tomazic@gmail.com>
+# Contributor: Andrea Scarpino <andrea@archlinux.org>
+# Contributor: Kevin Piche <kevin@archlinux.org>
+# Contributor: Manolis Tzanidakis <manolis@archlinux.org>
+
+pkgname=cpufreqd
+pkgver=2.4.2
+pkgrel=9
+pkgdesc="A small daemon to adjust cpu speed (and indeed voltage)"
+arch=('i686' 'x86_64')
+url="http://www.linux.it/~malattia/wiki/index.php/Cpufreqd"
+license=('GPL2')
+depends=('cpupower' 'lm_sensors')
+makedepends=('autoconf')
+backup=('etc/cpufreqd.conf')
+options=('!libtool')
+source=("http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.bz2"
+ 'cpufreqd'
+ 'cpufreqd.service'
+ 'cpufreqd_acpi_battery.c.patch'
+ 'cpupower.patch')
+md5sums=('2ca80a77849c9a69b81e27c1843c97f5'
+ '4d0fafbdb5f1b7313fdeb6f1250ef34f'
+ '4213dced234d7700dd012d3f63349cd1'
+ 'd0df76dce1bc6cc021b199f820b748b9'
+ 'cbc349fa8d4e83a45e9c9e45356648be')
+
+build() {
+ cd ${srcdir}
+
+
+ cd ${pkgname}-${pkgver}
+
+ #patch acpi
+ patch -p0 < ${srcdir}/cpufreqd_acpi_battery.c.patch
+
+ #patch for cpupower support
+ patch -p0 < ${srcdir}/cpupower.patch
+ autoreconf -i
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc --sbindir=/usr/bin
+ make || return 1
+}
+
+package() {
+ cd ${srcdir}/${pkgname}-${pkgver}
+ make DESTDIR=${pkgdir} install || return 1
+
+ install -Dm755 ${srcdir}/cpufreqd ${pkgdir}/etc/rc.d/cpufreqd || return 1
+ install -Dm644 ${srcdir}/cpufreqd.service ${pkgdir}/usr/lib/systemd/system/cpufreqd.service || return 1
+}
diff --git a/cpufreqd b/cpufreqd
new file mode 100644
index 000000000000..d2f2a89bf6e6
--- /dev/null
+++ b/cpufreqd
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+PID=`pidof -o %PPID /usr/bin/cpufreqd`
+case "$1" in
+ start)
+ stat_busy "Starting cpufreqd"
+ [ -z "$PID" ] && /usr/bin/cpufreqd
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ add_daemon cpufreqd
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping cpufreqd"
+ [ ! -z "$PID" ] && kill $PID &> /dev/null
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon cpufreqd
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac
+exit 0
diff --git a/cpufreqd.service b/cpufreqd.service
new file mode 100644
index 000000000000..5bcd8c1c4df6
--- /dev/null
+++ b/cpufreqd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Cpufreqd daemon
+After=acpid.service
+
+[Service]
+ExecStart=/usr/bin/cpufreqd -D
+ExecStop=/bin/kill -INT $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/cpufreqd_acpi_battery.c.patch b/cpufreqd_acpi_battery.c.patch
new file mode 100644
index 000000000000..51f63532d1e9
--- /dev/null
+++ b/cpufreqd_acpi_battery.c.patch
@@ -0,0 +1,176 @@
+--- src/cpufreqd_acpi_battery.c 2010-03-28 04:34:54.000000000 -0700
++++ src/cpufreqd_acpi_battery.c 2010-11-21 18:51:32.000000000 -0800
+@@ -29,12 +29,15 @@
+
+ #define POWER_SUPPLY "power_supply"
+ #define BATTERY_TYPE "Battery"
++#define PRESENT "present"
++#define STATUS "status"
++//energy batter properties
+ #define ENERGY_FULL "energy_full"
+ #define ENERGY_NOW "energy_now"
++#define POWER_NOW "power_now"
++//charge battery properties
+ #define CHARGE_FULL "charge_full"
+ #define CHARGE_NOW "charge_now"
+-#define PRESENT "present"
+-#define STATUS "status"
+ #define CURRENT_NOW "current_now"
+
+ struct battery_info {
+@@ -45,11 +48,11 @@
+ int is_present;
+
+ struct sysfs_class_device *cdev;
+- struct sysfs_attribute *energy_full; /* last full capacity */
+- struct sysfs_attribute *energy_now; /* remaining capacity */
++ struct sysfs_attribute *full_capacity; /* last full capacity */
++ struct sysfs_attribute *remaining_capacity; /* remaining capacity */
+ struct sysfs_attribute *present;
+ struct sysfs_attribute *status;
+- struct sysfs_attribute *current_now; /* present rate */
++ struct sysfs_attribute *draw_rate; /* present rate */
+
+ int open;
+ };
+@@ -87,16 +90,16 @@
+
+ if (!binfo->open) return;
+
+- if (binfo->energy_full)
+- put_attribute(binfo->energy_full);
+- if (binfo->energy_now)
+- put_attribute(binfo->energy_now);
++ if (binfo->full_capacity)
++ put_attribute(binfo->full_capacity);
++ if (binfo->remaining_capacity)
++ put_attribute(binfo->remaining_capacity);
+ if (binfo->present)
+ put_attribute(binfo->present);
+ if (binfo->status)
+ put_attribute(binfo->status);
+- if (binfo->current_now)
+- put_attribute(binfo->current_now);
++ if (binfo->draw_rate)
++ put_attribute(binfo->draw_rate);
+
+ binfo->open = 0;
+ }
+@@ -104,11 +107,11 @@
+ static int read_battery(struct battery_info *binfo) {
+ clog(LOG_DEBUG, "%s - reading battery levels\n", binfo->cdev->name);
+
+- if (read_int(binfo->current_now, &binfo->present_rate) != 0) {
++ if (read_int(binfo->draw_rate, &binfo->present_rate) != 0) {
+ clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name);
+ return -1;
+ }
+- if (read_int(binfo->energy_now, &binfo->remaining) != 0) {
++ if (read_int(binfo->remaining_capacity, &binfo->remaining) != 0) {
+ clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name);
+ return -1;
+ }
+@@ -120,38 +123,88 @@
+ binfo->cdev->name, binfo->remaining);
+ return 0;
+ }
++
++/* open energy battery specific attributes */
++static int read_energy_battery_attributes(struct battery_info *binfo)
++{
++ binfo->full_capacity = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
++ if(!binfo->full_capacity)
++ {
++ return -1;
++ }
++
++ binfo->remaining_capacity = get_class_device_attribute(binfo->cdev, ENERGY_NOW);
++ if(!binfo->remaining_capacity)
++ {
++ return -1;
++ }
++
++ binfo->draw_rate = get_class_device_attribute(binfo->cdev, POWER_NOW);
++ if(!binfo->draw_rate)
++ {
++ return -1;
++ }
++
++ return 0;
++}
++
++/* open charge battery specific attributes */
++static int read_charge_battery_attributes(struct battery_info *binfo)
++{
++ binfo->full_capacity = get_class_device_attribute(binfo->cdev, CHARGE_FULL);
++ if(!binfo->full_capacity)
++ {
++ return -1;
++ }
++
++ binfo->remaining_capacity = get_class_device_attribute(binfo->cdev, CHARGE_NOW);
++ if(!binfo->remaining_capacity)
++ {
++ return -1;
++ }
++
++ binfo->draw_rate = get_class_device_attribute(binfo->cdev, CURRENT_NOW);
++ if(!binfo->draw_rate)
++ {
++ return -1;
++ }
++
++ return 0;
++}
++
+ /* open all the required attributes and set the open status */
+ static int open_battery(struct battery_info *binfo) {
+ binfo->open = 1;
+
+- binfo->energy_full = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
+- if (!binfo->energy_full) {
+- /* try the "charge_full" name */
+- binfo->energy_full = get_class_device_attribute(binfo->cdev,
+- CHARGE_FULL);
+- if (!binfo->energy_full)
++ //attempt to open energy attribute
++ struct sysfs_attribute *tmp_attribute = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
++
++ if(!tmp_attribute)
++ {
++ if(read_charge_battery_attributes(binfo) != 0)
++ {
+ return -1;
++ }
+ }
+- binfo->energy_now = get_class_device_attribute(binfo->cdev, ENERGY_NOW);
+- if (!binfo->energy_now) {
+- /* try the "charge_now" name */
+- binfo->energy_now = get_class_device_attribute(binfo->cdev, CHARGE_NOW);
+- if (!binfo->energy_now)
++ else
++ {
++ put_attribute(tmp_attribute);
++ if(read_energy_battery_attributes(binfo) != 0)
++ {
+ return -1;
++ }
+ }
++
+ binfo->present = get_class_device_attribute(binfo->cdev, PRESENT);
+ if (!binfo->present)
+ return -1;
+ binfo->status = get_class_device_attribute(binfo->cdev, STATUS);
+ if (!binfo->status)
+ return -1;
+- binfo->current_now = get_class_device_attribute(binfo->cdev, CURRENT_NOW);
+- if (!binfo->current_now)
+- return -1;
+
+ /* read the last full capacity, this is not going to change
+ * very often, so no need to poke it later */
+- if (read_int(binfo->energy_full, &binfo->capacity) != 0) {
++ if (read_int(binfo->full_capacity, &binfo->capacity) != 0) {
+ clog(LOG_WARNING, "Couldn't read %s capacity (%s)\n",
+ binfo->cdev->name, strerror(errno));
+ return -1;
diff --git a/cpupower.patch b/cpupower.patch
new file mode 100644
index 000000000000..a104ed5f9e0c
--- /dev/null
+++ b/cpupower.patch
@@ -0,0 +1,24 @@
+--- configure.in 2010-04-18 17:57:30.000000000 +0400
++++ configure.in 2013-01-04 14:37:44.687427237 +0400
+@@ -4,7 +4,7 @@
+
+ AM_INIT_AUTOMAKE(1.8 dist-bzip2 foreign)
+ AC_CONFIG_SRCDIR([config.h.in])
+-AM_CONFIG_HEADER(config.h)
++AC_CONFIG_HEADERS(config.h)
+
+ # libtool
+ AC_LIBTOOL_DLOPEN
+@@ -38,9 +38,9 @@
+ AC_CHECK_LIB([dl], [dlopen],
+ [ CPUFREQD_LDFLAGS="${CPUFREQD_LDFLAGS} -ldl" ],
+ [ AC_MSG_ERROR([You need a working dlopen to build cpufreqd]) ])
+-AC_CHECK_LIB([cpufreq], [cpufreq_cpu_exists],
+- [ CPUFREQD_LDFLAGS="${CPUFREQD_LDFLAGS} -lcpufreq" ],
+- [ AC_MSG_ERROR([You need libcpufreq from cpufrequtils to build cpufreqd]) ])
++AC_CHECK_LIB([cpupower], [cpufreq_cpu_exists],
++ [ CPUFREQD_LDFLAGS="${CPUFREQD_LDFLAGS} -lcpupower" ],
++ [ AC_MSG_ERROR([You need libcpupower from cpupower to build cpufreqd]) ])
+ AC_SUBST(CPUFREQD_LDFLAGS)
+
+ DISABLED_PLUGINS=""