hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Wed Mar 12 11:09:39 PDT 2008


 fdi/policy/10osvendor/10-tabletPCs.fdi |   25 ++++++++++
 fdi/policy/10osvendor/Makefile.am      |    9 ++-
 hald/linux/device.c                    |   39 ++++++++++++++++
 tools/Makefile.am                      |    4 +
 tools/hal-system-setserial.c           |   77 +++++++++++++++++++++++++++++++++
 5 files changed, 150 insertions(+), 4 deletions(-)

New commits:
commit ea8441f5b0fd783d5803c5c7a0a1c95e72bf1a01
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Wed Mar 12 19:08:53 2008 +0100

    added support for Tablet PCs
    
    Added support for Tablet PCs with these features:
     * identify Wacom and Finepoint Tablet PC devices and port/irq
     * set system.formfactor.subtype to 'tabletpc' this allow the desktop
       to handle special tasks for Tablet PCs as e.g. show OnScreen Keyboard
     * added setserial helper to setup /dev/ttyS* devices with sepcial
       parameter if needed
     * added fdi-file to call for special Tablet devices setserial with
       needed parameter where the kernel can't setup the device correct
    
    This patch is already included in the SUSE hal package since 08/2005.

diff --git a/fdi/policy/10osvendor/10-tabletPCs.fdi b/fdi/policy/10osvendor/10-tabletPCs.fdi
new file mode 100644
index 0000000..f1bddde
--- /dev/null
+++ b/fdi/policy/10osvendor/10-tabletPCs.fdi
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+
+<deviceinfo version="0.2">
+
+  <device>
+    <match key="info.capabilities" contains="input.tablet.tabletPC">
+      <!-- There is a report that we should use ttyS2 instead of ttyS0 -->
+      <match key="/org/freedesktop/Hal/devices/computer:system.hardware.product" contains="HP Compaq tc4200">
+	<merge key="input.device.set" type="string">/dev/ttyS2</merge>
+      </match>
+
+      <!-- to get the device up we need to set the baud_rate correct -->
+      <match key="pnp.id" contains="FPI2004">
+	<merge key="input.device.set" type="string">/dev/ttyS0</merge>
+	<merge key="pnp.serial.baud_base" type="int">38400</merge>
+      </match>
+    </match>
+
+    <!-- add addon if need special ttySx settings -->
+    <match key="input.device.set" exists="true">
+      <append key="info.callouts.add" type="strlist">hal-system-setserial</append>	
+    </match>
+  </device>
+
+</deviceinfo>
diff --git a/fdi/policy/10osvendor/Makefile.am b/fdi/policy/10osvendor/Makefile.am
index f9c7579..19f1825 100644
--- a/fdi/policy/10osvendor/Makefile.am
+++ b/fdi/policy/10osvendor/Makefile.am
@@ -3,14 +3,15 @@ fdidir = $(datadir)/hal/fdi/policy/10osvendor
 
 dist_fdi_DATA = 			\
 	10-input-policy.fdi		\
-	10-x11-input.fdi		\
+	10-dockstation.fdi		\
+	10-laptop-panel-mgmt-policy.fdi	\
 	10-power-mgmt-policy.fdi	\
 	10-rfkill-switch.fdi		\
-	10-laptop-panel-mgmt-policy.fdi	\
+	10-tabletPCs.fdi		\
+	10-x11-input.fdi		\
 	15-storage-luks.fdi		\
 	20-storage-methods.fdi		\
-	30-wol.fdi			\
-	10-dockstation.fdi
+	30-wol.fdi
 
 if BUILD_KEYMAPS
 dist_fdi_DATA += 10-keymap.fdi
diff --git a/hald/linux/device.c b/hald/linux/device.c
index c41edf3..d8dfbfd 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1912,11 +1912,32 @@ ide_compute_udi (HalDevice *d)
 }
 
 /*--------------------------------------------------------------------------------------------------------------*/
+static void
+pnp_set_serial_info (const gchar *sysfs_path, HalDevice *d) {
+
+	hal_util_set_int_elem_from_file (d, "pnp.serial.irq", sysfs_path, "resources", "irq", 0, 10, TRUE);
+
+	if (hal_util_set_string_elem_from_file (d, "pnp.serial.port", sysfs_path, "resources", "io", 0, TRUE)) {
+		const char* port;
+		const char* _port;
+		_port = hal_device_property_get_string (d, "pnp.serial.port");
+		if(_port == NULL)
+			return;
+
+		port = strtok((char*) _port, "-");
+		if(port == NULL)
+			return;
+
+		hal_device_property_set_string (d, "pnp.serial.port", port);
+	}
+}
+
 
 static HalDevice *
 pnp_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d;
+	HalDevice *computer;
 
 	d = hal_device_new ();
 	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
@@ -1932,11 +1953,29 @@ pnp_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 	hal_util_set_string_from_file (d, "pnp.id", sysfs_path, "id");
 	if (hal_device_has_property (d, "pnp.id")) {
 		gchar *pnp_description;
+		const char *pnp_id;
 		ids_find_pnp (hal_device_property_get_string (d, "pnp.id"), &pnp_description);
 		if (pnp_description != NULL) {
 			hal_device_property_set_string (d, "pnp.description", pnp_description);
 			hal_device_property_set_string (d, "info.product", pnp_description);
 		}
+		pnp_id = hal_device_property_get_string (d, "pnp.id");
+		if( !strncmp(pnp_id, "WACf00", 6) || !strcmp(pnp_id, "FUJ02e5") ||
+		    !strcmp(pnp_id, "FUJ02e6") || !strcmp(pnp_id, "FPI2004")) {
+			/* a internal serial tablet --> this should be a tablet pc */
+			hal_device_add_capability (d, "input");
+			hal_device_add_capability (d, "input.tablet");
+			hal_device_add_capability (d, "input.tablet.tabletPC");
+
+			if ((computer = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer")) != NULL ||
+			    (computer = hal_device_store_find (hald_get_tdl (), "/org/freedesktop/Hal/devices/computer")) != NULL) {
+
+				hal_device_property_set_string (computer, "system.formfactor", "laptop");
+				hal_device_property_set_string (computer, "system.formfactor.subtype", "tabletpc");
+				/* collect info about serial port and irq etc. */
+				pnp_set_serial_info (sysfs_path, d);
+			}
+		}
 	}
 
 	if (!hal_device_has_property (d, "info.product")) {
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 6d4db2e..cab521e 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -102,6 +102,7 @@ libexec_PROGRAMS =                          \
 	hal-storage-closetray	            \
 	hal-storage-cleanup-mountpoint      \
 	hal-storage-cleanup-all-mountpoints \
+	hal-system-setserial		    \
 	hal-system-power-pm-is-supported
 
 if HAVE_PMU
@@ -142,6 +143,9 @@ hal_storage_cleanup_mountpoint_LDADD = @GLIB_LIBS@ @POLKIT_LIBS@ @DBUS_LIBS@ $(t
 hal_storage_cleanup_all_mountpoints_SOURCES = hal-storage-cleanup-all-mountpoints.c hal-storage-shared.c hal-storage-shared.h
 hal_storage_cleanup_all_mountpoints_LDADD = @GLIB_LIBS@ @POLKIT_LIBS@ @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la $(top_builddir)/libhal-storage/libhal-storage.la
 
+hal_system_setserial_SOURCES = hal-system-setserial.c
+hal_system_setserial_LDADD = 
+
 if HAVE_PMU
 hal_system_power_pmu_SOURCES = hal-system-power-pmu.c
 hal_system_power_pmu_LDADD = @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la
diff --git a/tools/hal-system-setserial.c b/tools/hal-system-setserial.c
new file mode 100644
index 0000000..f38689e
--- /dev/null
+++ b/tools/hal-system-setserial.c
@@ -0,0 +1,77 @@
+/*
+ * Licensed under the GNU General Public License Version 2
+ *
+ * Copyright (C) 2005-2008 Danny Kukawka <danny.kukawka at web.de>
+ *
+ * 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 Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#define _GNU_SOURCE
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <syslog.h>
+
+#define MAX_CMD_LENGTH 256
+
+static int debug = 0;
+
+
+int main (int argc, const char *argv[])
+{
+	int ret_val = EXIT_FAILURE;
+    	char *udi = NULL;
+	char *irq = NULL;
+	char *port = NULL;
+	char *baud_base = NULL;
+	char *input_dev = NULL;
+	char cmd[MAX_CMD_LENGTH+1];
+	
+	if (getenv ("HALD_VERBOSE") != NULL )
+        	debug = 1;
+	if (debug)
+        	syslog (LOG_INFO, "hal-system-setserial started in debug mode." );
+
+	udi = getenv("UDI");
+	irq = getenv("HAL_PROP_PNP_SERIAL_IRQ");
+	port = getenv("HAL_PROP_PNP_SERIAL_PORT");
+	baud_base = getenv("HAL_PROP_PNP_SERIAL_BAUD_BASE");
+	input_dev = getenv("HAL_PROP_INPUT_DEVICE_SET");
+
+	if (udi == NULL || irq == NULL || port == NULL || input_dev == NULL) {
+		syslog (LOG_INFO, "Missing env variable, exit NOW." );
+		return ret_val;
+	}
+
+	if (baud_base != NULL)
+		snprintf( cmd, MAX_CMD_LENGTH, "/bin/setserial %s port %s irq %s baud_base %s autoconfig", input_dev, port, irq, baud_base);
+	else
+		snprintf( cmd, MAX_CMD_LENGTH, "/bin/setserial %s port %s irq %s autoconfig", input_dev, port, irq);
+
+	syslog (LOG_INFO, "Collected setserial options and called(%d): %s ", system(cmd), cmd);
+
+	ret_val = EXIT_SUCCESS;
+
+	return ret_val;
+}
+


More information about the hal-commit mailing list