hal: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Thu Feb 15 11:26:17 PST 2007
configure.in | 27 ++++++++++++++++++++++-----
fdi/policy/10osvendor/10-omap-backlight.fdi | 4 ++--
fdi/policy/10osvendor/Makefile.am | 4 ++--
hald/linux/addons/Makefile.am | 11 ++++-------
hald/linux/addons/addon-omap-backlight.c | 4 ++--
5 files changed, 32 insertions(+), 18 deletions(-)
New commits:
diff-tree a366164c0c0cb153b0fcbd6e8810965f5da16532 (from 6124fb56eb8a96750c18a2986f952de0d0f9c179)
Author: Guillem Jover <guillem.jover at nokia.com>
Date: Thu Feb 15 14:26:16 2007 -0500
rename nokia770 to omap
The Nokia 770 code is OMAP generic, so others may benefit, also it
should only be available on ARM. Switched the --with-omap to be
auto (from no), but only enabled automatically on ARM.
diff --git a/configure.in b/configure.in
index 231114f..053d738 100644
--- a/configure.in
+++ b/configure.in
@@ -646,12 +646,28 @@ elif test "x$with_macbookpro" = "x" ; th
fi
AM_CONDITIONAL(BUILD_MACBOOKPRO, test x$BUILD_MACBOOKPRO = xyes)
-AC_ARG_WITH(nokia770, [ --with-nokia770 Whether to build Nokia 770 utils (no)])
-BUILD_N770=no
-if test "x$with_nokia770" = "xyes"; then
- BUILD_N770=yes
+AC_ARG_WITH([omap],
+ [AS_HELP_STRING([--with-omap],
+ [Whether to build OMAP utils (auto)])])
+BUILD_OMAP=no
+if test "x$with_omap" = "xyes" ; then
+ BUILD_OMAP=yes
+elif test "x$with_omap" = "x" ; then
+ case "${HALD_BACKEND}" in
+ linux)
+ case "${host}" in
+ arm*-*-*)
+ BUILD_OMAP=yes
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
fi
-AM_CONDITIONAL(BUILD_N770, test x$BUILD_N770 = xyes)
+AM_CONDITIONAL(BUILD_OMAP, [test x$BUILD_OMAP = xyes])
dnl cpufreq
AC_ARG_WITH(cpufreq, [ --with-cpufreq Whether to build cpufreq utils (auto)])
@@ -802,6 +818,7 @@ echo "
use APM: ${msg_apm}
Macbook Pro utils: ${BUILD_MACBOOKPRO} (Linux only, x86 only, requires libpci)
+ OMAP utils: ${BUILD_OMAP} (Linux only, arm only)
CPU frequency scaling: ${BUILD_CPUFREQ} (Linux only)
USB wireless mouse power: ${BUILD_USBCSR} (Linux only, requires libusb)
Dell Backlight ${BUILD_DELL} (Linux only, requires libsmbios >= 0.11.6)
diff --git a/fdi/policy/10osvendor/10-nokia770-backlight.fdi b/fdi/policy/10osvendor/10-nokia770-backlight.fdi
deleted file mode 100644
index ca1c19c..0000000
--- a/fdi/policy/10osvendor/10-nokia770-backlight.fdi
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-
-<deviceinfo version="0.2">
- <device>
- <match key="platform.id" string="omapfb">
- <spawn udi="/org/freedesktop/Hal/devices/omapfb_bl"/>
- </match>
- </device>
- <device>
- <match key="info.udi" string="/org/freedesktop/Hal/devices/omapfb_bl">
- <merge key="info.product" type="string">Nokia 770 LCD controller and panel</merge>
- <append key="info.capabilities" type="strlist">laptop_panel</append>
- <merge key="laptop_panel.access_method" type="string">custom</merge>
- <merge key="laptop_panel.num_levels" type="int">15</merge>
- <append key="info.addons" type="strlist">hald-addon-nokia770-backlight</append>
- </match>
- </device>
-</deviceinfo>
diff --git a/fdi/policy/10osvendor/10-omap-backlight.fdi b/fdi/policy/10osvendor/10-omap-backlight.fdi
new file mode 100644
index 0000000..5d3f1ce
--- /dev/null
+++ b/fdi/policy/10osvendor/10-omap-backlight.fdi
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<deviceinfo version="0.2">
+ <device>
+ <match key="platform.id" string="omapfb">
+ <spawn udi="/org/freedesktop/Hal/devices/omapfb_bl"/>
+ </match>
+ </device>
+ <device>
+ <match key="info.udi" string="/org/freedesktop/Hal/devices/omapfb_bl">
+ <merge key="info.product" type="string">OMAP LCD controller and panel</merge>
+ <append key="info.capabilities" type="strlist">laptop_panel</append>
+ <merge key="laptop_panel.access_method" type="string">custom</merge>
+ <merge key="laptop_panel.num_levels" type="int">15</merge>
+ <append key="info.addons" type="strlist">hald-addon-omap-backlight</append>
+ </match>
+ </device>
+</deviceinfo>
diff --git a/fdi/policy/10osvendor/Makefile.am b/fdi/policy/10osvendor/Makefile.am
index aed14e1..e2e1d8a 100644
--- a/fdi/policy/10osvendor/Makefile.am
+++ b/fdi/policy/10osvendor/Makefile.am
@@ -21,8 +21,8 @@ if BUILD_USBCSR
dist_fdi_DATA += 10-usbcsr-mice.fdi
endif
-if BUILD_N770
-dist_fdi_DATA += 10-nokia770-backlight.fdi
+if BUILD_OMAP
+dist_fdi_DATA += 10-omap-backlight.fdi
endif
if BUILD_DELL
diff --git a/hald/linux/addons/Makefile.am b/hald/linux/addons/Makefile.am
index 32bfb4d..597aee8 100644
--- a/hald/linux/addons/Makefile.am
+++ b/hald/linux/addons/Makefile.am
@@ -25,9 +25,11 @@ libexec_PROGRAMS += \
hald-addon-acpi-buttons-toshiba
endif
-if BUILD_N770
+if BUILD_OMAP
libexec_PROGRAMS += \
- hald-addon-nokia770-backlight
+ hald-addon-omap-backlight
+hald_addon_omap_backlight_SOURCES = addon-omap-backlight.c ../../logger.c ../../util_helper.c
+hald_addon_omap_backlight_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@
endif
if BUILD_MACBOOKPRO
@@ -73,8 +75,3 @@ hald_addon_pmu_LDADD = $(top_builddir)/l
hald_addon_storage_SOURCES = addon-storage.c ../../logger.c ../../util_helper.c
hald_addon_storage_LDADD = $(top_builddir)/libhal/libhal.la
-
-if BUILD_N770
-hald_addon_nokia770_backlight_SOURCES = addon-nokia770-backlight.c ../../logger.c ../../util_helper.c
-hald_addon_nokia770_backlight_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@
-endif
diff --git a/hald/linux/addons/addon-nokia770-backlight.c b/hald/linux/addons/addon-nokia770-backlight.c
deleted file mode 100644
index b9cefe1..0000000
--- a/hald/linux/addons/addon-nokia770-backlight.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/***************************************************************************
- * CVSID: $Id$
- *
- * addon-nokia770-backlight.c : daemon, handling Nokia 770
- * non-standard backlight. Based on macbookpro addon by
- * David Zeuthen and Nicolas Boichat
- *
- * Copyright (C) 2006 Sergey Lapin <slapinid at gmail.com>
- *
- * Licensed under the Academic Free License version 2.1
- *
- * 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **************************************************************************/
-
-#include <config.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/io.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <glib/gmain.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-
-#include "libhal/libhal.h"
-#include "../../logger.h"
-#include "../../util_helper.h"
-
-
-static GMainLoop *main_loop;
-static LibHalContext *halctx = NULL;
-static char * udi;
-static DBusConnection *conn;
-
-#define NUM_BUF_LEN 11
-
-static char buffer[NUM_BUF_LEN];
-
-struct backlight
-{
- void (*set_backlight_level)(struct backlight * bl, int i);
- int (*get_backlight_level)(struct backlight * bl);
- void (*backlight_init)(struct backlight * bl);
- int bl_min;
- int bl_max;
-};
-
-struct backlight bl_data;
-
-/* Reads backligh level */
-static int read_backlight(struct backlight * bl)
-{
- int fd;
-
- fd = open("/sys/devices/platform/omapfb/panel/backlight_level", O_RDONLY);
- if(fd <0 || read(fd, buffer, NUM_BUF_LEN) < 0)
- return -1;
-
- return atoi(buffer);
-}
-
-/* Read maximum bl level */
-/* TODO: set actual maximum level in property.
- No we have fixed value in FDI file, but it
- is better to set it in addon code.
-*/
-static void backlight_init(struct backlight * bl)
-{
- int fd;
-
- /* Reading maximum backlight level */
- fd = open("/sys/devices/platform/omapfb/panel/backlight_max", O_RDONLY);
-
- if(fd <0 || read(fd, buffer, NUM_BUF_LEN - 1) < 0)
- return;
-
- bl->bl_max = atoi(buffer);
- close(fd);
-}
-
-/* Setting backlight level */
-static void write_backlight(struct backlight * bl, int level)
-{
- int fd, l;
-
- /* sanity-checking level we're required to set */
- if(level > bl->bl_max)
- level = bl->bl_max;
-
- if(level < bl->bl_min)
- level = bl->bl_min;
-
- fd = open("/sys/devices/platform/omapfb/panel/backlight_level", O_WRONLY);
- l = snprintf(buffer, NUM_BUF_LEN - 1, "%d", level);
-
- if(l >= (NUM_BUF_LEN - 1)) {
- close(fd);
- return;
- }
-
- write(fd, buffer, l);
- close(fd);
-}
-
-/* DBus filter function */
-static DBusHandlerResult
-filter_function (DBusConnection *connection, DBusMessage *message, void *userdata)
-{
- DBusError err;
- DBusMessage *reply;
-
-#ifdef DEBUG_N770_BL
- dbg ("filter_function: sender=%s destination=%s obj_path=%s interface=%s method=%s",
- dbus_message_get_sender (message),
- dbus_message_get_destination (message),
- dbus_message_get_path (message),
- dbus_message_get_interface (message),
- dbus_message_get_member (message));
-#endif
- reply = NULL;
-
- if (dbus_message_is_method_call (message,
- "org.freedesktop.Hal.Device.LaptopPanel",
- "SetBrightness")) {
- int brightness;
-
- dbus_error_init (&err);
- if (dbus_message_get_args (message,
- &err,
- DBUS_TYPE_INT32, &brightness,
- DBUS_TYPE_INVALID)) {
- if (brightness < 0 || brightness > 228) {
- reply = dbus_message_new_error (message,
- "org.freedesktop.Hal.Device.LaptopPanel.Invalid",
- "Brightness has to be between 0 and 228!");
-
- } else {
- int return_code;
-
- bl_data.set_backlight_level (&bl_data, brightness);
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- goto error;
-
- return_code = 0;
- dbus_message_append_args (reply,
- DBUS_TYPE_INT32, &return_code,
- DBUS_TYPE_INVALID);
- }
-
- dbus_connection_send (connection, reply, NULL);
- }
-
- } else if (dbus_message_is_method_call (message,
- "org.freedesktop.Hal.Device.LaptopPanel",
- "GetBrightness")) {
- int brightness;
-
- dbus_error_init (&err);
- if (dbus_message_get_args (message,
- &err,
- DBUS_TYPE_INVALID)) {
-
- brightness = bl_data.get_backlight_level (&bl_data);
- if (brightness < bl_data.bl_min)
- brightness = bl_data.bl_min;
- if (brightness > bl_data.bl_max)
- brightness = bl_data.bl_max;
-
- /* dbg ("getting brightness, it's %d", brightness); */
-
- reply = dbus_message_new_method_return (message);
- if (reply == NULL)
- goto error;
-
- dbus_message_append_args (reply,
- DBUS_TYPE_INT32, &brightness,
- DBUS_TYPE_INVALID);
- dbus_connection_send (connection, reply, NULL);
- }
-
- }
-
-error:
- if (reply != NULL)
- dbus_message_unref (reply);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
-/* Setting-up backlight structure */
-static void setup_cb(void)
-{
- memset(&bl_data, 0, sizeof(struct backlight));
- bl_data.backlight_init = backlight_init;
- bl_data.get_backlight_level = read_backlight;
- bl_data.set_backlight_level = write_backlight;
-}
-
-int
-main (int argc, char *argv[])
-{
- DBusError err;
-
- setup_logger ();
- setup_cb();
- udi = getenv ("UDI");
-
- HAL_DEBUG (("udi=%s", udi));
- if (udi == NULL) {
- HAL_ERROR (("No device specified"));
- return -2;
- }
-
- dbus_error_init (&err);
- if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
- HAL_ERROR (("Cannot connect to hald"));
- return -3;
- }
-
-
-
- conn = libhal_ctx_get_dbus_connection (halctx);
- dbus_connection_setup_with_g_main (conn, NULL);
-
- dbus_connection_add_filter (conn, filter_function, NULL, NULL);
-
- if (!libhal_device_claim_interface (halctx,
- "/org/freedesktop/Hal/devices/omapfb_bl",
- "org.freedesktop.Hal.Device.LaptopPanel",
- " <method name=\"SetBrightness\">\n"
- " <arg name=\"brightness_value\" direction=\"in\" type=\"i\"/>\n"
- " <arg name=\"return_code\" direction=\"out\" type=\"i\"/>\n"
- " </method>\n"
- " <method name=\"GetBrightness\">\n"
- " <arg name=\"brightness_value\" direction=\"out\" type=\"i\"/>\n"
- " </method>\n",
- &err)) {
- HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'"));
- return -4;
- }
- dbus_error_init (&err);
- if (!libhal_device_addon_is_ready (halctx, udi, &err)) {
- return -4;
- }
- bl_data.backlight_init(&bl_data);
- main_loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (main_loop);
- return 0;
-}
diff --git a/hald/linux/addons/addon-omap-backlight.c b/hald/linux/addons/addon-omap-backlight.c
new file mode 100644
index 0000000..f7a443d
--- /dev/null
+++ b/hald/linux/addons/addon-omap-backlight.c
@@ -0,0 +1,271 @@
+/***************************************************************************
+ * CVSID: $Id$
+ *
+ * addon-omap-backlight.c : daemon, handling OMAP
+ * non-standard backlight. Based on macbookpro addon by
+ * David Zeuthen and Nicolas Boichat
+ *
+ * Copyright (C) 2006 Sergey Lapin <slapinid at gmail.com>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ **************************************************************************/
+
+#include <config.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/io.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <glib/gmain.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "libhal/libhal.h"
+#include "../../logger.h"
+#include "../../util_helper.h"
+
+
+static GMainLoop *main_loop;
+static LibHalContext *halctx = NULL;
+static char * udi;
+static DBusConnection *conn;
+
+#define NUM_BUF_LEN 11
+
+static char buffer[NUM_BUF_LEN];
+
+struct backlight
+{
+ void (*set_backlight_level)(struct backlight * bl, int i);
+ int (*get_backlight_level)(struct backlight * bl);
+ void (*backlight_init)(struct backlight * bl);
+ int bl_min;
+ int bl_max;
+};
+
+struct backlight bl_data;
+
+/* Reads backligh level */
+static int read_backlight(struct backlight * bl)
+{
+ int fd;
+
+ fd = open("/sys/devices/platform/omapfb/panel/backlight_level", O_RDONLY);
+ if(fd <0 || read(fd, buffer, NUM_BUF_LEN) < 0)
+ return -1;
+
+ return atoi(buffer);
+}
+
+/* Read maximum bl level */
+/* TODO: set actual maximum level in property.
+ No we have fixed value in FDI file, but it
+ is better to set it in addon code.
+*/
+static void backlight_init(struct backlight * bl)
+{
+ int fd;
+
+ /* Reading maximum backlight level */
+ fd = open("/sys/devices/platform/omapfb/panel/backlight_max", O_RDONLY);
+
+ if(fd <0 || read(fd, buffer, NUM_BUF_LEN - 1) < 0)
+ return;
+
+ bl->bl_max = atoi(buffer);
+ close(fd);
+}
+
+/* Setting backlight level */
+static void write_backlight(struct backlight * bl, int level)
+{
+ int fd, l;
+
+ /* sanity-checking level we're required to set */
+ if(level > bl->bl_max)
+ level = bl->bl_max;
+
+ if(level < bl->bl_min)
+ level = bl->bl_min;
+
+ fd = open("/sys/devices/platform/omapfb/panel/backlight_level", O_WRONLY);
+ l = snprintf(buffer, NUM_BUF_LEN - 1, "%d", level);
+
+ if(l >= (NUM_BUF_LEN - 1)) {
+ close(fd);
+ return;
+ }
+
+ write(fd, buffer, l);
+ close(fd);
+}
+
+/* DBus filter function */
+static DBusHandlerResult
+filter_function (DBusConnection *connection, DBusMessage *message, void *userdata)
+{
+ DBusError err;
+ DBusMessage *reply;
+
+#ifdef DEBUG_OMAP_BL
+ dbg ("filter_function: sender=%s destination=%s obj_path=%s interface=%s method=%s",
+ dbus_message_get_sender (message),
+ dbus_message_get_destination (message),
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
+#endif
+ reply = NULL;
+
+ if (dbus_message_is_method_call (message,
+ "org.freedesktop.Hal.Device.LaptopPanel",
+ "SetBrightness")) {
+ int brightness;
+
+ dbus_error_init (&err);
+ if (dbus_message_get_args (message,
+ &err,
+ DBUS_TYPE_INT32, &brightness,
+ DBUS_TYPE_INVALID)) {
+ if (brightness < 0 || brightness > 228) {
+ reply = dbus_message_new_error (message,
+ "org.freedesktop.Hal.Device.LaptopPanel.Invalid",
+ "Brightness has to be between 0 and 228!");
+
+ } else {
+ int return_code;
+
+ bl_data.set_backlight_level (&bl_data, brightness);
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ goto error;
+
+ return_code = 0;
+ dbus_message_append_args (reply,
+ DBUS_TYPE_INT32, &return_code,
+ DBUS_TYPE_INVALID);
+ }
+
+ dbus_connection_send (connection, reply, NULL);
+ }
+
+ } else if (dbus_message_is_method_call (message,
+ "org.freedesktop.Hal.Device.LaptopPanel",
+ "GetBrightness")) {
+ int brightness;
+
+ dbus_error_init (&err);
+ if (dbus_message_get_args (message,
+ &err,
+ DBUS_TYPE_INVALID)) {
+
+ brightness = bl_data.get_backlight_level (&bl_data);
+ if (brightness < bl_data.bl_min)
+ brightness = bl_data.bl_min;
+ if (brightness > bl_data.bl_max)
+ brightness = bl_data.bl_max;
+
+ /* dbg ("getting brightness, it's %d", brightness); */
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ goto error;
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_INT32, &brightness,
+ DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ }
+
+ }
+
+error:
+ if (reply != NULL)
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+/* Setting-up backlight structure */
+static void setup_cb(void)
+{
+ memset(&bl_data, 0, sizeof(struct backlight));
+ bl_data.backlight_init = backlight_init;
+ bl_data.get_backlight_level = read_backlight;
+ bl_data.set_backlight_level = write_backlight;
+}
+
+int
+main (int argc, char *argv[])
+{
+ DBusError err;
+
+ setup_logger ();
+ setup_cb();
+ udi = getenv ("UDI");
+
+ HAL_DEBUG (("udi=%s", udi));
+ if (udi == NULL) {
+ HAL_ERROR (("No device specified"));
+ return -2;
+ }
+
+ dbus_error_init (&err);
+ if ((halctx = libhal_ctx_init_direct (&err)) == NULL) {
+ HAL_ERROR (("Cannot connect to hald"));
+ return -3;
+ }
+
+
+
+ conn = libhal_ctx_get_dbus_connection (halctx);
+ dbus_connection_setup_with_g_main (conn, NULL);
+
+ dbus_connection_add_filter (conn, filter_function, NULL, NULL);
+
+ if (!libhal_device_claim_interface (halctx,
+ "/org/freedesktop/Hal/devices/omapfb_bl",
+ "org.freedesktop.Hal.Device.LaptopPanel",
+ " <method name=\"SetBrightness\">\n"
+ " <arg name=\"brightness_value\" direction=\"in\" type=\"i\"/>\n"
+ " <arg name=\"return_code\" direction=\"out\" type=\"i\"/>\n"
+ " </method>\n"
+ " <method name=\"GetBrightness\">\n"
+ " <arg name=\"brightness_value\" direction=\"out\" type=\"i\"/>\n"
+ " </method>\n",
+ &err)) {
+ HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.LaptopPanel'"));
+ return -4;
+ }
+ dbus_error_init (&err);
+ if (!libhal_device_addon_is_ready (halctx, udi, &err)) {
+ return -4;
+ }
+ bl_data.backlight_init(&bl_data);
+ main_loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (main_loop);
+ return 0;
+}
More information about the hal-commit
mailing list