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

Julien Blache jblache at alioth.debian.org
Fri Feb 23 20:57:25 CET 2007


Author: jblache
Date: 2007-02-23 20:57:25 +0100 (Fri, 23 Feb 2007)
New Revision: 277

Removed:
   trunk/pommed/pmac/r128_backlight.c
Modified:
   trunk/pommed.conf.pmac
   trunk/pommed/Makefile
   trunk/pommed/conffile.c
   trunk/pommed/conffile.h
   trunk/pommed/lcd_backlight.h
   trunk/pommed/pmac/sysfs_backlight.c
   trunk/pommed/pommed.c
Log:
Get rid of r128_backlight.c, integrate it into sysfs_backlight.c.


Modified: trunk/pommed/Makefile
===================================================================
--- trunk/pommed/Makefile	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed/Makefile	2007-02-23 19:57:25 UTC (rev 277)
@@ -17,7 +17,7 @@
 LDFLAGS = -lz $(CONFUSE_LIBS) $(DBUS_LIBS) $(ALSA_LIBS)
 
 SOURCES = pommed.c cd_eject.c evdev.c conffile.c audio.c dbus.c \
-		pmac/sysfs_backlight.c pmac/r128_backlight.c \
+		pmac/sysfs_backlight.c \
 		pmac/kbd_backlight.c pmac/ambient.c
 
 OF_SOURCES = pmac/oflib/of_externals.c pmac/oflib/of_internals.c \
@@ -61,8 +61,6 @@
 
 pmac/sysfs_backlight.o: pmac/sysfs_backlight.c pommed.h lcd_backlight.h conffile.h dbus.h
 
-pmac/r128_backlight.o: pmac/r128_backlight.c pommed.h lcd_backlight.h conffile.h dbus.h
-
 pmac/ambient.o: pmac/ambient.c ambient.h pommed.h dbus.h
 
 # OFlib

Modified: trunk/pommed/conffile.c
===================================================================
--- trunk/pommed/conffile.c	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed/conffile.c	2007-02-23 19:57:25 UTC (rev 277)
@@ -38,7 +38,6 @@
 struct _general_cfg general_cfg;
 #ifdef __powerpc__
 struct _lcd_sysfs_cfg lcd_sysfs_cfg;
-struct _lcd_r128_cfg lcd_r128_cfg;
 #else
 struct _lcd_x1600_cfg lcd_x1600_cfg;
 struct _lcd_gma950_cfg lcd_gma950_cfg;
@@ -66,12 +65,6 @@
     CFG_END()
   };
 
-static cfg_opt_t lcd_r128_opts[] =
-  {
-    CFG_INT("init", -1, CFGF_NONE),
-    CFG_END()
-  };
-
 static cfg_opt_t audio_opts[] =
   {
     CFG_STR("card", "default", CFGF_NONE),
@@ -140,7 +133,6 @@
     CFG_SEC("general", general_opts, CFGF_NONE),
 #ifdef __powerpc__ 
     CFG_SEC("lcd_sysfs", lcd_sysfs_opts, CFGF_NONE),
-    CFG_SEC("lcd_r128", lcd_r128_opts, CFGF_NONE),
 #else
     CFG_SEC("lcd_x1600", lcd_x1600_opts, CFGF_NONE),
     CFG_SEC("lcd_gma950", lcd_gma950_opts, CFGF_NONE),
@@ -194,8 +186,6 @@
   printf(" + sysfs backlight control:\n");
   printf("    initial level: %d\n", lcd_sysfs_cfg.init);
   printf("    step: %d\n", lcd_sysfs_cfg.step);
-  printf(" + ATI Rage128 backlight control:\n");
-  printf("    initial level: %d\n", lcd_r128_cfg.init);
 #else
   printf(" + ATI X1600 backlight control:\n");
   printf("    initial level: %d\n", lcd_x1600_cfg.init);
@@ -301,10 +291,6 @@
   lcd_sysfs_cfg.init = cfg_getint(sec, "init");
   lcd_sysfs_cfg.step = cfg_getint(sec, "step");
   /* No _fix_config() call here, it's done at probe time */
-
-  sec = cfg_getsec(cfg, "lcd_r128");
-  lcd_r128_cfg.init = cfg_getint(sec, "init");
-  r128_backlight_fix_config();
 #else
   sec = cfg_getsec(cfg, "lcd_x1600");
   lcd_x1600_cfg.init = cfg_getint(sec, "init");

Modified: trunk/pommed/conffile.h
===================================================================
--- trunk/pommed/conffile.h	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed/conffile.h	2007-02-23 19:57:25 UTC (rev 277)
@@ -15,10 +15,6 @@
   int step;
 };
 
-struct _lcd_r128_cfg {
-  int init;
-};
-
 #else
 
 struct _lcd_x1600_cfg {

Modified: trunk/pommed/lcd_backlight.h
===================================================================
--- trunk/pommed/lcd_backlight.h	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed/lcd_backlight.h	2007-02-23 19:57:25 UTC (rev 277)
@@ -49,24 +49,18 @@
 void
 sysfs_backlight_step(int dir);
 
+void
+sysfs_backlight_step_kernel(int dir);
+
 int
+aty128_sysfs_backlight_probe(void);
+
+int
 r9x00_sysfs_backlight_probe(void);
 
 int
 nvidia_sysfs_backlight_probe(void);
 
-
-/* r128_backlight.c */
-#define R128_BACKLIGHT_OFF	0
-#define R128_BACKLIGHT_MAX	127
-void
-r128_backlight_step(int dir);
-
-int
-r128_backlight_probe(void);
-
-void
-r128_backlight_fix_config(void);
 #endif /* !__powerpc__ */
 
 #endif /* !__LCD_BACKLIGHT_H__ */

Deleted: trunk/pommed/pmac/r128_backlight.c
===================================================================
--- trunk/pommed/pmac/r128_backlight.c	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed/pmac/r128_backlight.c	2007-02-23 19:57:25 UTC (rev 277)
@@ -1,178 +0,0 @@
-/*
- * pommed - Apple laptops hotkeys handler daemon
- *
- * $Id$
- *
- * Copyright (C) 2006 Julien BLACHE <jb at jblache.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; version 2 of the License.
- *
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */ 
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <syslog.h>
-#include <pci/pci.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include "../pommed.h"
-#include "../conffile.h"
-#include "../lcd_backlight.h"
-#include "../dbus.h"
-
-
-#define SYSFS_BACKLIGHT "/sys/class/backlight/aty128bl0"
-
-static int probed = 0;
-
-
-static int
-r128_backlight_get(void)
-{
-  int fd;
-  int n;
-  char buffer[4];
-
-  if (!probed)
-    return 0;
-
-  fd = open(SYSFS_BACKLIGHT "/actual_brightness", O_RDONLY);
-  if (fd < 0)
-    {
-      logmsg(LOG_WARNING, "Could not open sysfs actual_brightness node: %s", strerror(errno));
-
-      return 0;
-    }
-
-  n = read(fd, buffer, sizeof(buffer) -1);
-  if (n < 1)
-    {
-      logmsg(LOG_WARNING, "Could not read sysfs actual_brightness node");
-
-      close(fd);
-      return 0;
-    }
-  close(fd);
-
-  return atoi(buffer);
-}
-
-
-static void
-r128_backlight_set(int value)
-{
-  FILE *fp;
-
-  fp = fopen(SYSFS_BACKLIGHT "/brightness", "a");
-  if (fp == NULL)
-    {
-      logmsg(LOG_WARNING, "Could not open sysfs brightness node: %s", strerror(errno));
-
-      return;
-    }
-
-  fprintf(fp, "%d", value);
-
-  fclose(fp);
-}
-
-
-/* The brightness keys are handled by the kernel itself, so
- * we're only updating our internal buffers
- */
-void
-r128_backlight_step(int dir)
-{
-  int val;
-
-  val = r128_backlight_get();
-
-  logdebug("LCD stepping: %d -> %d\n", lcd_bck_info.level, val);
-
-  mbpdbus_send_lcd_backlight(val, lcd_bck_info.level);
-
-  lcd_bck_info.level = val;
-}
-
-
-#define PCI_ID_VENDOR_ATI        0x1002
-#define PCI_ID_PRODUCT_R128     0x4c46
-
-/* Look for an ATI Rage128 Mobility */
-int
-r128_backlight_probe(void)
-{
-  struct pci_access *pacc;
-  struct pci_dev *dev;
-
-  pacc = pci_alloc();
-  if (pacc == NULL)
-    {
-      logmsg(LOG_ERR, "Could not allocate PCI structs");
-      return -1;
-    }
-
-  pci_init(pacc);
-  pci_scan_bus(pacc);
-
-  /* Iterate over all devices */
-  for(dev = pacc->devices; dev; dev = dev->next)
-    {
-      pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES);
-      /* ATI r128 */
-      if ((dev->vendor_id == PCI_ID_VENDOR_ATI)
-	  && (dev->device_id == PCI_ID_PRODUCT_R128))
-	{
-	  probed = 1;
-	}
-    }
-
-  pci_cleanup(pacc);
-
-  if (!probed)
-    {
-      logdebug("Failed to detect ATI Rage128, aborting...\n");
-      return -1;
-    }
-
-  lcd_bck_info.max = R128_BACKLIGHT_MAX;
-
-  /*
-   * Set the initial backlight level
-   * The value has been sanity checked already
-   */
-  if (lcd_r128_cfg.init > -1)
-    {
-      r128_backlight_set(lcd_r128_cfg.init);
-    }
-
-  lcd_bck_info.level = r128_backlight_get();
-
-  return 0;
-}
-
-void
-r128_backlight_fix_config(void)
-{
-  if (lcd_r128_cfg.init < 0)
-    lcd_r128_cfg.init = -1;
-
-  if (lcd_r128_cfg.init > R128_BACKLIGHT_MAX)
-    lcd_r128_cfg.init = R128_BACKLIGHT_MAX;
-}
-

Modified: trunk/pommed/pmac/sysfs_backlight.c
===================================================================
--- trunk/pommed/pmac/sysfs_backlight.c	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed/pmac/sysfs_backlight.c	2007-02-23 19:57:25 UTC (rev 277)
@@ -38,8 +38,9 @@
 
 
 #define SYSFS_DRIVER_NONE      0
-#define SYSFS_DRIVER_RADEON    1
-#define SYSFS_DRIVER_NVIDIA    2
+#define SYSFS_DRIVER_ATY128    1
+#define SYSFS_DRIVER_RADEON    2
+#define SYSFS_DRIVER_NVIDIA    3
 
 
 /* sysfs backlight driver in use */
@@ -49,6 +50,7 @@
 static char *actual_brightness[] =
   {
     "/dev/null",
+    "/sys/class/backlight/aty128bl0/actual_brightness",
     "/sys/class/backlight/radeonbl0/actual_brightness",
     "/sys/class/backlight/nvidiabl0/actual_brightness"
   };
@@ -57,6 +59,7 @@
 static char *brightness[] =
   {
     "/dev/null",
+    "/sys/class/backlight/aty128bl0/brightness",
     "/sys/class/backlight/radeonbl0/brightness",
     "/sys/class/backlight/nvidiabl0/brightness"
   };
@@ -65,6 +68,7 @@
 static char *max_brightness[] =
   {
     "/dev/null",
+    "/sys/class/backlight/aty128bl0/max_brightness",
     "/sys/class/backlight/radeonbl0/max_brightness",
     "/sys/class/backlight/nvidiabl0/max_brightness"
   };
@@ -194,6 +198,24 @@
 }
 
 
+/* When brightness keys are handled by the kernel itself,
+ * we're only updating our internal buffers
+ */
+void
+sysfs_backlight_step_kernel(int dir)
+{
+  int val;
+
+  val = sysfs_backlight_get();
+
+  logdebug("LCD stepping: %d -> %d\n", lcd_bck_info.level, val);
+
+  mbpdbus_send_lcd_backlight(val, lcd_bck_info.level);
+
+  lcd_bck_info.level = val;
+}
+
+
 /* We can't fix the config until we know the max backlight value,
  * so, here, fix_config() is static and called at probe time
  */
@@ -258,6 +280,12 @@
 }
 
 int
+aty128_sysfs_backlight_probe(void)
+{
+  return sysfs_backlight_probe(SYSFS_DRIVER_ATY128);
+}
+
+int
 r9x00_sysfs_backlight_probe(void)
 {
   return sysfs_backlight_probe(SYSFS_DRIVER_RADEON);

Modified: trunk/pommed/pommed.c
===================================================================
--- trunk/pommed/pommed.c	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed/pommed.c	2007-02-23 19:57:25 UTC (rev 277)
@@ -72,8 +72,8 @@
 
   {  /* PowerBook3,2 */
     .type = MACHINE_POWERBOOK_32,
-    .lcd_backlight_probe = r128_backlight_probe,
-    .lcd_backlight_step = r128_backlight_step,
+    .lcd_backlight_probe = aty128_sysfs_backlight_probe,
+    .lcd_backlight_step = sysfs_backlight_step_kernel,
     .evdev_identify = evdev_is_adb,
   },
 

Modified: trunk/pommed.conf.pmac
===================================================================
--- trunk/pommed.conf.pmac	2007-02-23 12:21:41 UTC (rev 276)
+++ trunk/pommed.conf.pmac	2007-02-23 19:57:25 UTC (rev 277)
@@ -9,22 +9,21 @@
 	fnmode = 1
 }
 
-# sysfs backlight control (ATI Radeon 9600 and nVidia cards)
+# sysfs backlight control
 lcd_sysfs {
+	# The sysfs backlight control is a generic interface provided
+	# by the Linux kernel for backlight control on most graphic cards.
+	# The brightness range can differ depending on the hardware.
+
 	# initial backlight level [100] (0 - 127, -1 to disable)
 	init = -1
 	# step value (1 - 63)
 	step = 8
-}
 
-# ATI r128 backlight control (PowerBook Titanium)
-lcd_r128 {
-	# initial backlight level [0x6f] (0x1f - 0x94 usually, -1 to disable)
-	init = -1
-
-	# The backlight is handled by the kernel on these machines, so here
-	# there is no step configuration, as pommed doesn't get to set the
-	# backlight level when you press on the keys.
+	# WARNING
+	# On some machines, the backlight is handled by the kernel, so
+	# the "step" configuration value is useless, as pommed doesn't
+	# get to set the backlight level when you press on the keys.
 }
 
 # Audio support




More information about the Pommed-commits mailing list