aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fsodeviced/conf/nokia_n900/fsodeviced.conf12
-rw-r--r--fsodeviced/configure.ac5
-rw-r--r--fsodeviced/src/plugins/Makefile.am8
-rw-r--r--fsodeviced/src/plugins/ambientlight_n900/Makefile.am34
-rw-r--r--fsodeviced/src/plugins/ambientlight_n900/plugin.vala130
-rw-r--r--fsodeviced/src/plugins/n900_powercontrol/plugin.vala162
-rw-r--r--fsodeviced/src/plugins/n900_quirks/Makefile.am (renamed from fsodeviced/src/plugins/n900_powercontrol/Makefile.am)32
-rw-r--r--fsodeviced/src/plugins/n900_quirks/ambientlight.vala84
-rw-r--r--fsodeviced/src/plugins/n900_quirks/plugin.vala114
-rw-r--r--fsodeviced/src/plugins/n900_quirks/powercontrol.vala105
-rw-r--r--fsodeviced/src/plugins/n900_quirks/powersupply.vala347
-rw-r--r--fsodeviced/src/plugins/n900_quirks/proximity.vala175
-rw-r--r--fsodeviced/src/plugins/powersupply_n900/Makefile.am39
-rw-r--r--fsodeviced/src/plugins/powersupply_n900/plugin.vala389
-rw-r--r--fsodeviced/src/plugins/proximity_n900/Makefile.am36
-rw-r--r--fsodeviced/src/plugins/proximity_n900/plugin.vala223
16 files changed, 858 insertions, 1037 deletions
diff --git a/fsodeviced/conf/nokia_n900/fsodeviced.conf b/fsodeviced/conf/nokia_n900/fsodeviced.conf
index 446c9b80..674a0304 100644
--- a/fsodeviced/conf/nokia_n900/fsodeviced.conf
+++ b/fsodeviced/conf/nokia_n900/fsodeviced.conf
@@ -30,8 +30,6 @@ ignore_by_name = twl4030:vibrator
[fsodevice.kernel26_powersupply]
-[fsodevice.powersupply_n900]
-
[fsodevice.powercontrol_ifconfig]
interface = wlan0
@@ -82,5 +80,11 @@ suspend = 30
player_type = alsa
router_type = alsa
-#[fsodevice.proximity_n900]
-## module for old Maemo kernels
+[fsodevice.n900_quirks]
+
+[fsodevice.n900_quirks/powersupply]
+
+[fsodevice.n900_quirks/powercontrol]
+
+# [fsodevice.n900_quirks/ambientlight]
+# [fsodevice.n900_quirks/proximity]
diff --git a/fsodeviced/configure.ac b/fsodeviced/configure.ac
index 41e56f0b..f93a26ef 100644
--- a/fsodeviced/configure.ac
+++ b/fsodeviced/configure.ac
@@ -229,7 +229,6 @@ AC_CONFIG_FILES([
src/plugins/accelerometer/Makefile
src/plugins/accelerometer_kxsd9/Makefile
src/plugins/accelerometer_lis302/Makefile
- src/plugins/ambientlight_n900/Makefile
src/plugins/audio/Makefile
src/plugins/backlight_omappanel/Makefile
src/plugins/gpio_input/Makefile
@@ -244,16 +243,14 @@ AC_CONFIG_FILES([
src/plugins/kernel_idle/Makefile
src/plugins/kernel_info/Makefile
src/plugins/kernel_input/Makefile
- src/plugins/n900_powercontrol/Makefile
src/plugins/openmoko_powercontrol/Makefile
src/plugins/gta04_quirks/Makefile
src/plugins/herring_quirks/Makefile
+ src/plugins/n900_quirks/Makefile
src/plugins/powercontrol_ifconfig/Makefile
src/plugins/player_alsa/Makefile
src/plugins/player_canberra/Makefile
src/plugins/player_gstreamer/Makefile
- src/plugins/powersupply_n900/Makefile
- src/plugins/proximity_n900/Makefile
src/plugins/router_alsa/Makefile
src/plugins/router_qdsp5/Makefile
src/plugins/thinkpad_powercontrol/Makefile
diff --git a/fsodeviced/src/plugins/Makefile.am b/fsodeviced/src/plugins/Makefile.am
index 525666ef..8d3f00d6 100644
--- a/fsodeviced/src/plugins/Makefile.am
+++ b/fsodeviced/src/plugins/Makefile.am
@@ -4,8 +4,6 @@ NULL =
AUTOMAKE_OPTIONS = subdir-objects
SUBDIRS = \
- ambientlight_n900 \
- \
accelerometer \
accelerometer_kxsd9 \
accelerometer_lis302 \
@@ -28,22 +26,18 @@ SUBDIRS = \
kernel_info \
kernel_input \
\
- n900_powercontrol \
openmoko_powercontrol \
thinkpad_powercontrol \
\
powercontrol_ifconfig \
\
- powersupply_n900 \
- \
vibrator_ledclass \
vibrator_omapvibe \
vibrator_timedoutputclass \
\
gta04_quirks \
herring_quirks \
- \
- proximity_n900 \
+ n900_quirks \
\
gpio_input \
dummy_input \
diff --git a/fsodeviced/src/plugins/ambientlight_n900/Makefile.am b/fsodeviced/src/plugins/ambientlight_n900/Makefile.am
deleted file mode 100644
index 4d628d0c..00000000
--- a/fsodeviced/src/plugins/ambientlight_n900/Makefile.am
+++ /dev/null
@@ -1,34 +0,0 @@
-include $(top_srcdir)/Makefile.decl
-NULL =
-
-AM_CFLAGS = \
- -DG_LOG_DOMAIN=\"fsodevice.ambientlight_n900\" \
- $(NULL)
-AM_VALAFLAGS =
-
-modlibexecdir = $(libdir)/cornucopia/modules/fsodevice
-modlibexec_LTLIBRARIES = ambientlight_n900.la
-ambientlight_n900_la_SOURCES = plugin.vala
-ambientlight_n900_la_VALAFLAGS = \
- --basedir $(top_srcdir) \
- --vapidir $(top_srcdir)/fsoframework \
- --pkg glib-2.0 \
- --pkg fso-glib-1.0 \
- --pkg fsoframework-2.0 \
- $(DEBUG_VALAFLAGS) \
- $(NULL)
-ambientlight_n900_la_CFLAGS = \
- $(FSO_CFLAGS) \
- $(DEBUG_CFLAGS) \
- $(NULL)
-ambientlight_n900_la_LIBADD = \
- $(FSO_LIBS) \
- $(top_builddir)/src/lib/libfsodevice.la \
- $(NULL)
-ambientlight_n900_la_LDFLAGS = -no-undefined -module -avoid-version
-# ambientlight_n900_la_LIBTOOLFLAGS = --tag=disable-static
-
-CLEANFILES =
-MAINTAINERCLEANFILES = \
- Makefile.in \
- $(NULL)
diff --git a/fsodeviced/src/plugins/ambientlight_n900/plugin.vala b/fsodeviced/src/plugins/ambientlight_n900/plugin.vala
deleted file mode 100644
index 94b42425..00000000
--- a/fsodeviced/src/plugins/ambientlight_n900/plugin.vala
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-
-namespace AmbientLight
-{
- internal const string DEFAULT_NODE = "class/i2c-adapter/i2c-2/2-0029/";
- internal const int DARKNESS = 0;
- internal const int SUNLIGHT = 100;
-
-class N900 : FreeSmartphone.Device.AmbientLight, FsoFramework.AbstractObject
-{
- FsoFramework.Subsystem subsystem;
-
- private string sysfsnode;
- private string luxnode;
-
- private int maxvalue;
- private int minvalue;
-
- public N900( FsoFramework.Subsystem subsystem, string sysfsnode )
- {
- minvalue = DARKNESS;
- maxvalue = SUNLIGHT;
-
- this.subsystem = subsystem;
- this.sysfsnode = sysfsnode;
-
- this.luxnode = sysfsnode + "/lux";
- if ( !FsoFramework.FileHandling.isPresent( this.luxnode ) )
- {
- logger.error( @"Sysfs class is damaged, missing $(this.luxnode); skipping." );
- return;
- }
-
- subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.AmbientLight>( FsoFramework.Device.ServiceDBusName, FsoFramework.Device.AmbientLightServicePath, this );
-
- logger.info( "Created" );
- }
-
- public override string repr()
- {
- return @"<$sysfsnode>";
- }
-
- private int _valueToPercent( int value )
- {
- double v = value;
- return (int)(100.0 / (maxvalue-minvalue) * (v-minvalue));
- }
-
- //
- // FreeSmartphone.Device.AmbientLight (DBUS API)
- //
- public async void get_ambient_light_brightness( out int brightness, out int timestamp ) throws FreeSmartphone.Error, DBusError, IOError
- {
- var lux = FsoFramework.FileHandling.read( this.luxnode ).to_int();
- //brightness = _valueToPercent( lux );
- brightness = lux;
- var t = (int) time_t();
- timestamp = t;
- }
-}
-
-} /* namespace */
-
-static string sysfs_root;
-AmbientLight.N900 instance;
-
-/**
- * This function gets called on plugin initialization time.
- * @return the name of your plugin here
- * @note that it needs to be a name in the format <subsystem>.<plugin>
- * else your module will be unloaded immediately.
- **/
-public static string fso_factory_function( FsoFramework.Subsystem subsystem ) throws Error
-{
- // grab sysfs paths
- var config = FsoFramework.theConfig;
- sysfs_root = config.stringValue( "cornucopia", "sysfs_root", "/sys" );
- var dirname = GLib.Path.build_filename( sysfs_root, AmbientLight.DEFAULT_NODE );
- debug( @"looking in $dirname" );
- if ( FsoFramework.FileHandling.isPresent( dirname ) )
- {
- instance = new AmbientLight.N900( subsystem, dirname );
- }
- else
- {
- FsoFramework.theLogger.error( "No ambient light device found; ambient light object will not be available" );
- }
- return "fsodevice.ambientlight_n900";
-}
-
-[ModuleInit]
-public static void fso_register_function( TypeModule module )
-{
- FsoFramework.theLogger.debug( "fsodevice.ambientlight_n900 fso_register_function()" );
-}
-
-/**
- * This function gets called on plugin load time.
- * @return false, if the plugin operating conditions are present.
- * @note Some versions of glib contain a bug that leads to a SIGSEGV
- * in g_module_open, if you return true here.
- **/
-/*public static bool g_module_check_init( void* m )
-{
- var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS );
- return (!ok);
-}
-*/
-
-// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/n900_powercontrol/plugin.vala b/fsodeviced/src/plugins/n900_powercontrol/plugin.vala
deleted file mode 100644
index 3023698e..00000000
--- a/fsodeviced/src/plugins/n900_powercontrol/plugin.vala
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-
-static const string MODULE_NAME = "fsodevice.n900_powercontrol";
-
-namespace N900
-{
-
-/**
- * Bluetooth power control for Nokia N900
- **/
-class BluetoothPowerControl : FsoDevice.BasePowerControl
-{
- private FsoFramework.Subsystem subsystem;
- private string sysfsnode;
- private string name;
-
- public BluetoothPowerControl( FsoFramework.Subsystem subsystem, string sysfsnode )
- {
- base( Path.build_filename( sysfsnode, "power_on" ) );
- this.subsystem = subsystem;
- this.sysfsnode = sysfsnode;
- this.name = Path.get_basename( sysfsnode );
-
- subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.PowerControl>( FsoFramework.Device.ServiceDBusName, FsoFramework.Device.PowerControlServicePath, this );
-
- logger.info( "Created." );
- }
-
- public override bool getPower()
- {
- return false;
- }
-
- public override void setPower( bool on )
- {
- if ( !on )
- {
- Posix.system( "killall bluetoothd; killall -9 bluetoothd" );
- Posix.system( "modprobe -r hci_h4p" );
- FsoFramework.FileHandling.write( "0", Path.build_filename( wl12xx, "bt_coex_mode" ) );
- return;
- }
-
- Posix.system( "modprobe hci_h4p" );
- FsoFramework.FileHandling.write( "00:11:22:33:44:55", Path.build_filename( sysfsnode, "bdaddr" ) );
- Posix.system( "modprobe -r hci_h4p" );
- Posix.system( "modprobe hci_h4p" );
- FsoFramework.FileHandling.write( "1", Path.build_filename( wl12xx, "bt_coex_mode" ) );
- }
-}
-
-/**
- * WiFi power control for Nokia N900
- **/
-class WiFiPowerControl : FsoDevice.BasePowerControl
-{
- private FsoFramework.Subsystem subsystem;
- private string sysfsnode;
- private string name;
-
- public WiFiPowerControl( FsoFramework.Subsystem subsystem, string sysfsnode )
- {
- base( Path.build_filename( sysfsnode, null ) );
- this.subsystem = subsystem;
- this.sysfsnode = sysfsnode;
- this.name = Path.get_basename( sysfsnode );
-
- subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.PowerControl>( FsoFramework.Device.ServiceDBusName, FsoFramework.Device.PowerControlServicePath, this );
-
- logger.info( "Created." );
- }
-
- public override bool getPower()
- {
- return false;
- }
-
- public override void setPower( bool on )
- {
- }
-}
-
-} /* namespace */
-
-internal List<FsoDevice.BasePowerControlResource> resources;
-internal List<FsoDevice.BasePowerControl> instances;
-internal static string sysfs_root;
-internal static string hci_h4p;
-internal static string wl12xx;
-
-/**
- * This function gets called on plugin initialization time.
- * @return the name of your plugin here
- * @note that it needs to be a name in the format <subsystem>.<plugin>
- * else your module will be unloaded immediately.
- **/
-public static string fso_factory_function( FsoFramework.Subsystem subsystem ) throws Error
-{
- // grab sysfs paths
- var config = FsoFramework.theConfig;
- sysfs_root = config.stringValue( "cornucopia", "sysfs_root", "/sys" );
- hci_h4p = Path.build_filename( sysfs_root, "devices", "platform", "hci_h4p" );
- wl12xx = Path.build_filename( sysfs_root, "devices", "platform", "wl12xx" );
-
- var bto = new N900.BluetoothPowerControl( subsystem, hci_h4p );
- instances.append( bto );
-#if WANT_FSO_RESOURCE
- resources.append( new FsoDevice.BasePowerControlResource( bto, "Bluetooth", subsystem ) );
-#endif
-
- /*
- var wifio = new N900.WiFiPowerControl( subsystem, wl12xx );
- instances.append( wifio );
-#if WANT_FSO_RESOURCE
- resources.append( new FsoDevice.BasePowerControlResource( wifio, "WiFi", subsystem ) );
-#endif
- */
-
- //TODO: add other devices
-
- return MODULE_NAME;
-}
-
-[ModuleInit]
-public static void fso_register_function( TypeModule module )
-{
- FsoFramework.theLogger.debug( "fsodevice.n900_powercontrol fso_register_function()" );
-}
-
-/**
- * This function gets called on plugin load time.
- * @return false, if the plugin operating conditions are present.
- * @note Some versions of glib contain a bug that leads to a SIGSEGV
- * in g_module_open, if you return true here.
- **/
-/*public static bool g_module_check_init( void* m )
-{
- var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS );
- return (!ok);
-}
-*/
-
-// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/n900_powercontrol/Makefile.am b/fsodeviced/src/plugins/n900_quirks/Makefile.am
index 02f10d36..b3243783 100644
--- a/fsodeviced/src/plugins/n900_powercontrol/Makefile.am
+++ b/fsodeviced/src/plugins/n900_quirks/Makefile.am
@@ -2,7 +2,7 @@ include $(top_srcdir)/Makefile.decl
NULL =
AM_CFLAGS = \
- -DG_LOG_DOMAIN=\"fsodevice.n900_powercontrol\" \
+ -DG_LOG_DOMAIN=\"fsodevice.n900_quirks\" \
$(NULL)
AM_VALAFLAGS =
@@ -11,33 +11,47 @@ AM_VALAFLAGS += -D WANT_FSO_RESOURCE
endif
modlibexecdir = $(libdir)/cornucopia/modules/fsodevice
-modlibexec_LTLIBRARIES = n900_powercontrol.la
-n900_powercontrol_la_SOURCES = plugin.vala
-n900_powercontrol_la_VALAFLAGS = \
+modlibexec_LTLIBRARIES = n900_quirks.la
+n900_quirks_la_SOURCES = \
+ plugin.vala \
+ ambientlight.vala \
+ powercontrol.vala \
+ powersupply.vala \
+ proximity.vala \
+ $(NULL)
+n900_quirks_la_VALAFLAGS = \
--basedir $(top_srcdir) \
+ --vapidir $(top_srcdir)/fsoframework \
+ --vapidir $(top_srcdir)/vapi \
--vapidir $(top_srcdir)/src/lib \
+ --pkg linux \
--pkg glib-2.0 \
- --pkg gio-2.0 \
+ --pkg gee-1.0 \
--pkg fso-glib-1.0 \
--pkg fsoframework-2.0 \
+ --pkg fsotransport-2.0 \
+ --pkg fsosystem-2.0 \
--pkg fsodevice-2.0 \
$(DEBUG_VALAFLAGS) \
$(NULL)
-n900_powercontrol_la_CFLAGS = \
+n900_quirks_la_CFLAGS = \
-I$(top_srcdir)/src/lib \
+ -I$(top_srcdir)/src/3rdparty \
+ -I$(top_srcdir) \
$(FSO_CFLAGS) \
$(GLIB_CFLAGS) \
$(DEBUG_CFLAGS) \
$(NULL)
-n900_powercontrol_la_LIBADD = \
+n900_quirks_la_LIBADD = \
$(FSO_LIBS) \
$(GLIB_LIBS) \
$(top_builddir)/src/lib/libfsodevice.la \
$(NULL)
-n900_powercontrol_la_LDFLAGS = -no-undefined -module -avoid-version
-# n900_powercontrol_la_LIBTOOLFLAGS = --tag=disable-static
+n900_quirks_la_LDFLAGS = -no-undefined -module -avoid-version
+# n900_quirks_la_LIBTOOLFLAGS = --tag=disable-static
CLEANFILES =
MAINTAINERCLEANFILES = \
Makefile.in \
$(NULL)
+
diff --git a/fsodeviced/src/plugins/n900_quirks/ambientlight.vala b/fsodeviced/src/plugins/n900_quirks/ambientlight.vala
new file mode 100644
index 00000000..db14d07e
--- /dev/null
+++ b/fsodeviced/src/plugins/n900_quirks/ambientlight.vala
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+using GLib;
+
+namespace AmbientLight
+{
+ internal const string DEFAULT_NODE = "class/i2c-adapter/i2c-2/2-0029/";
+ internal const int DARKNESS = 0;
+ internal const int SUNLIGHT = 100;
+
+ public class N900 : FreeSmartphone.Device.AmbientLight, FsoFramework.AbstractObject
+ {
+ FsoFramework.Subsystem subsystem;
+
+ private string sysfsnode;
+ private string luxnode;
+
+ private int maxvalue;
+ private int minvalue;
+
+ public N900( FsoFramework.Subsystem subsystem, string sysfsnode )
+ {
+ minvalue = DARKNESS;
+ maxvalue = SUNLIGHT;
+
+ this.subsystem = subsystem;
+ this.sysfsnode = sysfsnode;
+
+ this.luxnode = sysfsnode + "/lux";
+ if ( !FsoFramework.FileHandling.isPresent( this.luxnode ) )
+ {
+ logger.error( @"Sysfs class is damaged, missing $(this.luxnode); skipping." );
+ return;
+ }
+
+ subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.AmbientLight>( FsoFramework.Device.ServiceDBusName,
+ FsoFramework.Device.AmbientLightServicePath, this );
+
+ logger.info( "Created" );
+ }
+
+ public override string repr()
+ {
+ return @"<$sysfsnode>";
+ }
+
+ private int _valueToPercent( int value )
+ {
+ double v = value;
+ return (int)(100.0 / (maxvalue-minvalue) * (v-minvalue));
+ }
+
+ //
+ // FreeSmartphone.Device.AmbientLight (DBUS API)
+ //
+ public async void get_ambient_light_brightness( out int brightness, out int timestamp ) throws FreeSmartphone.Error, DBusError, IOError
+ {
+ var lux = FsoFramework.FileHandling.read( this.luxnode ).to_int();
+ //brightness = _valueToPercent( lux );
+ brightness = lux;
+ var t = (int) time_t();
+ timestamp = t;
+ }
+ }
+} /* namespace */
+
+// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/n900_quirks/plugin.vala b/fsodeviced/src/plugins/n900_quirks/plugin.vala
new file mode 100644
index 00000000..d02807c6
--- /dev/null
+++ b/fsodeviced/src/plugins/n900_quirks/plugin.vala
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+using GLib;
+
+namespace N900
+{
+ public static const string MODULE_NAME = "fsodevice.n900_quirks";
+}
+
+internal AmbientLight.N900 ambientlight;
+internal PowerSupply.N900 powersupply;
+internal Proximity.N900 proximity;
+internal Proximity.ProximityResource proximity_resource;
+internal List<FsoDevice.BasePowerControlResource> resources;
+internal List<FsoDevice.BasePowerControl> instances;
+
+/**
+ * This function gets called on plugin initialization time.
+ * @return the name of your plugin here
+ * @note that it needs to be a name in the format <subsystem>.<plugin>
+ * else your module will be unloaded immediately.
+ **/
+public static string fso_factory_function( FsoFramework.Subsystem subsystem ) throws Error
+{
+ var config = FsoFramework.theConfig;
+ var sysfs_root = config.stringValue( "cornucopia", "sysfs_root", "/sys" );
+
+ if ( config.hasSection( @"$(N900.MODULE_NAME)/ambientlight" ) )
+ {
+ var dirname = GLib.Path.build_filename( sysfs_root, AmbientLight.DEFAULT_NODE );
+ if ( FsoFramework.FileHandling.isPresent( dirname ) )
+ ambientlight = new AmbientLight.N900( subsystem, dirname );
+ else FsoFramework.theLogger.error( "No ambient light device found; ambient light object will not be available" );
+ }
+
+ if ( config.hasSection( @"$(N900.MODULE_NAME)/powercontrol" ) )
+ {
+ var hci_h4p = Path.build_filename( sysfs_root, "devices", "platform", "hci_h4p" );
+ var wl12xx = Path.build_filename( sysfs_root, "devices", "platform", "wl12xx" );
+ var bto = new N900.BluetoothPowerControl( subsystem, hci_h4p, wl12xx );
+ instances.append( bto );
+#if WANT_FSO_RESOURCE
+ resources.append( new FsoDevice.BasePowerControlResource( bto, "Bluetooth", subsystem ) );
+#endif
+ }
+
+ /*
+ var wifio = new N900.WiFiPowerControl( subsystem, wl12xx );
+ instances.append( wifio );
+#if WANT_FSO_RESOURCE
+ resources.append( new FsoDevice.BasePowerControlResource( wifio, "WiFi", subsystem ) );
+#endif
+ */
+
+ if ( config.hasSection( @"$(N900.MODULE_NAME)/powersupply" ) )
+ {
+ var sys_devices_platform_msusb_hdrc = "%s/devices/platform/musb_hdrc".printf( sysfs_root );
+ powersupply = new PowerSupply.N900( subsystem, sys_devices_platform_msusb_hdrc );
+ }
+
+ if ( config.hasSection( @"$(N900.MODULE_NAME)/proximity" ) )
+ {
+ var dirname = GLib.Path.build_filename( sysfs_root, "devices", "platform", "gpio-switch", "proximity" );
+ if ( FsoFramework.FileHandling.isPresent( dirname ) )
+ {
+ proximity = new Proximity.N900( subsystem, dirname );
+ proximity_resource = new Proximity.ProximityResource( subsystem, proximity );
+ }
+ else
+ {
+ FsoFramework.theLogger.error( "No proximity device found; proximity object will not be available" );
+ }
+ }
+
+ return "fsodevice.n900_quirks";
+}
+
+[ModuleInit]
+public static void fso_register_function( TypeModule module )
+{
+ FsoFramework.theLogger.debug( "fsodevice.n900_quirks fso_register_function()" );
+}
+
+/**
+ * This function gets called on plugin load time.
+ * @return false, if the plugin operating conditions are present.
+ * @note Some versions of glib contain a bug that leads to a SIGSEGV
+ * in g_module_open, if you return true here.
+ **/
+/*public static bool g_module_check_init( void* m )
+{
+ var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS );
+ return (!ok);
+}
+*/
+
+// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/n900_quirks/powercontrol.vala b/fsodeviced/src/plugins/n900_quirks/powercontrol.vala
new file mode 100644
index 00000000..cc8b452b
--- /dev/null
+++ b/fsodeviced/src/plugins/n900_quirks/powercontrol.vala
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010-2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+using GLib;
+
+namespace N900
+{
+ /**
+ * Bluetooth power control for Nokia N900
+ **/
+ class BluetoothPowerControl : FsoDevice.BasePowerControl
+ {
+ private FsoFramework.Subsystem subsystem;
+ private string sysfsnode;
+ private string name;
+ private string wl12xx;
+
+ public BluetoothPowerControl( FsoFramework.Subsystem subsystem, string sysfsnode, string wl12xx )
+ {
+ base( Path.build_filename( sysfsnode, "power_on" ) );
+ this.subsystem = subsystem;
+ this.sysfsnode = sysfsnode;
+ this.name = Path.get_basename( sysfsnode );
+ this.wl12xx = wl12xx;
+
+ subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.PowerControl>( FsoFramework.Device.ServiceDBusName,
+ FsoFramework.Device.PowerControlServicePath, this );
+
+ logger.info( "Created." );
+ }
+
+ public override bool getPower()
+ {
+ return false;
+ }
+
+ public override void setPower( bool on )
+ {
+ if ( !on )
+ {
+ Posix.system( "killall bluetoothd; killall -9 bluetoothd" );
+ Posix.system( "modprobe -r hci_h4p" );
+ FsoFramework.FileHandling.write( "0", Path.build_filename( wl12xx, "bt_coex_mode" ) );
+ return;
+ }
+
+ Posix.system( "modprobe hci_h4p" );
+ FsoFramework.FileHandling.write( "00:11:22:33:44:55", Path.build_filename( sysfsnode, "bdaddr" ) );
+ Posix.system( "modprobe -r hci_h4p" );
+ Posix.system( "modprobe hci_h4p" );
+ FsoFramework.FileHandling.write( "1", Path.build_filename( wl12xx, "bt_coex_mode" ) );
+ }
+ }
+
+ /**
+ * WiFi power control for Nokia N900
+ **/
+ class WiFiPowerControl : FsoDevice.BasePowerControl
+ {
+ private FsoFramework.Subsystem subsystem;
+ private string sysfsnode;
+ private string name;
+
+ public WiFiPowerControl( FsoFramework.Subsystem subsystem, string sysfsnode )
+ {
+ base( Path.build_filename( sysfsnode, null ) );
+ this.subsystem = subsystem;
+ this.sysfsnode = sysfsnode;
+ this.name = Path.get_basename( sysfsnode );
+
+ subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.PowerControl>( FsoFramework.Device.ServiceDBusName,
+ FsoFramework.Device.PowerControlServicePath, this );
+
+ logger.info( "Created." );
+ }
+
+ public override bool getPower()
+ {
+ return false;
+ }
+
+ public override void setPower( bool on )
+ {
+ }
+ }
+
+} /* namespace */
+
+// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/n900_quirks/powersupply.vala b/fsodeviced/src/plugins/n900_quirks/powersupply.vala
new file mode 100644
index 00000000..c20c38d1
--- /dev/null
+++ b/fsodeviced/src/plugins/n900_quirks/powersupply.vala
@@ -0,0 +1,347 @@
+/*
+ * Copyright (C) 2010-2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+using GLib;
+
+namespace PowerSupply
+{
+ const string N900_CHARGER_I2C_FILE = "/dev/i2c-2";
+
+ const uint8 N900_CHARGER_I2C_DEVICE = 0x55;
+ const uint8 N900_CHARGER_READ_CAPACITY = 0x0b;
+
+ public errordomain I2C_ERROR
+ {
+ SELECT_SLAVE_DEVICE,
+ READ_FROM_DEVICE,
+ WRITE_TO_DEVICE
+ }
+
+ /**
+ * Implementation of org.freesmartphone.Device.PowerSupply for the Nokia N900 device
+ **/
+ class N900 : FreeSmartphone.Device.PowerSupply,
+ FreeSmartphone.Info,
+ FsoFramework.AbstractObject
+ {
+ FsoFramework.Subsystem subsystem;
+
+ private string sysfsnode;
+ private uint8 charging_mode = 0x08;
+
+ // internal (accessible for aggregate power supply)
+ internal string name;
+ internal string typ;
+ internal FreeSmartphone.Device.PowerStatus status = FreeSmartphone.Device.PowerStatus.UNKNOWN;
+ internal bool present;
+ internal int fd = -1;
+
+ internal int capacity = -1;
+
+ public N900( FsoFramework.Subsystem subsystem, string sysfsnode )
+ {
+ this.subsystem = subsystem;
+ this.sysfsnode = sysfsnode;
+
+ fd = Posix.open( N900_CHARGER_I2C_FILE, Posix.O_RDWR );
+ if ( fd == -1 )
+ {
+ logger.warning( @"Can't open $N900_CHARGER_I2C_FILE: $(strerror(errno)). Powersupply will not available." );
+ return;
+ }
+
+ FsoFramework.BaseKObjectNotifier.addMatch( "change", "power_supply", onPowerSupplyChangeNotification );
+
+ Idle.add( onIdle );
+
+ //subsystem.registerServiceName( FsoFramework.Device.ServiceDBusName );
+ //subsystem.registerServiceObjectWithPrefix( FsoFramework.Device.ServiceDBusName, FsoFramework.Device.PowerSupplyServicePath, this );
+
+ logger.info( "Created" );
+ }
+
+ public override string repr()
+ {
+ return @"<$sysfsnode>";
+ }
+
+ private void pushMaskedByteToI2C( int file, uint8 mask, uint8 device, uint8 command, uint8 value ) throws I2C_ERROR
+ {
+ if ( Posix.ioctl( fd, Linux.I2C.SLAVE, device ) == -1)
+ {
+ throw new I2C_ERROR.SELECT_SLAVE_DEVICE( "Could not select slave device 0x%02X (%s)".printf( device, strerror(errno) ) );
+ }
+ int32 result = Linux.I2C.SMBUS.write_byte_data_masked( file, mask, command, value );
+ if ( result == -1 )
+ {
+ throw new I2C_ERROR.WRITE_TO_DEVICE( "Could not write at 0x%02X:0x%02X (%s)".printf( device, command, strerror(errno) ) );
+ }
+ }
+
+ private void pushByteToI2C( int file, uint8 device, uint8 command, uint8 value ) throws I2C_ERROR
+ {
+ if ( Posix.ioctl( fd, Linux.I2C.SLAVE, device ) == -1)
+ {
+ throw new I2C_ERROR.SELECT_SLAVE_DEVICE( "Could not select i2c slave device 0x%02X (%s)".printf( device, strerror(errno) ) );
+ }
+ int32 result = Linux.I2C.SMBUS.write_byte_data( file, command, value );
+ if ( result == -1 )
+ {
+ throw new I2C_ERROR.WRITE_TO_DEVICE( "Could not write at 0x%02X:0x%02X (%s)".printf( device, command, strerror(errno) ) );
+ }
+ }
+
+ private uint8 pullByteFromI2C( int file, uint8 device, uint8 command ) throws I2C_ERROR
+ {
+ if ( Posix.ioctl( fd, Linux.I2C.SLAVE, device ) == -1)
+ {
+ throw new I2C_ERROR.SELECT_SLAVE_DEVICE( "Could not select i2c slave device 0x%02X (%s)".printf( device, strerror(errno) ) );
+ }
+ int32 result = Linux.I2C.SMBUS.read_byte_data( file, command );
+ if ( result == -1 )
+ {
+ throw new I2C_ERROR.READ_FROM_DEVICE( "Could not read at 0x%02X:0x%02X (%s)".printf( device, command, strerror(errno) ) );
+ }
+ return (uint8) result & 0xff;
+ }
+
+ private bool onTimeout()
+ {
+ try
+ {
+ var status = pullByteFromI2C( fd, 0x6b, 0x00 );
+ logger.info( "Triggering charger while status is 0x%02X".printf( status ) );
+ pushByteToI2C( fd, 0x6b, 0x00, 0x80 );
+ }
+ catch ( Error e )
+ {
+ logger.error( @"Error: $(e.message), abandoning charging" );
+ return false;
+ }
+ return true;
+
+ /*
+ logger.debug( "Reading capacity from i2c..." );
+
+ var ok = Posix.ioctl( fd, Linux.I2C.SLAVE, N900_CHARGER_I2C_DEVICE );
+ if ( ok < 0 )
+ {
+ logger.warning( @"Can't change I2C SLAVE: $(strerror(errno))." );
+ return true;
+ }
+
+ var res = Linux.I2C.SMBUS.read_byte_data( fd, N900_CHARGER_READ_CAPACITY );
+ if ( res < 0 )
+ {
+ logger.warning( @"Can't i2c read_byte_data: $(strerror(errno))." );
+ return true; // mainloop: don't call us again
+ }
+ logger.debug( @"i2c reports capacity as $(res)" );
+ capacity = res;
+ */
+ return true; // mainloop: call us again
+ }
+
+ public void onPowerSupplyChangeNotification( HashTable<string,string> properties )
+ {
+ var name = properties.lookup( "POWER_SUPPLY_NAME" );
+ if ( name != "isp1704" )
+ {
+ /* we ignore it since there is also a battery gauge(bq27200-0) */
+ return;
+ }
+ string current_max = properties.lookup( "POWER_SUPPLY_CURRENT_MAX" );
+
+ switch ( current_max )
+ {
+ case "1800":
+ charging_mode = 0xc8;
+ break;
+ case "800":
+ charging_mode = 0x88;
+ break;
+ case "500":
+ charging_mode = 0x48;
+ break;
+ case "100":
+ default:
+ /* default to 100mA */
+ charging_mode = 0x08;
+ break;
+ }
+ logger.info(@"charging mode $(current_max) -> $(charging_mode)" );
+ Idle.add( onIdle );
+ }
+
+ public bool onIdle()
+ {
+ logger.info( "Disabling charger for configuration" );
+
+ try
+ {
+ //i2cset -y 2 0x6b 0x01 0xcc # No limit, 3.4V weak threshold, enable term, charger disable
+ pushByteToI2C( fd, 0x6b, 0x01, 0xcc );
+
+ /*
+ # Register 0x04
+ # 8: reset
+ # 4: 27.2mV # charge current
+ # 2: 13.6mV
+ # 1: 6.8mV
+ # 8: N/A
+ # 4: 13.6mV # termination current
+ # 2: 6.8mV
+ # 1: 3.4mV
+ # 7-1250 6-1150 5-1050 4-950 3-850 2-750 1-650 0-550
+ # 7-400 6-350 5-300 4-250 3-200 2-150 1-100 0-50
+ i2cset -y -m 0xFF 2 0x6b 0x04 0x50;
+ */
+ pushMaskedByteToI2C( fd, 0xff, 0x6b, 0x04, 0x50 );
+
+ /*
+ # Register 0x02
+ # 8: .640 V
+ # 4: .320 V
+ # 2: .160 V
+ # 1: .080
+ # 8: .040
+ # 4: .020 (+ 3.5)
+ # 2: otg pin active at high (default 1)
+ # 1: enable otg pin
+ i2cset -y -m 0xfc 2 0x6b 0x02 0x8c;
+ # 4.2 = 3.5 + .640 + .040 + .02 = 8c
+ # 4.16 = 3.5 + .640V + .020 = 84
+ # 4.1 = 3.5 + .320 + .160 + .08 + .04 = 78
+ # 4.0 = 3.5 + .320 + .160 + .02 = 64
+ # 3.9 = 3.5 + .320 + .080 = 50
+ */
+ pushMaskedByteToI2C( fd, 0xfc, 0x6b, 0x02, 0x8c );
+
+ /*
+ # Register 0x1
+ # 8: 00 = 100, 01 = 500, 10 = 800mA
+ # 4: 11 = no limit
+ # 2: 200mV weak threshold default 1
+ # 1: 100mV weak treshold defsult 1 (3.4 - 3.7)
+ # 8: enable termination
+ # 4: charger disable
+ # 2: high imp mode
+ # 1: boost
+ i2cset -y 2 0x6b 0x01 0xc8;
+ */
+ pushByteToI2C( fd, 0x6b, 0x01, charging_mode);
+
+ /*
+ # Register 0x00
+ # 8: Read: OTG Pin Status
+ # Write: Timer Reset
+ # 4: Enable Stat Pin
+ # 2: Stat : 00 Ready 01 In Progress
+ # 1: : 10 Done 11 Fault
+ # 8: Boost Mode
+ # 4: Fault: 000 Normal 001 VBUS OVP 010 Sleep Mode
+ # 2: 011 Poor input or Vbus < UVLO
+ # 1: 100 Battery OVP 101 Thermal Shutdown
+ # 110 Timer Fault 111 NA
+ i2cset -y 2 0x6b 0x00 0x00;
+ */
+ pushByteToI2C( fd, 0x6b, 0x00, 0x00 );
+
+ logger.info( "Charger programmed... sleeping 1 second" );
+ }
+ catch ( Error e )
+ {
+ logger.error( @"Error: $(e.message), aborting" );
+ return false;
+ }
+
+ Timeout.add_seconds( 1, () => {
+ onTimeout();
+ return false;
+ } );
+
+ Timeout.add_seconds( 15, onTimeout );
+
+ return false; // mainloop: don't call again
+ }
+
+ public bool isBattery()
+ {
+ return typ == "battery";
+ }
+
+ public bool isPresent()
+ {
+ /*
+ var node = isBattery() ? "%s/present" : "%s/online";
+ var value = FsoFramework.FileHandling.read( node.printf( sysfsnode ) );
+ return ( value != null && value == "1" );
+ */
+ return true;
+ }
+
+ public int getCapacity()
+ {
+ return capacity;
+ }
+
+ //
+ // FreeSmartphone.Info (DBUS API)
+ //
+ public async HashTable<string,Value?> get_info() throws DBusError, IOError
+ {
+ var res = new HashTable<string,Value?>( str_hash, str_equal );
+ /*
+ res.insert( "name", name );
+
+ var dir = Dir.open( sysfsnode );
+ var entry = dir.read_name();
+ while ( entry != null )
+ {
+ if ( entry != "uevent" )
+ {
+ var filename = Path.build_filename( sysfsnode, entry );
+ var contents = FsoFramework.FileHandling.read( filename );
+ if ( contents != "" )
+ {
+ res.insert( entry, contents );
+ }
+ }
+ entry = dir.read_name();
+ }
+ */
+ return res;
+ }
+
+ //
+ // FreeSmartphone.Device.PowerStatus (DBUS API)
+ //
+ public async FreeSmartphone.Device.PowerStatus get_power_status() throws DBusError, IOError
+ {
+ return status;
+ }
+
+ public async int get_capacity() throws DBusError, IOError
+ {
+ return getCapacity();
+ }
+ }
+} /* namespace */
+
+// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/n900_quirks/proximity.vala b/fsodeviced/src/plugins/n900_quirks/proximity.vala
new file mode 100644
index 00000000..bd65341f
--- /dev/null
+++ b/fsodeviced/src/plugins/n900_quirks/proximity.vala
@@ -0,0 +1,175 @@
+/*
+ * Copyright (C) 2009-2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
+ * 2010 Sebastian Krzyszkowiak <seba.dos1@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+
+ * This library 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
+ * Lesser General Public License for more details.
+
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+using GLib;
+
+namespace Proximity
+{
+ class N900 : FreeSmartphone.Device.Proximity,
+ FreeSmartphone.Device.PowerControl,
+ FsoFramework.AbstractObject
+ {
+ FsoFramework.Subsystem subsystem;
+
+ private string node;
+ private string powernode;
+
+ private int lastvalue;
+ private int lasttimestamp;
+
+ public N900( FsoFramework.Subsystem subsystem, string node )
+ {
+ this.subsystem = subsystem;
+ this.node = node;
+ this.lastvalue = -1;
+ this.lasttimestamp = 0;
+
+ if ( !FsoFramework.FileHandling.isPresent( this.node ) )
+ {
+ logger.error( @"Sysfs class is damaged, missing $(this.node); skipping." );
+ return;
+ }
+
+ this.powernode = GLib.Path.build_filename( this.node, "disable" );
+ this.node = GLib.Path.build_filename( this.node, "state" );
+
+ logger.debug( @"Trying to read from $(this.node)..." );
+
+ subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.Proximity>( FsoFramework.Device.ServiceDBusName, FsoFramework.Device.ProximityServicePath, this );
+
+ var channel = new IOChannel.file( this.node, "r" );
+ string value = "";
+ size_t c = 0;
+ channel.read_to_end(out value, out c);
+ channel.seek_position(0, SeekType.SET);
+
+ this.lastvalue = (value.strip() == "closed") ? 100 : 0;
+ this.lasttimestamp = (int) TimeVal().tv_sec;
+
+ this.set_power( false );
+
+ channel.add_watch( IOCondition.IN | IOCondition.PRI | IOCondition.ERR, onInputEvent );
+
+ logger.info( "Created" );
+
+ }
+
+ public override string repr()
+ {
+ return @"<$node>";
+ }
+
+ public bool onInputEvent( IOChannel source, IOCondition condition )
+ {
+ if ( ( ( condition & IOCondition.IN ) == IOCondition.IN ) || ( ( condition & IOCondition.PRI ) == IOCondition.PRI ) ) {
+ string value = "";
+ size_t c = 0;
+ source.read_line (out value, out c, null);
+ logger.debug( @"got data from sysfs node: $value" );
+ // send dbus signal
+ this.lastvalue = (value.strip() == "closed") ? 100 : 0;
+ this.lasttimestamp = (int) TimeVal().tv_sec;
+ this.proximity( this.lastvalue );
+
+ source.seek_position(0, SeekType.SET);
+ return true;
+ }
+ else {
+ logger.error("onInputEvent error");
+ return false;
+ }
+ }
+
+ //
+ // FreeSmartphone.Device.Proximity (DBUS API)
+ //
+ public async void get_proximity( out int proximity, out int timestamp ) throws FreeSmartphone.Error, DBusError, IOError
+ {
+ try {
+ var value = FsoFramework.FileHandling.read( node ) ?? "";
+ this.lastvalue = (value.strip() == "closed") ? 100 : 0;
+ this.lasttimestamp = (int) TimeVal().tv_sec;
+ }
+ finally {
+ proximity = this.lastvalue;
+ timestamp = this.lasttimestamp;
+ }
+ }
+
+ //
+ // FreeSmartphone.Device.PowerControl (DBUS API)
+ //
+ public async bool get_power() throws DBusError, IOError
+ {
+ var contents = FsoFramework.FileHandling.read( powernode ) ?? "";
+ return contents.strip() == "0";
+ }
+
+ public async void set_power( bool on ) throws DBusError, IOError
+ {
+ var contents = on ? "0" : "1";
+ FsoFramework.FileHandling.write( contents, powernode );
+ }
+
+ }
+
+ /**
+ * Implementation of org.freesmartphone.Resource for the Proximity Resource
+ **/
+ class ProximityResource : FsoFramework.AbstractDBusResource
+ {
+ internal bool on;
+ private Proximity.N900 instance;
+
+ public ProximityResource( FsoFramework.Subsystem subsystem, Proximity.N900 instance )
+ {
+ base( "Proximity", subsystem );
+ this.instance = instance;
+ }
+
+ public override async void enableResource()
+ {
+ if (on)
+ return;
+ assert( logger.debug( "Enabling..." ) );
+ instance.set_power( true );
+ on = true;
+ }
+
+ public override async void disableResource()
+ {
+ if (!on)
+ return;
+ assert( logger.debug( "Disabling..." ) );
+ instance.set_power( false );
+ on = false;
+ }
+
+ public override async void suspendResource()
+ {
+ }
+
+ public override async void resumeResource()
+ {
+ }
+ }
+} /* namespace */
+
+// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/powersupply_n900/Makefile.am b/fsodeviced/src/plugins/powersupply_n900/Makefile.am
deleted file mode 100644
index 3e2ca1c4..00000000
--- a/fsodeviced/src/plugins/powersupply_n900/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-include $(top_srcdir)/Makefile.decl
-NULL =
-
-AM_CFLAGS = \
- -DG_LOG_DOMAIN=\"fsodevice.powersupply_n900\" \
- $(NULL)
-AM_VALAFLAGS =
-
-modlibexecdir = $(libdir)/cornucopia/modules/fsodevice
-modlibexec_LTLIBRARIES = powersupply_n900.la
-powersupply_n900_la_SOURCES = plugin.vala
-powersupply_n900_la_VALAFLAGS = \
- --basedir $(top_srcdir) \
- --vapidir $(top_srcdir)/vapi \
- --vapidir $(top_srcdir)/fsoframework \
- --pkg glib-2.0 \
- --pkg linux \
- --pkg fso-glib-1.0 \
- --pkg fsoframework-2.0 \
- $(DEBUG_VALAFLAGS) \
- $(NULL)
-powersupply_n900_la_CFLAGS = \
- -I$(top_srcdir) \
- -I$(top_srcdir)/src/3rdparty \
- $(FSO_CFLAGS) \
- $(DEBUG_CFLAGS) \
- $(NULL)
-powersupply_n900_la_LIBADD = \
- $(FSO_LIBS) \
- $(DBUS_LIBS) \
- $(top_builddir)/src/lib/libfsodevice.la \
- $(NULL)
-powersupply_n900_la_LDFLAGS = -no-undefined -module -avoid-version
-# powersupply_n900_la_LIBTOOLFLAGS = --tag=disable-static
-
-CLEANFILES =
-MAINTAINERCLEANFILES = \
- Makefile.in \
- $(NULL)
diff --git a/fsodeviced/src/plugins/powersupply_n900/plugin.vala b/fsodeviced/src/plugins/powersupply_n900/plugin.vala
deleted file mode 100644
index 30b45680..00000000
--- a/fsodeviced/src/plugins/powersupply_n900/plugin.vala
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright (C) 2010-2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-
-namespace PowerSupply
-{
-
-const string N900_CHARGER_I2C_FILE = "/dev/i2c-2";
-
-const uint8 N900_CHARGER_I2C_DEVICE = 0x55;
-const uint8 N900_CHARGER_READ_CAPACITY = 0x0b;
-
-public errordomain I2C_ERROR
-{
- SELECT_SLAVE_DEVICE,
- READ_FROM_DEVICE,
- WRITE_TO_DEVICE
-}
-
-/**
- * Implementation of org.freesmartphone.Device.PowerSupply for the Nokia N900 device
- **/
-class N900 : FreeSmartphone.Device.PowerSupply,
- FreeSmartphone.Info,
- FsoFramework.AbstractObject
-{
- FsoFramework.Subsystem subsystem;
-
- private string sysfsnode;
- private uint8 charging_mode = 0x08;
-
- // internal (accessible for aggregate power supply)
- internal string name;
- internal string typ;
- internal FreeSmartphone.Device.PowerStatus status = FreeSmartphone.Device.PowerStatus.UNKNOWN;
- internal bool present;
- internal int fd = -1;
-
- internal int capacity = -1;
-
- public N900( FsoFramework.Subsystem subsystem, string sysfsnode )
- {
- this.subsystem = subsystem;
- this.sysfsnode = sysfsnode;
-
- fd = Posix.open( N900_CHARGER_I2C_FILE, Posix.O_RDWR );
- if ( fd == -1 )
- {
- logger.warning( @"Can't open $N900_CHARGER_I2C_FILE: $(strerror(errno)). Powersupply will not available." );
- return;
- }
-
- FsoFramework.BaseKObjectNotifier.addMatch( "change", "power_supply", onPowerSupplyChangeNotification );
-
- Idle.add( onIdle );
-
- //subsystem.registerServiceName( FsoFramework.Device.ServiceDBusName );
- //subsystem.registerServiceObjectWithPrefix( FsoFramework.Device.ServiceDBusName, FsoFramework.Device.PowerSupplyServicePath, this );
-
- logger.info( "Created" );
- }
-
- public override string repr()
- {
- return @"<$sysfsnode>";
- }
-
- private void pushMaskedByteToI2C( int file, uint8 mask, uint8 device, uint8 command, uint8 value ) throws I2C_ERROR
- {
- if ( Posix.ioctl( fd, Linux.I2C.SLAVE, device ) == -1)
- {
- throw new I2C_ERROR.SELECT_SLAVE_DEVICE( "Could not select slave device 0x%02X (%s)".printf( device, strerror(errno) ) );
- }
- int32 result = Linux.I2C.SMBUS.write_byte_data_masked( file, mask, command, value );
- if ( result == -1 )
- {
- throw new I2C_ERROR.WRITE_TO_DEVICE( "Could not write at 0x%02X:0x%02X (%s)".printf( device, command, strerror(errno) ) );
- }
- }
-
- private void pushByteToI2C( int file, uint8 device, uint8 command, uint8 value ) throws I2C_ERROR
- {
- if ( Posix.ioctl( fd, Linux.I2C.SLAVE, device ) == -1)
- {
- throw new I2C_ERROR.SELECT_SLAVE_DEVICE( "Could not select i2c slave device 0x%02X (%s)".printf( device, strerror(errno) ) );
- }
- int32 result = Linux.I2C.SMBUS.write_byte_data( file, command, value );
- if ( result == -1 )
- {
- throw new I2C_ERROR.WRITE_TO_DEVICE( "Could not write at 0x%02X:0x%02X (%s)".printf( device, command, strerror(errno) ) );
- }
- }
-
- private uint8 pullByteFromI2C( int file, uint8 device, uint8 command ) throws I2C_ERROR
- {
- if ( Posix.ioctl( fd, Linux.I2C.SLAVE, device ) == -1)
- {
- throw new I2C_ERROR.SELECT_SLAVE_DEVICE( "Could not select i2c slave device 0x%02X (%s)".printf( device, strerror(errno) ) );
- }
- int32 result = Linux.I2C.SMBUS.read_byte_data( file, command );
- if ( result == -1 )
- {
- throw new I2C_ERROR.READ_FROM_DEVICE( "Could not read at 0x%02X:0x%02X (%s)".printf( device, command, strerror(errno) ) );
- }
- return (uint8) result & 0xff;
- }
-
- private bool onTimeout()
- {
- try
- {
- var status = pullByteFromI2C( fd, 0x6b, 0x00 );
- logger.info( "Triggering charger while status is 0x%02X".printf( status ) );
- pushByteToI2C( fd, 0x6b, 0x00, 0x80 );
- }
- catch ( Error e )
- {
- logger.error( @"Error: $(e.message), abandoning charging" );
- return false;
- }
- return true;
-
- /*
- logger.debug( "Reading capacity from i2c..." );
-
- var ok = Posix.ioctl( fd, Linux.I2C.SLAVE, N900_CHARGER_I2C_DEVICE );
- if ( ok < 0 )
- {
- logger.warning( @"Can't change I2C SLAVE: $(strerror(errno))." );
- return true;
- }
-
- var res = Linux.I2C.SMBUS.read_byte_data( fd, N900_CHARGER_READ_CAPACITY );
- if ( res < 0 )
- {
- logger.warning( @"Can't i2c read_byte_data: $(strerror(errno))." );
- return true; // mainloop: don't call us again
- }
- logger.debug( @"i2c reports capacity as $(res)" );
- capacity = res;
- */
- return true; // mainloop: call us again
- }
-
- public void onPowerSupplyChangeNotification( HashTable<string,string> properties )
- {
- var name = properties.lookup( "POWER_SUPPLY_NAME" );
- if ( name != "isp1704" )
- {
- /* we ignore it since there is also a battery gauge(bq27200-0) */
- return;
- }
- string current_max = properties.lookup( "POWER_SUPPLY_CURRENT_MAX" );
-
- switch ( current_max )
- {
- case "1800":
- charging_mode = 0xc8;
- break;
- case "800":
- charging_mode = 0x88;
- break;
- case "500":
- charging_mode = 0x48;
- break;
- case "100":
- default:
- /* default to 100mA */
- charging_mode = 0x08;
- break;
- }
- logger.info(@"charging mode $(current_max) -> $(charging_mode)" );
- Idle.add( onIdle );
- }
-
- public bool onIdle()
- {
- logger.info( "Disabling charger for configuration" );
-
- try
- {
- //i2cset -y 2 0x6b 0x01 0xcc # No limit, 3.4V weak threshold, enable term, charger disable
- pushByteToI2C( fd, 0x6b, 0x01, 0xcc );
-
- /*
- # Register 0x04
- # 8: reset
- # 4: 27.2mV # charge current
- # 2: 13.6mV
- # 1: 6.8mV
- # 8: N/A
- # 4: 13.6mV # termination current
- # 2: 6.8mV
- # 1: 3.4mV
- # 7-1250 6-1150 5-1050 4-950 3-850 2-750 1-650 0-550
- # 7-400 6-350 5-300 4-250 3-200 2-150 1-100 0-50
- i2cset -y -m 0xFF 2 0x6b 0x04 0x50;
- */
- pushMaskedByteToI2C( fd, 0xff, 0x6b, 0x04, 0x50 );
-
- /*
- # Register 0x02
- # 8: .640 V
- # 4: .320 V
- # 2: .160 V
- # 1: .080
- # 8: .040
- # 4: .020 (+ 3.5)
- # 2: otg pin active at high (default 1)
- # 1: enable otg pin
- i2cset -y -m 0xfc 2 0x6b 0x02 0x8c;
- # 4.2 = 3.5 + .640 + .040 + .02 = 8c
- # 4.16 = 3.5 + .640V + .020 = 84
- # 4.1 = 3.5 + .320 + .160 + .08 + .04 = 78
- # 4.0 = 3.5 + .320 + .160 + .02 = 64
- # 3.9 = 3.5 + .320 + .080 = 50
- */
- pushMaskedByteToI2C( fd, 0xfc, 0x6b, 0x02, 0x8c );
-
- /*
- # Register 0x1
- # 8: 00 = 100, 01 = 500, 10 = 800mA
- # 4: 11 = no limit
- # 2: 200mV weak threshold default 1
- # 1: 100mV weak treshold defsult 1 (3.4 - 3.7)
- # 8: enable termination
- # 4: charger disable
- # 2: high imp mode
- # 1: boost
- i2cset -y 2 0x6b 0x01 0xc8;
- */
- pushByteToI2C( fd, 0x6b, 0x01, charging_mode);
-
- /*
- # Register 0x00
- # 8: Read: OTG Pin Status
- # Write: Timer Reset
- # 4: Enable Stat Pin
- # 2: Stat : 00 Ready 01 In Progress
- # 1: : 10 Done 11 Fault
- # 8: Boost Mode
- # 4: Fault: 000 Normal 001 VBUS OVP 010 Sleep Mode
- # 2: 011 Poor input or Vbus < UVLO
- # 1: 100 Battery OVP 101 Thermal Shutdown
- # 110 Timer Fault 111 NA
- i2cset -y 2 0x6b 0x00 0x00;
- */
- pushByteToI2C( fd, 0x6b, 0x00, 0x00 );
-
- logger.info( "Charger programmed... sleeping 1 second" );
- }
- catch ( Error e )
- {
- logger.error( @"Error: $(e.message), aborting" );
- return false;
- }
-
- Timeout.add_seconds( 1, () => {
- onTimeout();
- return false;
- } );
-
- Timeout.add_seconds( 15, onTimeout );
-
- return false; // mainloop: don't call again
- }
-
- public bool isBattery()
- {
- return typ == "battery";
- }
-
- public bool isPresent()
- {
- /*
- var node = isBattery() ? "%s/present" : "%s/online";
- var value = FsoFramework.FileHandling.read( node.printf( sysfsnode ) );
- return ( value != null && value == "1" );
- */
- return true;
- }
-
- public int getCapacity()
- {
- return capacity;
- }
-
- //
- // FreeSmartphone.Info (DBUS API)
- //
- public async HashTable<string,Value?> get_info() throws DBusError, IOError
- {
- var res = new HashTable<string,Value?>( str_hash, str_equal );
- /*
- res.insert( "name", name );
-
- var dir = Dir.open( sysfsnode );
- var entry = dir.read_name();
- while ( entry != null )
- {
- if ( entry != "uevent" )
- {
- var filename = Path.build_filename( sysfsnode, entry );
- var contents = FsoFramework.FileHandling.read( filename );
- if ( contents != "" )
- {
- res.insert( entry, contents );
- }
- }
- entry = dir.read_name();
- }
- */
- return res;
- }
-
- //
- // FreeSmartphone.Device.PowerStatus (DBUS API)
- //
- public async FreeSmartphone.Device.PowerStatus get_power_status() throws DBusError, IOError
- {
- return status;
- }
-
- public async int get_capacity() throws DBusError, IOError
- {
- return getCapacity();
- }
-}
-
-} /* namespace */
-
-internal static string sysfs_root;
-internal static string sys_devices_platform_msusb_hdrc;
-internal PowerSupply.N900 instance;
-
-/**
- * This function gets called on plugin initialization time.
- * @return the name of your plugin here
- * @note that it needs to be a name in the format <subsystem>.<plugin>
- * else your module will be unloaded immediately.
- **/
-public static string fso_factory_function( FsoFramework.Subsystem subsystem ) throws Error
-{
- // grab sysfs paths
- var config = FsoFramework.theConfig;
- sysfs_root = config.stringValue( "cornucopia", "sysfs_root", "/sys" );
- sys_devices_platform_msusb_hdrc = "%s/devices/platform/musb_hdrc".printf( sysfs_root );
-
- instance = new PowerSupply.N900( subsystem, sys_devices_platform_msusb_hdrc );
- return "fsodevice.powersupply_n900";
-}
-
-[ModuleInit]
-public static void fso_register_function( TypeModule module )
-{
- FsoFramework.theLogger.debug( "fsodevice.powersupply_n900 fso_register_function()" );
-}
-
-/**
- * This function gets called on plugin load time.
- * @return false, if the plugin operating conditions are present.
- * @note Some versions of glib contain a bug that leads to a SIGSEGV
- * in g_module_open, if you return true here.
- **/
-/*public static bool g_module_check_init( void* m )
-{
- var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS );
- return (!ok);
-}
-*/
-
-// vim:ts=4:sw=4:expandtab
diff --git a/fsodeviced/src/plugins/proximity_n900/Makefile.am b/fsodeviced/src/plugins/proximity_n900/Makefile.am
deleted file mode 100644
index 26147b3c..00000000
--- a/fsodeviced/src/plugins/proximity_n900/Makefile.am
+++ /dev/null
@@ -1,36 +0,0 @@
-include $(top_srcdir)/Makefile.decl
-NULL =
-
-AM_CFLAGS = \
- -DG_LOG_DOMAIN=\"fsodevice.proximity_n900\" \
- $(NULL)
-AM_VALAFLAGS =
-
-modlibexecdir = $(libdir)/cornucopia/modules/fsodevice
-modlibexec_LTLIBRARIES = proximity_n900.la
-proximity_n900_la_SOURCES = plugin.vala
-proximity_n900_la_VALAFLAGS = \
- --basedir $(top_srcdir) \
- --vapidir $(top_srcdir)/fsoframework \
- --pkg glib-2.0 \
- --pkg fso-glib-1.0 \
- --pkg fsoresource-2.0 \
- --pkg fsoframework-2.0 \
- $(DEBUG_VALAFLAGS) \
- $(NULL)
-proximity_n900_la_CFLAGS = \
- -I$(top_srcdir) \
- $(FSO_CFLAGS) \
- $(DEBUG_CFLAGS) \
- $(NULL)
-proximity_n900_la_LIBADD = \
- $(FSO_LIBS) \
- $(top_builddir)/src/lib/libfsodevice.la \
- $(NULL)
-proximity_n900_la_LDFLAGS = -no-undefined -module -avoid-version
-# proximity_n900_la_LIBTOOLFLAGS = --tag=disable-static
-
-CLEANFILES =
-MAINTAINERCLEANFILES = \
- Makefile.in \
- $(NULL)
diff --git a/fsodeviced/src/plugins/proximity_n900/plugin.vala b/fsodeviced/src/plugins/proximity_n900/plugin.vala
deleted file mode 100644
index 7f52a259..00000000
--- a/fsodeviced/src/plugins/proximity_n900/plugin.vala
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2009-2011 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- * 2010 Sebastian Krzyszkowiak <seba.dos1@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-
-namespace Proximity
-{
-
-class N900 : FreeSmartphone.Device.Proximity,
- FreeSmartphone.Device.PowerControl,
- FsoFramework.AbstractObject
-{
- FsoFramework.Subsystem subsystem;
-
- private string node;
- private string powernode;
-
- private int lastvalue;
- private int lasttimestamp;
-
- public N900( FsoFramework.Subsystem subsystem, string node )
- {
- this.subsystem = subsystem;
- this.node = node;
- this.lastvalue = -1;
- this.lasttimestamp = 0;
-
- if ( !FsoFramework.FileHandling.isPresent( this.node ) )
- {
- logger.error( @"Sysfs class is damaged, missing $(this.node); skipping." );
- return;
- }
-
- this.powernode = GLib.Path.build_filename( this.node, "disable" );
- this.node = GLib.Path.build_filename( this.node, "state" );
-
- logger.debug( @"Trying to read from $(this.node)..." );
-
- subsystem.registerObjectForServiceWithPrefix<FreeSmartphone.Device.Proximity>( FsoFramework.Device.ServiceDBusName, FsoFramework.Device.ProximityServicePath, this );
-
- var channel = new IOChannel.file( this.node, "r" );
- string value = "";
- size_t c = 0;
- channel.read_to_end(out value, out c);
- channel.seek_position(0, SeekType.SET);
-
- this.lastvalue = (value.strip() == "closed") ? 100 : 0;
- this.lasttimestamp = (int) TimeVal().tv_sec;
-
- this.set_power( false );
-
- channel.add_watch( IOCondition.IN | IOCondition.PRI | IOCondition.ERR, onInputEvent );
-
- logger.info( "Created" );
-
- }
-
- public override string repr()
- {
- return @"<$node>";
- }
-
- public bool onInputEvent( IOChannel source, IOCondition condition )
- {
- if ( ( ( condition & IOCondition.IN ) == IOCondition.IN ) || ( ( condition & IOCondition.PRI ) == IOCondition.PRI ) ) {
- string value = "";
- size_t c = 0;
- source.read_line (out value, out c, null);
- logger.debug( @"got data from sysfs node: $value" );
- // send dbus signal
- this.lastvalue = (value.strip() == "closed") ? 100 : 0;
- this.lasttimestamp = (int) TimeVal().tv_sec;
- this.proximity( this.lastvalue );
-
- source.seek_position(0, SeekType.SET);
- return true;
- }
- else {
- logger.error("onInputEvent error");
- return false;
- }
- }
-
- //
- // FreeSmartphone.Device.Proximity (DBUS API)
- //
- public async void get_proximity( out int proximity, out int timestamp ) throws FreeSmartphone.Error, DBusError, IOError
- {
- try {
- var value = FsoFramework.FileHandling.read( node ) ?? "";
- this.lastvalue = (value.strip() == "closed") ? 100 : 0;
- this.lasttimestamp = (int) TimeVal().tv_sec;
- }
- finally {
- proximity = this.lastvalue;
- timestamp = this.lasttimestamp;
- }
- }
-
- //
- // FreeSmartphone.Device.PowerControl (DBUS API)
- //
- public async bool get_power() throws DBusError, IOError
- {
- var contents = FsoFramework.FileHandling.read( powernode ) ?? "";
- return contents.strip() == "0";
- }
-
- public async void set_power( bool on ) throws DBusError, IOError
- {
- var contents = on ? "0" : "1";
- FsoFramework.FileHandling.write( contents, powernode );
- }
-
-}
-
-/**
- * Implementation of org.freesmartphone.Resource for the Proximity Resource
- **/
-class ProximityResource : FsoFramework.AbstractDBusResource
-{
- internal bool on;
-
- public ProximityResource( FsoFramework.Subsystem subsystem )
- {
- base( "Proximity", subsystem );
- }
-
- public override async void enableResource()
- {
- if (on)
- return;
- assert( logger.debug( "Enabling..." ) );
- instance.set_power( true );
- on = true;
- }
-
- public override async void disableResource()
- {
- if (!on)
- return;
- assert( logger.debug( "Disabling..." ) );
- instance.set_power( false );
- on = false;
- }
-
- public override async void suspendResource()
- {
- }
-
- public override async void resumeResource()
- {
- }
-}
-
-} /* namespace */
-
-static string sysfs_root;
-Proximity.N900 instance;
-Proximity.ProximityResource resource;
-
-/**
- * This function gets called on plugin initialization time.
- * @return the name of your plugin here
- * @note that it needs to be a name in the format <subsystem>.<plugin>
- * else your module will be unloaded immediately.
- **/
-public static string fso_factory_function( FsoFramework.Subsystem subsystem ) throws Error
-{
- // grab sysfs paths
- var config = FsoFramework.theConfig;
- sysfs_root = config.stringValue( "cornucopia", "sysfs_root", "/sys" );
- var dirname = GLib.Path.build_filename( sysfs_root, "devices", "platform", "gpio-switch", "proximity" );
-
- if ( FsoFramework.FileHandling.isPresent( dirname ) )
- {
- instance = new Proximity.N900( subsystem, dirname );
- resource = new Proximity.ProximityResource( subsystem );
- }
- else
- {
- FsoFramework.theLogger.error( "No proximity device found; proximity object will not be available" );
- }
- return "fsodevice.proximity_n900";
-}
-
-[ModuleInit]
-public static void fso_register_function( TypeModule module )
-{
- FsoFramework.theLogger.debug( "fsodevice.proximity_n900 fso_register_function()" );
-}
-
-/**
- * This function gets called on plugin load time.
- * @return false, if the plugin operating conditions are present.
- * @note Some versions of glib contain a bug that leads to a SIGSEGV
- * in g_module_open, if you return true here.
- **/
-/*public static bool g_module_check_init( void* m )
-{
- var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS );
- return (!ok);
-}
-*/
-
-// vim:ts=4:sw=4:expandtab