[Pkg-wmaker-commits] [wmacpi] 54/105: Imported Debian patch 2.2~rc1-4

Doug Torrance dtorrance-guest at moszumanska.debian.org
Tue Aug 18 01:13:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmacpi.

commit 07634a827a1528a39275b76987ce56929966ca1a
Author: Julien BLACHE <jblache at debian.org>
Date:   Wed Feb 13 22:09:30 2008 +0100

    Imported Debian patch 2.2~rc1-4
---
 debian/changelog                                   |   8 ++
 .../patches/01_power_supply_and_misc_fixes.dpatch  | 127 +++++++++++++++------
 2 files changed, 98 insertions(+), 37 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 0893653..20d799b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+wmacpi (2.2~rc1-4) unstable; urgency=low
+
+  * debian/patches/01_power_supply_and_misc_fixes.dpatch:
+    + Updated; take into account that batteries can report either their energy
+      level, charge level, or capacity percentage (closes: #465388).
+
+ -- Julien BLACHE <jblache at debian.org>  Wed, 13 Feb 2008 22:09:30 +0100
+
 wmacpi (2.2~rc1-3) unstable; urgency=low
 
   * debian/patches/01_power_supply_and_misc_fixes.dpatch:
diff --git a/debian/patches/01_power_supply_and_misc_fixes.dpatch b/debian/patches/01_power_supply_and_misc_fixes.dpatch
index 26b25c2..1b63ac9 100644
--- a/debian/patches/01_power_supply_and_misc_fixes.dpatch
+++ b/debian/patches/01_power_supply_and_misc_fixes.dpatch
@@ -8,7 +8,7 @@
 @DPATCH@
 diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
 --- wmacpi-2.2~rc1~/libacpi.c	2007-07-13 17:26:30.000000000 +0200
-+++ wmacpi-2.2~rc1/libacpi.c	2008-02-10 18:30:18.958898787 +0100
++++ wmacpi-2.2~rc1/libacpi.c	2008-02-13 22:07:53.987250325 +0100
 @@ -4,6 +4,7 @@
  #include <string.h>
  #include <ctype.h>
@@ -17,7 +17,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  #include <sys/types.h>
  #include <dirent.h>
  #include <time.h>
-@@ -11,13 +12,117 @@
+@@ -11,13 +12,128 @@
  #include "libacpi.h"
  
  extern char *state[];
@@ -123,6 +123,17 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
 +	snprintf(batteries[i].name, MAX_NAME, "%s", names[i]);
 +	pdebug("battery detected at /sys/class/power_supply/%s\n", batteries[i].name);
 +	pinfo("found battery %s\n", names[i]);
++
++	if (read_sysfs_file(batteries[i].name, "energy_now", ps_type, sizeof(ps_type)) == 0)
++	  batteries[i].sysfs_capa_mode = SYSFS_CAPA_ENERGY;
++	else if (read_sysfs_file(batteries[i].name, "charge_now", ps_type, sizeof(ps_type)) == 0)
++	  batteries[i].sysfs_capa_mode = SYSFS_CAPA_CHARGE;
++	else if (read_sysfs_file(batteries[i].name, "capacity", ps_type, sizeof(ps_type)) == 0) {
++	  batteries[i].sysfs_capa_mode = SYSFS_CAPA_PERCENT;
++	  batteries[i].design_cap = 100;
++	  batteries[i].last_full_cap = 100;
++	} else
++	  batteries[i].sysfs_capa_mode = SYSFS_CAPA_ERR;
 +    }
 +
 +    /* tell user some info */
@@ -137,7 +148,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  {
      DIR *battdir;
      struct dirent *batt;
-@@ -83,6 +188,14 @@
+@@ -83,6 +199,14 @@
      return 0;
  }
  
@@ -152,7 +163,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  /* a stub that just calls the current function */
  int reinit_batteries(global_t *globals)
  {
-@@ -90,10 +203,59 @@
+@@ -90,10 +214,59 @@
      return init_batteries(globals);
  }
  
@@ -214,7 +225,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  {
      DIR *acdir;
      struct dirent *adapter;
-@@ -125,6 +287,14 @@
+@@ -125,6 +298,14 @@
      return 0;
  }
  
@@ -229,7 +240,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  /* stub that does nothing but call the normal init function */
  int reinit_ac_adapters(global_t *globals)
  {
-@@ -162,6 +332,15 @@
+@@ -162,6 +343,15 @@
      /* yep, all good */
      fclose(acpi);
  
@@ -245,7 +256,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
      if (!(retval = init_batteries(globals)))
  	retval = init_ac_adapters(globals);
  
-@@ -187,7 +366,7 @@
+@@ -187,7 +377,7 @@
      return retval;
  }
  
@@ -254,7 +265,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  {
      char *retval;
      int i;
-@@ -203,14 +382,29 @@
+@@ -203,14 +393,29 @@
      return retval;
  }
  
@@ -286,7 +297,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  {
      FILE *file;
      char buf[1024];
-@@ -232,7 +426,105 @@
+@@ -232,7 +437,136 @@
  	return BATT;
  }
  
@@ -328,19 +339,34 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
 +      return 0;
 +    }
 +
-+    /* get design capacity
-+     * note that all these integer values can also contain the
-+     * string 'unknown', so we need to check for this. */
-+    if (read_sysfs_file(info->name, "energy_full_design", buf, sizeof(buf)) < 0)
++    if (info->sysfs_capa_mode == SYSFS_CAPA_ENERGY) {
++      /* get design capacity */
++      if (read_sysfs_file(info->name, "energy_full_design", buf, sizeof(buf)) < 0)
++	info->design_cap = -1;
++      else
++	info->design_cap = strtoul(buf, NULL, 10) / 1000;
++
++      /* get last full capacity */
++      if (read_sysfs_file(info->name, "energy_full", buf, sizeof(buf)) < 0)
++	info->last_full_cap = -1;
++      else
++	info->last_full_cap = strtoul(buf, NULL, 10) / 1000;
++    } else if (info->sysfs_capa_mode == SYSFS_CAPA_CHARGE) {
++      /* get design capacity */
++      if (read_sysfs_file(info->name, "charge_full_design", buf, sizeof(buf)) < 0)
++	info->design_cap = -1;
++      else
++	info->design_cap = strtoul(buf, NULL, 10) / 1000;
++
++      /* get last full capacity */
++      if (read_sysfs_file(info->name, "charge_full", buf, sizeof(buf)) < 0)
++	info->last_full_cap = -1;
++      else
++	info->last_full_cap = strtoul(buf, NULL, 10) / 1000;
++    } else if (info->sysfs_capa_mode != SYSFS_CAPA_PERCENT) {
 +      info->design_cap = -1;
-+    else
-+      info->design_cap = strtoul(buf, NULL, 10) / 1000;
-+
-+    /* get last full capacity */
-+    if (read_sysfs_file(info->name, "energy_full", buf, sizeof(buf)) < 0)
 +      info->last_full_cap = -1;
-+    else
-+      info->last_full_cap = strtoul(buf, NULL, 10) / 1000;
++    }
 +
 +    /* get design voltage */
 +    if (read_sysfs_file(info->name, "voltage_min_design", buf, sizeof(buf)) < 0)
@@ -374,11 +400,27 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
 +      info->present_rate = (rate != 0) ? rate : info->present_rate;
 +    }
 +
-+    /* get remaining capacity */
-+    if (read_sysfs_file(info->name, "energy_now", buf, sizeof(buf)) < 0)
++    if (info->sysfs_capa_mode == SYSFS_CAPA_ENERGY) {
++      /* get remaining capacity */
++      if (read_sysfs_file(info->name, "energy_now", buf, sizeof(buf)) < 0)
++	info->remaining_cap = -1;
++      else
++	info->remaining_cap = strtoul(buf, NULL, 10) / 1000;
++    } else if (info->sysfs_capa_mode == SYSFS_CAPA_CHARGE) {
++      /* get remaining capacity */
++      if (read_sysfs_file(info->name, "charge_now", buf, sizeof(buf)) < 0)
++	info->remaining_cap = -1;
++      else
++	info->remaining_cap = strtoul(buf, NULL, 10) / 1000;
++    } else if (info->sysfs_capa_mode == SYSFS_CAPA_PERCENT) {
++      /* get remaining capacity */
++      if (read_sysfs_file(info->name, "capacity", buf, sizeof(buf)) < 0)
++	info->remaining_cap = -1;
++      else
++	info->remaining_cap = strtoul(buf, NULL, 10) / 1000;
++    } else {
 +      info->remaining_cap = -1;
-+    else
-+      info->remaining_cap = strtoul(buf, NULL, 10) / 1000;
++    }
 +
 +    /* get current voltage */
 +    if (read_sysfs_file(info->name, "voltage_now", buf, sizeof(buf)) < 0)
@@ -393,7 +435,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  {
      FILE *file;
      battery_t *info = &batteries[batt_no];
-@@ -241,6 +533,8 @@
+@@ -241,6 +575,8 @@
      int buflen;
      char *val;
  
@@ -402,7 +444,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
      if ((file = fopen(info->info_file, "r")) == NULL) {
  	/* this is cheating, but string concatenation should work . . . */
  	pfatal("Could not open %s:", info->info_file );
-@@ -325,18 +619,6 @@
+@@ -325,18 +661,6 @@
  	return 0;
      }
  
@@ -421,7 +463,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
      /* get charging state */
      entry = strstr(buf, "charging state:");
      val = get_value(entry);
-@@ -385,6 +667,15 @@
+@@ -385,6 +709,15 @@
      return 1;
  }
  
@@ -437,7 +479,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  /*
   * 2003-7-1.
   * In order to make this code more convenient for things other than
-@@ -562,7 +853,7 @@
+@@ -562,7 +895,7 @@
      battery_t *binfo;
      adapter_t *ap = &globals->adapter;
      
@@ -446,7 +488,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
      
      binfo = &batteries[batt];
      
-@@ -593,16 +884,6 @@
+@@ -593,16 +926,6 @@
      /* we need to /know/ that we've got a valid state for the 
       * globals->power value . . . .*/
      ap->power = get_power_status(globals);
@@ -465,7 +507,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.c wmacpi-2.2~rc1/libacpi.c
  
 diff -urNad wmacpi-2.2~rc1~/libacpi.h wmacpi-2.2~rc1/libacpi.h
 --- wmacpi-2.2~rc1~/libacpi.h	2007-07-13 17:26:30.000000000 +0200
-+++ wmacpi-2.2~rc1/libacpi.h	2008-02-10 18:30:18.959898139 +0100
++++ wmacpi-2.2~rc1/libacpi.h	2008-02-13 21:56:52.148206585 +0100
 @@ -2,7 +2,7 @@
  #define _LIBACPI_H_
  
@@ -475,7 +517,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.h wmacpi-2.2~rc1/libacpi.h
  
  /* Here because we need it for definitions in this file . . . */
  #define MAX_NAME 128
-@@ -26,22 +26,17 @@
+@@ -26,21 +26,23 @@
      MED,
      LOW,
      CRIT,
@@ -491,16 +533,27 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.h wmacpi-2.2~rc1/libacpi.h
      CH_ERR,
  } charge_state_t;
  
--typedef enum {
+ typedef enum {
 -    OK,
 -    CRITICAL,
 -    CS_ERR,
 -} cap_state_t;
--
++  SYSFS_CAPA_ENERGY,
++  SYSFS_CAPA_CHARGE,
++  SYSFS_CAPA_PERCENT,
++  SYSFS_CAPA_ERR,
++} sysfs_capa_t;
+ 
  typedef struct {
      /* general info */
-     char name[MAX_NAME];
-@@ -53,7 +48,6 @@
+@@ -48,12 +50,13 @@
+     /* these two are conveniences */
+     char info_file[MAX_NAME];
+     char state_file[MAX_NAME];
++    /* sysfs capacity mode */
++    sysfs_capa_t sysfs_capa_mode;
+     int present; 
+     int design_cap;		/* assuming mAh */
      int last_full_cap;
      int design_voltage;		/* in mV */
      /* state info */
@@ -510,7 +563,7 @@ diff -urNad wmacpi-2.2~rc1~/libacpi.h wmacpi-2.2~rc1/libacpi.h
      int remaining_cap;		/* in mAh */
 diff -urNad wmacpi-2.2~rc1~/master.xpm wmacpi-2.2~rc1/master.xpm
 --- wmacpi-2.2~rc1~/master.xpm	2007-07-13 17:26:30.000000000 +0200
-+++ wmacpi-2.2~rc1/master.xpm	2008-02-10 18:30:18.960898039 +0100
++++ wmacpi-2.2~rc1/master.xpm	2008-02-13 21:49:16.850249944 +0100
 @@ -96,9 +96,9 @@
  " .	c #004941",
  "..	c #20B2AE",
@@ -651,7 +704,7 @@ diff -urNad wmacpi-2.2~rc1~/master.xpm wmacpi-2.2~rc1/master.xpm
  "% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %   % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %       % % % % % % % % "};
 diff -urNad wmacpi-2.2~rc1~/wmacpi.c wmacpi-2.2~rc1/wmacpi.c
 --- wmacpi-2.2~rc1~/wmacpi.c	2007-07-13 17:26:30.000000000 +0200
-+++ wmacpi-2.2~rc1/wmacpi.c	2008-02-10 18:30:18.960898039 +0100
++++ wmacpi-2.2~rc1/wmacpi.c	2008-02-13 21:49:16.854259411 +0100
 @@ -36,7 +36,7 @@
  #include "libacpi.h"
  #include "wmacpi.h"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmacpi.git



More information about the Pkg-wmaker-commits mailing list