[oe-commits] org.oe.dev libgsmd: experimental plugin infrastructure for magician and universal

pH5 commit openembedded-commits at lists.openembedded.org
Thu Apr 5 10:05:36 UTC 2007


libgsmd: experimental plugin infrastructure for magician and universal
- subject to change

Author: pH5 at openembedded.org
Branch: org.openembedded.dev
Revision: b180e055906b9a23bcd4980e8682b0a7de022179
ViewMTN: http://monotone.openembedded.org/revision.psp?id=b180e055906b9a23bcd4980e8682b0a7de022179
Files:
1
packages/gsm/files/interpreter-ready.patch
packages/gsm/files/magician/ldisc.patch
packages/gsm/files/magician/vendor-tihtc.patch
packages/gsm/files/htcuniversal
packages/gsm/files/htcuniversal/default
packages/gsm/files/numeric.patch
packages/gsm/files/plugin.patch
packages/gsm/files/magician/default
packages/gsm/libgsmd_svn.bb
Diffs:

#
# mt diff -rdfdda7c548b2b8c023a5e9015f79c6f450c91fa3 -rb180e055906b9a23bcd4980e8682b0a7de022179
#
# 
# 
# delete "packages/gsm/files/interpreter-ready.patch"
# 
# delete "packages/gsm/files/magician/ldisc.patch"
# 
# delete "packages/gsm/files/magician/vendor-tihtc.patch"
# 
# add_dir "packages/gsm/files/htcuniversal"
# 
# add_file "packages/gsm/files/htcuniversal/default"
#  content [ec5dd1432f454bf1f125b0ae7e8df2d0c09ce451]
# 
# add_file "packages/gsm/files/numeric.patch"
#  content [977aab49d5f8a96b98eb9900c325e8d95d323778]
# 
# add_file "packages/gsm/files/plugin.patch"
#  content [cdcc38e2e5945c3c6dbc3992863db070003f4208]
# 
# patch "packages/gsm/files/magician/default"
#  from [396587576d27a7d0d54e47e09ba41984e95de005]
#    to [527b11c0e4f7bbe299632422b43361ad03bad520]
# 
# patch "packages/gsm/libgsmd_svn.bb"
#  from [5065ec60004cca9901a244a94b9227aca18ee6bf]
#    to [92c8f650cef1746ab805c766fe19dc5602989a8c]
# 
============================================================
--- packages/gsm/files/htcuniversal/default	ec5dd1432f454bf1f125b0ae7e8df2d0c09ce451
+++ packages/gsm/files/htcuniversal/default	ec5dd1432f454bf1f125b0ae7e8df2d0c09ce451
@@ -0,0 +1,10 @@
+# gsmd	This shell script configures for the gsmd init script.
+
+GSMD_OPTS="-s 115200 -F"
+
+# If your GSM device needs to be powered up, uncomment and modify the next line
+#GSM_POW="/sys/bus/platform/devices/gta01-pm-gsm.0/power_on"
+
+# this should be in a common /etc/default/serial, together
+# with BT_DEV, and IR_DEV
+GSM_DEV="/dev/ttyS0"
============================================================
--- packages/gsm/files/numeric.patch	977aab49d5f8a96b98eb9900c325e8d95d323778
+++ packages/gsm/files/numeric.patch	977aab49d5f8a96b98eb9900c325e8d95d323778
@@ -0,0 +1,56 @@
+Index: gsm/src/gsmd/atcmd.c
+===================================================================
+--- gsm.orig/src/gsmd/atcmd.c	2007-04-02 09:59:16.000000000 +0200
++++ gsm/src/gsmd/atcmd.c	2007-04-02 10:10:54.000000000 +0200
+@@ -207,7 +207,7 @@
+ 	 *    TBD
+ 	 */
+ 
+-	if (buf[0] == '+' || buf[0] == '%') {
++	if (buf[0] == '+' || buf[0] == '%' || buf[0] == '@') {
+ 		/* an extended response */
+ 		const char *colon = strchr(buf, ':');
+ 		if (!colon) {
+@@ -269,14 +269,13 @@
+ 			memcpy(cmd->buf, buf, len);
+ 		}
+ 	} else {
+-		if (!strcmp(buf, "RING")) {
++		if (!strcmp(buf, "RING") || buf[0] == '2') {
+ 			/* this is the only non-extended unsolicited return
+ 			 * code, part of Case 'B' */
+ 			return unsolicited_parse(g, buf, len, NULL);
+ 		}
+ 
+-		if (!strcmp(buf, "ERROR") ||
+-		    ((g->flags & GSMD_FLAG_V0) && buf[0] == '4')) {
++		if (!strcmp(buf, "ERROR") || buf[0] == '4') {
+ 			/* Part of Case 'C' */
+ 			DEBUGP("unspecified error\n");
+ 			if (cmd)
+@@ -285,8 +284,7 @@
+ 			goto final_cb;
+ 		}
+ 
+-		if (!strncmp(buf, "OK", 2)
+-		    || ((g->flags & GSMD_FLAG_V0) && buf[0] == '0')) {
++		if (!strncmp(buf, "OK", 2) || buf[0] == '0') {
+ 			/* Part of Case 'C' */
+ 			if (cmd)
+ 				cmd->ret = 0;
+@@ -296,13 +294,13 @@
+ 
+ 		/* FIXME: handling of those special commands in response to
+ 		 * ATD / ATA */
+-		if (!strncmp(buf, "NO CARRIER", 11)) {
++		if (!strncmp(buf, "NO CARRIER", 11) || buf[0] == '3') {
+ 			/* Part of Case 'D' */
+ 			final = 1;
+ 			goto final_cb;
+ 		}
+ 
+-		if (!strncmp(buf, "BUSY", 4)) {
++		if (!strncmp(buf, "BUSY", 4) || buf[0] == '7') {
+ 			/* Part of Case 'D' */
+ 			final = 1;
+ 			goto final_cb;
============================================================
--- packages/gsm/files/plugin.patch	cdcc38e2e5945c3c6dbc3992863db070003f4208
+++ packages/gsm/files/plugin.patch	cdcc38e2e5945c3c6dbc3992863db070003f4208
@@ -0,0 +1,935 @@
+Index: gsm/include/gsmd/gsmd.h
+===================================================================
+--- gsm.orig/include/gsmd/gsmd.h	2007-04-02 09:58:55.000000000 +0200
++++ gsm/include/gsmd/gsmd.h	2007-04-02 11:03:41.000000000 +0200
+@@ -7,6 +7,7 @@
+ 
+ #include <common/linux_list.h>
+ 
++#include <gsmd/machineplugin.h>
+ #include <gsmd/vendorplugin.h>
+ #include <gsmd/select.h>
+ #include <gsmd/state.h>
+@@ -58,12 +59,14 @@
+ 
+ struct gsmd {
+ 	unsigned int flags;
++	int interpreter_ready;
+ 	struct gsmd_fd gfd_uart;
+ 	struct gsmd_fd gfd_sock;
+ 	struct llparser llp;
+ 	struct llist_head users;
+ 	struct llist_head pending_atcmds;	/* our busy gsmd_atcmds */
+ 	struct llist_head busy_atcmds;	/* our busy gsmd_atcmds */
++	struct gsmd_machine_plugin *machinepl;
+ 	struct gsmd_vendor_plugin *vendorpl;
+ 	struct gsmd_device_state dev_state;
+ 
+Index: gsm/include/gsmd/machineplugin.h
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gsm/include/gsmd/machineplugin.h	2007-04-02 11:03:41.000000000 +0200
+@@ -0,0 +1,24 @@
++#ifndef _GSMD_MACHINEPLUG_H
++#define _GSMD_MACHINEPLUG_H
++
++#ifdef __GSMD__
++
++#include <common/linux_list.h>
++#include <gsmd/gsmd.h>
++
++struct gsmd;
++
++struct gsmd_machine_plugin {
++	struct llist_head list;
++	unsigned char *name;
++	int (*detect)(struct gsmd *g);
++	int (*init)(struct gsmd *g, int fd);
++};
++
++extern int gsmd_machine_plugin_register(struct gsmd_machine_plugin *pl);
++extern void gsmd_machine_plugin_unregister(struct gsmd_machine_plugin *pl);
++extern int gsmd_machine_plugin_find(struct gsmd *g);
++
++#endif /* __GSMD__ */
++
++#endif
+Index: gsm/src/gsmd/machine_tihtc.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gsm/src/gsmd/machine_tihtc.c	2007-04-02 11:03:41.000000000 +0200
+@@ -0,0 +1,71 @@
++/* TI [Calypso] with HTC firmware machine plugin
++ *
++ * Written by Philipp Zabel <philipp.zabel at gmail.com>
++ *
++ * 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.
++ *
++ */
++
++#include <stdlib.h>
++#include <unistd.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++#include <sys/ioctl.h>
++
++#include "gsmd.h"
++
++#include <gsmd/gsmd.h>
++#include <gsmd/usock.h>
++#include <gsmd/event.h>
++#include <gsmd/talloc.h>
++#include <gsmd/extrsp.h>
++#include <gsmd/machineplugin.h>
++
++#define N_TIHTC 17
++
++static int tihtc_detect(struct gsmd *g)
++{
++	/* FIXME: do actual detection of machine if we have multiple machines */
++	return 1;
++}
++
++static int tihtc_init(struct gsmd *g, int fd)
++{
++	int ldisc = N_TIHTC;
++	int rc;
++
++	/*
++	 * Himalaya, Blueangel, Alpine and Magican
++	 * power up their GSM chipsets when the
++	 * tty is opened. Wait for the "AT-Command
++	 * Interpreter ready" message before trying
++	 * to send commands.
++	 */
++	g->interpreter_ready = 0;
++
++	/* Set the line discipline to N_TIHTC */
++	rc = ioctl(fd, TIOCSETD, &ldisc);
++	if (rc < 0)
++		fprintf(stderr, "can't set line discipline\n");
++
++	return rc;
++}
++
++struct gsmd_machine_plugin gsmd_machine_plugin = {
++	.name = "TI Calypso / HTC firmware",
++	.detect = &tihtc_detect,
++	.init = &tihtc_init,
++};
+Index: gsm/src/gsmd/machine_generic.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gsm/src/gsmd/machine_generic.c	2007-04-02 11:03:41.000000000 +0200
+@@ -0,0 +1,61 @@
++/* generic machine plugin
++ *
++ * Written by Philipp Zabel <philipp.zabel at gmail.com>
++ *
++ * 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.
++ *
++ */
++
++#include <stdlib.h>
++#include <unistd.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#include "gsmd.h"
++
++#include <gsmd/gsmd.h>
++#include <gsmd/usock.h>
++#include <gsmd/event.h>
++#include <gsmd/talloc.h>
++#include <gsmd/extrsp.h>
++#include <gsmd/machineplugin.h>
++
++static int generic_detect(struct gsmd *g)
++{
++	/* FIXME: do actual detection of machine if we have multiple machines */
++	return 1;
++}
++
++static int generic_init(struct gsmd *g, int fd)
++{
++	int rc;
++
++	/*
++	 * We assume that the GSM chipset can take
++	 * input immediately, so we don't have to
++	 * wait for the "AT-Command Interpreter ready"
++	 * message before trying to send commands.
++	 */
++	g->interpreter_ready = 1;
++
++	return 0;
++}
++
++struct gsmd_machine_plugin gsmd_machine_plugin = {
++	.name = "generic",
++	.detect = &generic_detect,
++	.init = &generic_init,
++};
+Index: gsm/src/gsmd/machine.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gsm/src/gsmd/machine.c	2007-04-02 13:43:04.000000000 +0200
+@@ -0,0 +1,140 @@
++/* gsmd machine plugin core
++ *
++ * Written by Philipp Zabel <philipp.zabel at gmail.com>
++ *
++ * 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.
++ *
++ */
++
++#include <dlfcn.h>
++#include <errno.h>
++#include <stdio.h>
++#include <string.h>
++
++#include <common/linux_list.h>
++
++#include "gsmd.h"
++
++#include <gsmd/gsmd.h>
++#include <gsmd/machineplugin.h>
++
++static LLIST_HEAD(machinepl_list);
++
++int gsmd_machine_plugin_register(struct gsmd_machine_plugin *pl)
++{
++	llist_add(&pl->list, &machinepl_list);
++
++	return 0;
++}
++
++void gsmd_machine_plugin_unregister(struct gsmd_machine_plugin *pl)
++{
++	llist_del(&pl->list);
++}
++
++int gsmd_machine_plugin_find(struct gsmd *g)
++{
++	struct gsmd_machine_plugin *pl;
++
++	if (g->machinepl)
++		return -EEXIST;
++
++	llist_for_each_entry(pl, &machinepl_list, list) {
++		if (pl->detect(g) == 1) {
++			DEBUGP("selecting machine plugin \"%s\"\n", pl->name);
++			g->machinepl = pl;
++			return 1;
++		}
++	}
++
++	return 0;
++}
++
++int gsmd_machine_plugin_load(char *name)
++{
++	int rc = -1;
++	void *plugin;
++	struct gsmd_machine_plugin *pl;
++	char buf[128];
++
++	DEBUGP("loading machine plugin \"%s\"\n", name);
++
++	snprintf(buf, sizeof(buf), PLUGINDIR"/libgsmd-machine_%s.so", name);
++
++	plugin = dlopen(buf, RTLD_LAZY);
++	if (!plugin) {
++		fprintf(stderr, "gsmd_machine_plugin_load: %s\n", dlerror());
++		return -1;
++	}
++
++	pl = dlsym(plugin, "gsmd_machine_plugin");
++	if (pl)
++		rc = gsmd_machine_plugin_register(pl);
++	else
++		dlclose(plugin);
++
++	return rc;
++}
++
++/* maybe /etc/gsmd/cpuinfo */
++struct machines {
++	char *cpuinfo;
++	char *machine;
++	char *vendor;
++} machines[] = {
++	{ "GTA01",		"generic",	"ti" },
++	{ "HTC Blueangel",	"tihtc",	"tihtc" },
++	{ "HTC Himalaya",	"tihtc",	"tihtc" },
++	{ "HTC Magician",	"tihtc",	"tihtc" },
++	{ "HTC Universal",	"generic",	"qc" },
++	{ NULL, NULL, NULL },
++};
++
++int gsmd_machine_plugin_init(struct gsmd *g, int fd)
++{
++	FILE *cpuinfo;
++	char buf[1024];
++	char *line, *machine = NULL;
++	int i, rc;
++
++	cpuinfo = fopen("/proc/cpuinfo", "r");
++	fread(buf, sizeof(buf), 1, cpuinfo);
++	fclose(cpuinfo);
++
++	line = strtok(buf, "\n");
++	while (line = strtok(NULL, "\n")) {
++		if (strncmp(line, "Hardware\t: ", 11) == 0) {
++			machine = line+11;
++			break;
++		}
++	}
++	/* FIXME: do this dynamically */
++	if (machine) {
++		for (i = 0; machines[i].cpuinfo; i++) {
++			if (strcmp(machine, machines[i].cpuinfo) == 0) {
++				DEBUGP("detected %s\n", machine);
++				rc = gsmd_machine_plugin_load(machines[i].machine);
++				rc |= gsmd_vendor_plugin_load(machines[i].vendor);
++				return rc;
++			}
++		}
++	}
++	/* load generic machine and all vendor plugins */
++	rc = gsmd_machine_plugin_load("generic");
++	gsmd_vendor_plugin_load("ti");
++	gsmd_vendor_plugin_load("tihtc");
++	gsmd_vendor_plugin_load("qc");
++	return rc;
++}
+Index: gsm/src/gsmd/vendor_qc.c
+===================================================================
+--- /dev/null	1970-01-01 00:00:00.000000000 +0000
++++ gsm/src/gsmd/vendor_qc.c	2007-04-02 11:03:41.000000000 +0200
+@@ -0,0 +1,104 @@
++/* Qualcomm [msm6250] gsmd plugin
++ *
++ * Written by Philipp Zabel <philipp.zabel at gmail.com>
++ * based on vendor_ti.c
++ *
++ * 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.
++ *
++ */
++
++#include <stdlib.h>
++#include <unistd.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++
++#include "gsmd.h"
++
++#include <gsmd/gsmd.h>
++#include <gsmd/usock.h>
++#include <gsmd/event.h>
++#include <gsmd/talloc.h>
++#include <gsmd/extrsp.h>
++#include <gsmd/atcmd.h>
++#include <gsmd/vendorplugin.h>
++#include <gsmd/unsolicited.h>
++
++static int htccsq_parse(char *buf, int len, const char *param,
++		     struct gsmd *gsmd)
++{
++	char *tok;
++	struct gsmd_evt_auxdata *aux;
++	struct gsmd_ucmd *ucmd = usock_build_event(GSMD_MSG_EVENT, GSMD_EVT_SIGNAL,
++					     sizeof(*aux));
++	static int rssi_table[] = { 0,5,10,15,20,25,99 }; /* FIXME */
++	unsigned int i;
++
++	DEBUGP("entering htccsq_parse param=`%s'\n", param);
++	if (!ucmd)
++		return -EINVAL;
++
++
++	aux = (struct gsmd_evt_auxdata *) ucmd->buf;
++
++	i = atoi(buf);
++	if (i > 6)
++		i = 6;
++	aux->u.signal.sigq.rssi = rssi_table[atoi(buf)];
++	aux->u.signal.sigq.ber = 99;
++
++	DEBUGP("sending EVT_SIGNAL\n");
++	usock_evt_send(gsmd, ucmd, GSMD_EVT_SIGNAL);
++
++	return 0;
++
++out_free_io:
++	free(ucmd);
++	return -EIO;
++}
++
++static const struct gsmd_unsolicit qc_unsolicit[] = {
++	{ "@HTCCSQ",	&htccsq_parse },	/* Signal Quality */
++
++	/* FIXME: parse the below and generate the respective events */
++
++	/* %CGREG: reports extended information about GPRS registration state */
++};
++
++static int qc_detect(struct gsmd *g)
++{
++	/* FIXME: do actual detection of vendor if we have multiple vendors */
++	/* open /proc/cpuinfo and check for HTC Universal? */
++	return 1;
++}
++
++static int qc_initsettings(struct gsmd *g)
++{
++	int rc;
++	struct gsmd_atcmd *cmd;
++
++	/* enable @HTCCSQ: signal quality reports */
++	rc |= gsmd_simplecmd(g, "AT at HTCCSQ=1");
++
++	return rc;
++}
++
++struct gsmd_vendor_plugin gsmd_vendor_plugin = {
++	.name = "Qualcomm msm6250",
++	.num_unsolicit = ARRAY_SIZ%s
>>> DIFF TRUNCATED @ 16K






More information about the Openembedded-commits mailing list