[Pommed-commits] r350 - in trunk: . pommed pommed/mactel pommed/pmac

jblache at alioth.debian.org jblache at alioth.debian.org
Wed Aug 22 14:02:16 UTC 2007


Author: jblache
Date: 2007-08-22 14:02:16 +0000 (Wed, 22 Aug 2007)
New Revision: 350

Modified:
   trunk/ChangeLog
   trunk/pommed.conf.mactel
   trunk/pommed.conf.pmac
   trunk/pommed/conffile.c
   trunk/pommed/conffile.h
   trunk/pommed/evdev.c
   trunk/pommed/kbd_auto.c
   trunk/pommed/kbd_backlight.h
   trunk/pommed/mactel/kbd_backlight.c
   trunk/pommed/pmac/kbd_backlight.c
   trunk/pommed/pommed.c
Log:
Add an idle timer to automatically switch off the keyboard backlight.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/ChangeLog	2007-08-22 14:02:16 UTC (rev 350)
@@ -2,6 +2,8 @@
 --------------------
 
 version 1.9:
+	- pommed: add an idle timer to automatically switch off the
+	keyboard backlight. Suggested by Javier Marcet.
 
 version 1.8:
 	- pommed: probe for the applesmc sysfs path in the ambient light

Modified: trunk/pommed/conffile.c
===================================================================
--- trunk/pommed/conffile.c	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/conffile.c	2007-08-22 14:02:16 UTC (rev 350)
@@ -122,6 +122,7 @@
     CFG_INT("on_threshold", 20, CFGF_NONE),
     CFG_INT("off_threshold", 40, CFGF_NONE),
     CFG_BOOL("auto", 1, CFGF_NONE),
+    CFG_INT("idle_timer", 60, CFGF_NONE),
     CFG_END()
   };
 
@@ -227,6 +228,7 @@
   printf("    auto on threshold: %d\n", kbd_cfg.on_thresh);
   printf("    auto off threshold: %d\n", kbd_cfg.off_thresh);
   printf("    auto enable: %s\n", (kbd_cfg.auto_on) ? "yes" : "no");
+  printf("    idle timer: %d%s\n", (kbd_cfg.idle * LOOP_TIMEOUT) / 1000, (kbd_cfg.idle > 0) ? "s" : "");
   printf(" + CD eject:\n");
   printf("    enabled: %s\n", (eject_cfg.enabled) ? "yes" : "no");
   printf("    device: %s\n", eject_cfg.device);
@@ -354,6 +356,7 @@
   kbd_cfg.on_thresh = cfg_getint(sec, "on_threshold");
   kbd_cfg.off_thresh = cfg_getint(sec, "off_threshold");
   kbd_cfg.auto_on = cfg_getbool(sec, "auto");
+  kbd_cfg.idle = cfg_getint(sec, "idle_timer");
   kbd_backlight_fix_config();
 
   sec = cfg_getsec(cfg, "eject");

Modified: trunk/pommed/conffile.h
===================================================================
--- trunk/pommed/conffile.h	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/conffile.h	2007-08-22 14:02:16 UTC (rev 350)
@@ -53,6 +53,7 @@
   int on_thresh;
   int off_thresh;
   int auto_on;
+  int idle;
 };
 
 struct _eject_cfg {

Modified: trunk/pommed/evdev.c
===================================================================
--- trunk/pommed/evdev.c	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/evdev.c	2007-08-22 14:02:16 UTC (rev 350)
@@ -87,6 +87,10 @@
       if (ev.value == 0)
 	return;
 
+      /* Reset keyboard backlight idle timer */
+      kbd_bck_info.idle = 0;
+      kbd_backlight_inhibit_clear(KBD_INHIBIT_IDLE);
+
       switch (ev.code)
 	{
 	  case K_LCD_BCK_DOWN:

Modified: trunk/pommed/kbd_auto.c
===================================================================
--- trunk/pommed/kbd_auto.c	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/kbd_auto.c	2007-08-22 14:02:16 UTC (rev 350)
@@ -50,7 +50,7 @@
     kbd_bck_info.inhibit_lvl = kbd_bck_info.level;
 
   kbd_backlight_set(KBD_BACKLIGHT_OFF,
-		    (mask == KBD_INHIBIT_LID) ? (KBD_AUTO) : (KBD_USER));
+		    (mask & KBD_MASK_AUTO) ? (KBD_AUTO) : (KBD_USER));
 
   kbd_bck_info.inhibit |= mask;
 
@@ -60,11 +60,15 @@
 void
 kbd_backlight_inhibit_clear(int mask)
 {
+  int flag;
+
+  flag = kbd_bck_info.inhibit & mask;
+
   kbd_bck_info.inhibit &= ~mask;
 
   logdebug("KBD: inhibit clear 0x%02x -> 0x%02x\n", mask, kbd_bck_info.inhibit);
 
-  if (kbd_bck_info.inhibit)
+  if (kbd_bck_info.inhibit || !flag)
     return;
 
   if (kbd_bck_info.auto_on)
@@ -74,7 +78,7 @@
     }
 
   kbd_backlight_set(kbd_bck_info.inhibit_lvl,
-		    (mask == KBD_INHIBIT_LID) ? (KBD_AUTO) : (KBD_USER));
+		    (mask & KBD_MASK_AUTO) ? (KBD_AUTO) : (KBD_USER));
 }
 
 void

Modified: trunk/pommed/kbd_backlight.h
===================================================================
--- trunk/pommed/kbd_backlight.h	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/kbd_backlight.h	2007-08-22 14:02:16 UTC (rev 350)
@@ -20,8 +20,11 @@
 #define KBD_INHIBIT_USER        (1 << 0)
 #define KBD_INHIBIT_LID         (1 << 1)
 #define KBD_INHIBIT_CFG         (1 << 2)
+#define KBD_INHIBIT_IDLE        (1 << 3)
 
+#define KBD_MASK_AUTO           (KBD_INHIBIT_LID | KBD_INHIBIT_IDLE)
 
+
 #define KBD_USER     0
 #define KBD_AUTO     1
 
@@ -37,6 +40,7 @@
   int toggle_lvl; /* backlight level for simple toggle */
 
   int auto_on;  /* automatic */
+  int idle;     /* idle timer */
   int r_sens;   /* right sensor */
   int l_sens;   /* left sensor */
 };

Modified: trunk/pommed/mactel/kbd_backlight.c
===================================================================
--- trunk/pommed/mactel/kbd_backlight.c	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/mactel/kbd_backlight.c	2007-08-22 14:02:16 UTC (rev 350)
@@ -246,4 +246,7 @@
 
   if (kbd_cfg.step > (KBD_BACKLIGHT_MAX / 2))
     kbd_cfg.step = KBD_BACKLIGHT_MAX / 2;
+
+  if (kbd_cfg.idle > 0)
+    kbd_cfg.idle = (kbd_cfg.idle * 1000) / LOOP_TIMEOUT;
 }

Modified: trunk/pommed/pmac/kbd_backlight.c
===================================================================
--- trunk/pommed/pmac/kbd_backlight.c	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/pmac/kbd_backlight.c	2007-08-22 14:02:16 UTC (rev 350)
@@ -395,6 +395,9 @@
 
   if (kbd_cfg.step > (KBD_BACKLIGHT_MAX / 2))
     kbd_cfg.step = KBD_BACKLIGHT_MAX / 2;
+
+  if (kbd_cfg.idle > 0)
+    kbd_cfg.idle = (kbd_cfg.idle * 1000) / LOOP_TIMEOUT;
 }
 
 

Modified: trunk/pommed/pommed.c
===================================================================
--- trunk/pommed/pommed.c	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed/pommed.c	2007-08-22 14:02:16 UTC (rev 350)
@@ -841,6 +841,11 @@
 	    {
 	      if (has_kbd_backlight())
 		{
+		  /* Increment keyboard backlight idle timer */
+		  kbd_bck_info.idle++;
+		  if ((kbd_cfg.idle > 0) && (kbd_bck_info.idle > kbd_cfg.idle))
+		    kbd_backlight_inhibit_set(KBD_INHIBIT_IDLE);
+
 		  kbd_backlight_ambient_check();
 		}
 
@@ -854,6 +859,11 @@
 	  /* poll() timed out, check ambient light sensors and AC state */
 	  if (has_kbd_backlight())
 	    {
+	      /* Increment keyboard backlight idle timer */
+	      kbd_bck_info.idle++;
+	      if ((kbd_cfg.idle > 0) && (kbd_bck_info.idle > kbd_cfg.idle))
+		kbd_backlight_inhibit_set(KBD_INHIBIT_IDLE);
+
 	      kbd_backlight_ambient_check();
 	    }
 

Modified: trunk/pommed.conf.mactel
===================================================================
--- trunk/pommed.conf.mactel	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed.conf.mactel	2007-08-22 14:02:16 UTC (rev 350)
@@ -69,6 +69,8 @@
 	off_threshold = 40
 	# enable/disable automatic backlight
 	auto = yes
+	# idle timer - switches off keyboard backlight automatically (timeout in seconds, -1 to disable)
+	idle_timer = 60
 }
 
 # CD/DVD drive ejection

Modified: trunk/pommed.conf.pmac
===================================================================
--- trunk/pommed.conf.pmac	2007-07-27 14:40:41 UTC (rev 349)
+++ trunk/pommed.conf.pmac	2007-08-22 14:02:16 UTC (rev 350)
@@ -59,6 +59,8 @@
 	off_threshold = 40
 	# enable/disable automatic backlight
 	auto = yes
+	# idle timer - switches off keyboard backlight automatically (timeout in seconds, -1 to disable)
+	idle_timer = 60
 }
 
 # CD/DVD drive ejection




More information about the Pommed-commits mailing list