apm: finally fixed suspend/resume problem on Zaurus with 2.4-crapix
authorMarcin Juszkiewicz <hrw@openembedded.org>
Thu, 26 Jan 2006 16:59:16 +0000 (16:59 +0000)
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>
Thu, 26 Jan 2006 16:59:16 +0000 (16:59 +0000)
- rewritten /usr/bin/apm wrapper from shell to C and added into apm
- now Zaurus machines can be suspended by non-root users
- die Sharp, die!

packages/apmd/apmd-3.2.2/apmwrapper [deleted file]
packages/apmd/apmd-3.2.2/devfs.patch [deleted file]
packages/apmd/apmd-3.2.2/hwclock [deleted file]
packages/apmd/apmd-3.2.2/logcheck.ignore.paranoid [deleted file]
packages/apmd/apmd-3.2.2/zaurus24.patch [new file with mode: 0644]
packages/apmd/apmd_3.2.2.bb

diff --git a/packages/apmd/apmd-3.2.2/apmwrapper b/packages/apmd/apmd-3.2.2/apmwrapper
deleted file mode 100644 (file)
index 3bc9bec..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-if ( cat /proc/cpuinfo|grep -i hardware|grep -i SHARP ) && \
-   [ ".$@" = ".-s" -o ".$@" = ".--suspend" ]; then
-       killall -USR1 apmd || /usr/bin/apm.orig -s
-else
-       /usr/bin/apm.orig "$@"
-fi
-
diff --git a/packages/apmd/apmd-3.2.2/devfs.patch b/packages/apmd/apmd-3.2.2/devfs.patch
deleted file mode 100644 (file)
index b11e019..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- apmd-3.2.0.orig/apm.h~devfs
-+++ apmd-3.2.0.orig/apm.h
-@@ -24,7 +24,7 @@
- #include <sys/types.h>
- #define APM_PROC   "/proc/apm"
--#define APM_DEVICE "/dev/apm_bios"
-+#define APM_DEVICE "/dev/misc/apm_bios"
- #define APM_DEV  "/proc/devices"
- #define APM_NAME "apm_bios"
diff --git a/packages/apmd/apmd-3.2.2/hwclock b/packages/apmd/apmd-3.2.2/hwclock
deleted file mode 100644 (file)
index a1c1c22..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-# Preserve the system clock around suspend/resume.
-
-INIT="/etc/init.d/hwclock.sh"
-[ -x "${INIT}" ] || exit 0
-
-case "${1},${2}" in
-(suspend,*)
-    "${INIT}" stop
-    ;;
-(resume,suspend)
-    "${INIT}" start
-    ;;
-esac
-
-exit 0
diff --git a/packages/apmd/apmd-3.2.2/logcheck.ignore.paranoid b/packages/apmd/apmd-3.2.2/logcheck.ignore.paranoid
deleted file mode 100644 (file)
index de37f01..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-apmd\[[0-9]+\]: (Normal|Standby|Critical) Resume
-apmd\[[0-9]+\]: (Now using|Using) (AC|battery|backup) power
-apmd\[[0-9]+\]: (System|User) (Standby|Suspend)
-apmd\[[0-9]+\]: (apmd_)?call_proxy:
-apmd\[[0-9]+\]: Battery: [0-9]+%,
-apmd\[[0-9]+\]: Battery: absent
-apmd\[[0-9]+\]: Capability Change
-apmd\[[0-9]+\]: Exiting
-apmd\[[0-9]+\]: Performing APM status check
-apmd\[[0-9]+\]: Suspending now
-apmd\[[0-9]+\]: Update Time
-apmd\[[0-9]+\]: Version: apmd [0-9.]+, (apm )?driver [0-9.]+, APM BIOS [0-9.]+
-apmd\[[0-9]+\]: apmd [0-9.]+ interfacing with apm driver [0-9.]+ and APM BIOS [0-9.]+
diff --git a/packages/apmd/apmd-3.2.2/zaurus24.patch b/packages/apmd/apmd-3.2.2/zaurus24.patch
new file mode 100644 (file)
index 0000000..5df016a
--- /dev/null
@@ -0,0 +1,50 @@
+Index: apmd-3.2.2.orig/apm.c
+===================================================================
+--- apmd-3.2.2.orig.orig/apm.c 2006-01-26 15:15:27.000000000 +0100
++++ apmd-3.2.2.orig/apm.c      2006-01-26 17:50:14.000000000 +0100
+@@ -24,10 +24,12 @@
+ #include <unistd.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
++#include <sys/utsname.h>
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <time.h>
+ #include <getopt.h>
++#include <signal.h>
+ #include "apm.h"
+ static int verbose = 0;
+@@ -43,6 +45,9 @@
+     int fd;
+     time_t then, now;
+     int error;
++    FILE* pid_file;
++    int apmd_pid;
++    struct utsname uname_ver;
+     fd = open(APM_DEVICE, O_WRONLY);
+     if (fd < 0)
+@@ -54,6 +59,22 @@
+     switch (mode)
+     {
+     case SUSPEND:
++      if(0 == system("grep -i hardware /proc/cpuinfo|grep -i SHARP"))
++      {
++          uname(&uname_ver);
++
++          if(0 == strncmp("2.4", uname_ver.release, 3))
++          {
++              pid_file = fopen("/var/run/apmd.pid", "r");
++              if(pid_file)
++              {
++                  fscanf(pid_file, "%d", &apmd_pid);
++                  fclose(pid_file);
++              }
++
++              kill(apmd_pid, SIGKILL);
++          }
++      }
+       error = apm_suspend(fd);
+       break;
+     case STANDBY:
index 0e8b364..206c520 100644 (file)
@@ -3,12 +3,12 @@ SECTION = "base"
 PRIORITY = "required"
 DEPENDS = "libtool-cross"
 LICENSE = "GPL"
-PR = "r5"
+PR = "r6"
 
 SRC_URI = "${DEBIAN_MIRROR}/main/a/apmd/apmd_${PV}.orig.tar.gz; \
            file://debian.patch;patch=1 \
            file://workaround.patch;patch=1 \
-           file://apmwrapper \
+           file://zaurus24.patch;patch=1 \
            file://init \
            file://default \
            file://apmd_proxy \
@@ -44,25 +44,8 @@ do_install() {
        install -d ${D}${bindir}
        install -d ${D}${libdir}
        install -d ${D}${datadir}/apmd
-#
-# only Zaurus 2.4-embedix kernels need a breadead apm hack
-#
-#
-       case ${MACHINE} in
-               collie | poodle | tosa | c7x0 | akita | spitz | borzoi)
-                       if [ "${KERNEL_VERSION}" == "2.6" ]
-                       then
-                               install -m 4577 ${S}/.libs/apm ${D}${bindir}/apm
-                       else
-                               install -m 4755 ${S}/.libs/apm ${D}${bindir}/apm.orig
-                               install -m 0755 ${WORKDIR}/apmwrapper ${D}${bindir}/apm
-                       fi
-                       ;;
-        *)
-                       install -m 4577 ${S}/.libs/apm ${D}${bindir}/apm
-               ;;
-    esac
 
+       install -m 4577 ${S}/.libs/apm ${D}${bindir}/apm
        install -m 0755 ${S}/.libs/apmd ${D}${sbindir}/apmd
        install -m 0755 ${WORKDIR}/apmd_proxy ${D}${sysconfdir}/apm/
        install -m 0644 ${WORKDIR}/apmd_proxy.conf ${D}${datadir}/apmd/
@@ -79,5 +62,3 @@ PACKAGES =+ "libapm libapm-dev apm"
 FILES_libapm = "${libdir}/libapm.so.*"
 FILES_libapm-dev = "${libdir}/libapm.* ${includedir}"
 FILES_apm = "${bindir}/apm*"
-
-