ecore: remove unused patch
[qi-bootmenu-system/guyou.git] / sources / patches / tslib-static-modules.patch
blob5a739c6c83501fa5c791249ece8f4f6200304f10
1 commit 47bbd1c449bc9bf747f114b9c7e711908ad29a20
2 Author: Marc Andre Tanner <mat@brain-dump.org>
3 Date: Sun Jan 3 08:23:05 2010 +0100
5 Support static modules aka modules which are embedded inside libts
7 This can be usefull for statically linked application or platforms
8 where dlopen(3) is not available.
10 A module will be compiled statically if it was requested during
11 ./configure with --enable-$FOO=static.
13 Static modules will have precedence over shared ones which means
14 if a module is configured to be embedded inside libts it's
15 corresponding shared library isn't build and ignored even if
16 it is in $TSLIB_PLUGINDIR.
18 Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>
20 diff --git a/configure.ac b/configure.ac
21 index f79fc00..6a44ccb 100644
22 --- a/configure.ac
23 +++ b/configure.ac
24 @@ -50,125 +50,21 @@ AC_FUNC_VPRINTF
25 AC_CHECK_FUNCS([gettimeofday memmove memset munmap select strcasecmp strchr strdup strtoul])
27 # filters
28 -AC_MSG_CHECKING([whether linear modules is requested])
29 -AC_ARG_ENABLE(linear,
30 - AS_HELP_STRING([--enable-linear],
31 - [Enable building of linear scaling (default=yes)]),
32 - [linear_module=$enableval],
33 - [linear_module=yes])
34 -AC_MSG_RESULT($linear_module)
35 -AM_CONDITIONAL(ENABLE_LINEAR_MODULE, test "$linear_module" = "yes")
37 -AC_MSG_CHECKING([whether dejitter module is requested])
38 -AC_ARG_ENABLE(dejitter,
39 - AS_HELP_STRING([--enable-dejitter],
40 - [Enable building of dejitter filter (default=yes)]),
41 - [dejitter_module=$enableval],
42 - [dejitter_module=yes])
43 -AC_MSG_RESULT($dejitter_module)
44 -AM_CONDITIONAL(ENABLE_DEJITTER_MODULE, test "$dejitter_module" = "yes")
46 -AC_MSG_CHECKING([whether linear-h2200 module is requested])
47 -AC_ARG_ENABLE(linear-h2200,
48 - AS_HELP_STRING([--enable-linear-h2200],
49 - [Enable building of linearizing filter for iPAQ h2200 (default=yes)]),
50 - [h2200_linear_module=$enableval],
51 - [h2200_linear_module=yes])
52 -AC_MSG_RESULT($h2200_linear_module)
53 -AM_CONDITIONAL(ENABLE_H2200_LINEAR_MODULE, test "$h2200_linear_module" = "yes")
55 -AC_MSG_CHECKING([whether variance module is requested])
56 -AC_ARG_ENABLE(variance,
57 - AS_HELP_STRING([--enable-variance],
58 - [Enable building of variance filter (default=yes)]),
59 - [variance_module=$enableval],
60 - [variance_module=yes])
61 -AC_MSG_RESULT($variance_module)
62 -AM_CONDITIONAL(ENABLE_VARIANCE_MODULE, test "$variance_module" = "yes")
64 -AC_MSG_CHECKING([whether pthres module is requested])
65 -AC_ARG_ENABLE(pthres,
66 - AS_HELP_STRING([--enable-pthres],
67 - [Enable building of pthres filter (default=yes)]),
68 - [pthres_module=$enableval],
69 - [pthres_module=yes])
70 -AC_MSG_RESULT($pthres_module)
71 -AM_CONDITIONAL(ENABLE_PTHRES_MODULE, test "$pthres_module" = "yes")
73 +TSLIB_CHECK_MODULE([linear], [yes], [Enable building of linear scaling])
74 +TSLIB_CHECK_MODULE([dejitter], [yes], [Enable building of dejitter filter])
75 +TSLIB_CHECK_MODULE([linear-h2200], [yes], [Enable building of linearizing filter for iPAQ h2200])
76 +TSLIB_CHECK_MODULE([variance], [yes], [Enable building of variance filter])
77 +TSLIB_CHECK_MODULE([pthres], [yes], [Enable building of pthres filter])
79 # hardware access modules
80 -AC_MSG_CHECKING([whether ucb1x00 module is requested])
81 -AC_ARG_ENABLE(ucb1x00,
82 - AS_HELP_STRING([--enable-ucb1x00],
83 - [Enable building of ucb1x00 raw module (UCB1x00 support) (default=yes)]),
84 - [ucb1x00_module=$enableval],
85 - [ucb1x00_module=yes])
86 -AC_MSG_RESULT($ucb1x00_module)
87 -AM_CONDITIONAL(ENABLE_UCB1X00_MODULE, test "$ucb1x00_module" = "yes")
89 -AC_MSG_CHECKING([whether corgi module is requested])
90 -AC_ARG_ENABLE(corgi,
91 - AS_HELP_STRING([--enable-corgi],
92 - [Enable building of corgi raw module (Sharp Zaurus sl-c7x0 support) (default=yes)]),
93 - [corgi_module=$enableval],
94 - [corgi_module=yes])
95 -AC_MSG_RESULT($corgi_module)
96 -AM_CONDITIONAL(ENABLE_CORGI_MODULE, test "$corgi_module" = "yes")
98 -AC_MSG_CHECKING([whether collie module is requested])
99 -AC_ARG_ENABLE(collie,
100 - AS_HELP_STRING([--enable-collie],
101 - [Enable building of collie raw module (Sharp Zaurus sl-5500/5000d support) (default=yes)]),
102 - [collie_module=$enableval],
103 - [collie_module=yes])
104 -AC_MSG_RESULT($collie_module)
105 -AM_CONDITIONAL(ENABLE_COLLIE_MODULE, test "$collie_module" = "yes")
108 -AC_MSG_CHECKING([whether h3600 module is requested])
109 -AC_ARG_ENABLE(h3600,
110 - AS_HELP_STRING([--enable-h3600],
111 - [Enable building of h3600 raw module (HP iPaq H3600 support) (default=yes)]),
112 - [h3600_module=$enableval],
113 - [h3600_module=yes])
114 -AC_MSG_RESULT($h3600_module)
115 -AM_CONDITIONAL(ENABLE_H3600_MODULE, test "$h3600_module" = "yes")
117 -AC_MSG_CHECKING([whether mk712 module is requested])
118 -AC_ARG_ENABLE(mk712,
119 - AS_HELP_STRING([--enable-mk712],
120 - [Enable building of mk712 raw module (Hi tachi support) (default=yes)]),
121 - [mk712_module=$enableval],
122 - [mk712_module=yes])
123 -AC_MSG_RESULT($mk712_module)
124 -AM_CONDITIONAL(ENABLE_MK712_MODULE, test "$mk712_module" = "yes")
126 -AC_MSG_CHECKING([whether arctic2 module is requested])
127 -AC_ARG_ENABLE(arctic2,
128 - AS_HELP_STRING([--enable-arctic2],
129 - [Enable building of arctic2 raw module (IBM Arctic II support) (default=yes)]),
130 - [arctic2_module=$enableval],
131 - [arctic2_module=yes])
132 -AC_MSG_RESULT($arctic2_module)
133 -AM_CONDITIONAL(ENABLE_ARCTIC2_MODULE, test "$arctic2_module" = "yes")
135 -AC_MSG_CHECKING([whether tatung module is requested])
136 -AC_ARG_ENABLE(tatung,
137 - AS_HELP_STRING([--enable-tatung],
138 - [Enable building of tatung raw module (Tatung Webpad support) (default=yes)]),
139 - [tatung_module=$enableval],
140 - [tatung_module=yes])
141 -AC_MSG_RESULT($tatung_module)
142 -AM_CONDITIONAL(ENABLE_TATUNG_MODULE, test "$tatung_module" = "yes")
144 -AC_MSG_CHECKING([whether input module is requested])
145 -AC_ARG_ENABLE(input,
146 - AS_HELP_STRING([--enable-input],
147 - [Enable building of generic input raw module (Linux /dev/input/eventN support) (default=yes)]),
148 - [input_module=$enableval],
149 - [input_module=yes])
150 -AC_MSG_RESULT($input_module)
151 -AM_CONDITIONAL(ENABLE_INPUT_MODULE, test "$input_module" = "yes")
152 +TSLIB_CHECK_MODULE([ucb1x00], [yes], [Enable building of ucb1x00 raw module (UCB1x00 support)])
153 +TSLIB_CHECK_MODULE([corgi], [yes], [Enable building of corgi raw module (Sharp Zaurus sl-c7x0 support)])
154 +TSLIB_CHECK_MODULE([collie], [yes], [Enable building of collie raw module (Sharp Zaurus sl-5500/5000d support)])
155 +TSLIB_CHECK_MODULE([h3600], [yes], [Enable building of h3600 raw module (HP iPaq H3600 support)])
156 +TSLIB_CHECK_MODULE([mk712], [yes], [Enable building of mk712 raw module (Hi tachi support)])
157 +TSLIB_CHECK_MODULE([arctic2], [yes], [Enable building of arctic2 raw module (IBM Arctic II support)])
158 +TSLIB_CHECK_MODULE([tatung], [yes], [Enable building of tatung raw module (Tatung Webpad support)])
159 +TSLIB_CHECK_MODULE([input], [yes], [Enable building of generic input raw module (Linux /dev/input/eventN support)])
161 AC_MSG_CHECKING([where to place modules])
162 AC_ARG_WITH(plugindir,
163 diff --git a/m4/internal/tslib_modules.m4 b/m4/internal/tslib_modules.m4
164 new file mode 100644
165 index 0000000..6bc1764
166 --- /dev/null
167 +++ b/m4/internal/tslib_modules.m4
168 @@ -0,0 +1,22 @@
169 +dnl use: TSLIB_CHECK_MODULE(module, default, description)
170 +AC_DEFUN([TSLIB_CHECK_MODULE],
172 +m4_pushdef([UP], m4_translit([$1], [-a-z], [_A-Z]))dnl
174 +AC_MSG_CHECKING([whether $1 module is requested])
176 +AC_ARG_ENABLE([$1],
177 + AC_HELP_STRING([--enable-$1], [$3 (default=$2)]),
178 + [enable_module=$enableval],
179 + [enable_module=$2])
180 +AC_MSG_RESULT($enable_module)
182 +AM_CONDITIONAL(ENABLE_[]UP[]_MODULE, test "x$enable_module" = "xyes")
183 +AM_CONDITIONAL(ENABLE_STATIC_[]UP[]_MODULE, test "x$enable_module" = "xstatic")
184 +if test "x$enable_module" = "xstatic" ; then
185 + AC_DEFINE(TSLIB_STATIC_[]UP[]_MODULE, 1, whether $1 should be build as part of libts or as a
186 + separate shared library which is dlopen()-ed at runtime)
189 +m4_popdef([UP])
191 diff --git a/plugins/Makefile.am b/plugins/Makefile.am
192 index 93edb29..a73971d 100644
193 --- a/plugins/Makefile.am
194 +++ b/plugins/Makefile.am
195 @@ -91,7 +91,7 @@ else
196 INPUT_MODULE =
197 endif
199 -if ENABLE_H2200_LINEAR_MODULE
200 +if ENABLE_LINEAR_H2200_MODULE
201 H2200_LINEAR_MODULE = linear_h2200.la
202 else
203 H2200_LINEAR_MODULE =
204 diff --git a/plugins/arctic2-raw.c b/plugins/arctic2-raw.c
205 index 82dfceb..cf7becc 100644
206 --- a/plugins/arctic2-raw.c
207 +++ b/plugins/arctic2-raw.c
208 @@ -48,7 +48,7 @@ static const struct tslib_ops arctic2_ops =
209 .read = arctic2_read,
212 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
213 +TSAPI struct tslib_module_info *arctic2_mod_init(struct tsdev *dev, const char *params)
215 struct tslib_module_info *m;
217 @@ -59,3 +59,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
218 m->ops = &arctic2_ops;
219 return m;
222 +#ifndef TSLIB_STATIC_ARCTIC2_MODULE
223 + TSLIB_MODULE_INIT(arctic2_mod_init);
224 +#endif
225 diff --git a/plugins/collie-raw.c b/plugins/collie-raw.c
226 index 28e817f..7bb15d7 100644
227 --- a/plugins/collie-raw.c
228 +++ b/plugins/collie-raw.c
229 @@ -48,7 +48,7 @@ static const struct tslib_ops collie_ops =
230 .read = collie_read,
233 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
234 +TSAPI struct tslib_module_info *collie_mod_init(struct tsdev *dev, const char *params)
236 struct tslib_module_info *m;
238 @@ -59,3 +59,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
239 m->ops = &collie_ops;
240 return m;
243 +#ifndef TSLIB_STATIC_COLLIE_MODULE
244 + TSLIB_MODULE_INIT(collie_mod_init);
245 +#endif
246 diff --git a/plugins/corgi-raw.c b/plugins/corgi-raw.c
247 index daef144..d7ddd7c 100644
248 --- a/plugins/corgi-raw.c
249 +++ b/plugins/corgi-raw.c
250 @@ -47,7 +47,7 @@ static const struct tslib_ops corgi_ops =
251 .read = corgi_read,
254 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
255 +TSAPI struct tslib_module_info *corgi_mod_init(struct tsdev *dev, const char *params)
257 struct tslib_module_info *m;
259 @@ -58,3 +58,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
260 m->ops = &corgi_ops;
261 return m;
264 +#ifndef TSLIB_STATIC_CORGI_MODULE
265 + TSLIB_MODULE_INIT(corgi_mod_init);
266 +#endif
267 diff --git a/plugins/dejitter.c b/plugins/dejitter.c
268 index 383793b..0d4d634 100644
269 --- a/plugins/dejitter.c
270 +++ b/plugins/dejitter.c
271 @@ -29,6 +29,7 @@
273 #include <stdio.h>
275 +#include "config.h"
276 #include "tslib.h"
277 #include "tslib-filter.h"
279 @@ -197,7 +198,7 @@ static const struct tslib_vars dejitter_vars[] =
281 #define NR_VARS (sizeof(dejitter_vars) / sizeof(dejitter_vars[0]))
283 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
284 +TSAPI struct tslib_module_info *dejitter_mod_init(struct tsdev *dev, const char *params)
286 struct tslib_dejitter *djt;
288 @@ -219,3 +220,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
290 return &djt->module;
293 +#ifndef TSLIB_STATIC_DEJITTER_MODULE
294 + TSLIB_MODULE_INIT(dejitter_mod_init);
295 +#endif
296 diff --git a/plugins/h3600-raw.c b/plugins/h3600-raw.c
297 index 81aabc2..b6254df 100644
298 --- a/plugins/h3600-raw.c
299 +++ b/plugins/h3600-raw.c
300 @@ -47,7 +47,7 @@ static const struct tslib_ops h3600_ops =
301 .read = h3600_read,
304 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
305 +TSAPI struct tslib_module_info *h3600_mod_init(struct tsdev *dev, const char *params)
307 struct tslib_module_info *m;
309 @@ -58,3 +58,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
310 m->ops = &h3600_ops;
311 return m;
314 +#ifndef TSLIB_STATIC_H3600_MODULE
315 + TSLIB_MODULE_INIT(h3600_mod_init);
316 +#endif
317 diff --git a/plugins/input-raw.c b/plugins/input-raw.c
318 index 6bca86b..5fa0acb 100644
319 --- a/plugins/input-raw.c
320 +++ b/plugins/input-raw.c
321 @@ -326,7 +326,7 @@ static const struct tslib_vars raw_vars[] =
323 #define NR_VARS (sizeof(raw_vars) / sizeof(raw_vars[0]))
325 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
326 +TSAPI struct tslib_module_info *input_mod_init(struct tsdev *dev, const char *params)
328 struct tslib_input *i;
330 @@ -349,3 +349,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
332 return &(i->module);
335 +#ifndef TSLIB_STATIC_INPUT_MODULE
336 + TSLIB_MODULE_INIT(input_mod_init);
337 +#endif
338 diff --git a/plugins/linear-h2200.c b/plugins/linear-h2200.c
339 index ab4a807..83fe2ed 100644
340 --- a/plugins/linear-h2200.c
341 +++ b/plugins/linear-h2200.c
342 @@ -20,6 +20,7 @@
344 #include <stdio.h>
346 +#include "config.h"
347 #include "tslib.h"
348 #include "tslib-filter.h"
350 @@ -106,7 +107,7 @@ static const struct tslib_ops linear_h2200_ops =
351 .fini = linear_h2200_fini,
354 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
355 +TSAPI struct tslib_module_info *linear_h2200_mod_init(struct tsdev *dev, const char *params)
358 struct tslib_linear_h2200 *lin;
359 @@ -119,3 +120,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
361 return &lin->module;
364 +#ifndef TSLIB_STATIC_LINEAR_H2200_MODULE
365 + TSLIB_MODULE_INIT(linear_h2200_mod_init);
366 +#endif
367 diff --git a/plugins/linear.c b/plugins/linear.c
368 index 4fe04d3..c55c218 100644
369 --- a/plugins/linear.c
370 +++ b/plugins/linear.c
371 @@ -20,6 +20,7 @@
373 #include <stdio.h>
375 +#include "config.h"
376 #include "tslib-private.h"
377 #include "tslib-filter.h"
379 @@ -107,7 +108,7 @@ static const struct tslib_vars linear_vars[] =
381 #define NR_VARS (sizeof(linear_vars) / sizeof(linear_vars[0]))
383 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
384 +TSAPI struct tslib_module_info *linear_mod_init(struct tsdev *dev, const char *params)
387 struct tslib_linear *lin;
388 @@ -163,3 +164,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
390 return &lin->module;
393 +#ifndef TSLIB_STATIC_LINEAR_MODULE
394 + TSLIB_MODULE_INIT(linear_mod_init);
395 +#endif
396 diff --git a/plugins/mk712-raw.c b/plugins/mk712-raw.c
397 index 79914b6..b1a6af7 100644
398 --- a/plugins/mk712-raw.c
399 +++ b/plugins/mk712-raw.c
400 @@ -50,7 +50,7 @@ static const struct tslib_ops mk712_ops =
401 .read = mk712_read,
404 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
405 +TSAPI struct tslib_module_info *mk712_mod_init(struct tsdev *dev, const char *params)
407 struct tslib_module_info *m;
409 @@ -61,3 +61,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
410 m->ops = &mk712_ops;
411 return m;
414 +#ifndef TSLIB_STATIC_MK712_MODULE
415 + TSLIB_MODULE_INIT(mk712_mod_init);
416 +#endif
417 diff --git a/plugins/plugins.h b/plugins/plugins.h
418 new file mode 100644
419 index 0000000..4bba49c
420 --- /dev/null
421 +++ b/plugins/plugins.h
422 @@ -0,0 +1,17 @@
423 +#define TSLIB_DECLARE_MODULE(name) \
424 + TSAPI struct tslib_module_info *name##_mod_init(struct tsdev *dev, const char *params)
426 +TSLIB_DECLARE_MODULE(linear);
427 +TSLIB_DECLARE_MODULE(dejitter);
428 +TSLIB_DECLARE_MODULE(linear_h2200);
429 +TSLIB_DECLARE_MODULE(variance);
430 +TSLIB_DECLARE_MODULE(pthres);
432 +TSLIB_DECLARE_MODULE(ucb1x00);
433 +TSLIB_DECLARE_MODULE(corgi);
434 +TSLIB_DECLARE_MODULE(collie);
435 +TSLIB_DECLARE_MODULE(h3600);
436 +TSLIB_DECLARE_MODULE(mk712);
437 +TSLIB_DECLARE_MODULE(arctic2);
438 +TSLIB_DECLARE_MODULE(tatung);
439 +TSLIB_DECLARE_MODULE(input);
440 diff --git a/plugins/pthres.c b/plugins/pthres.c
441 index cca454c..c5e1f6e 100644
442 --- a/plugins/pthres.c
443 +++ b/plugins/pthres.c
444 @@ -20,6 +20,7 @@
445 #include <errno.h>
446 #include <limits.h>
448 +#include "config.h"
449 #include "tslib.h"
450 #include "tslib-filter.h"
452 @@ -131,7 +132,7 @@ static const struct tslib_vars pthres_vars[] =
454 #define NR_VARS (sizeof(pthres_vars) / sizeof(pthres_vars[0]))
456 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
457 +TSAPI struct tslib_module_info *pthres_mod_init(struct tsdev *dev, const char *params)
460 struct tslib_pthres *p;
461 @@ -155,3 +156,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
463 return &p->module;
466 +#ifndef TSLIB_STATIC_PTHRES_MODULE
467 + TSLIB_MODULE_INIT(pthres_mod_init);
468 +#endif
469 diff --git a/plugins/tatung-raw.c b/plugins/tatung-raw.c
470 index 26fae27..5ba85cf 100644
471 --- a/plugins/tatung-raw.c
472 +++ b/plugins/tatung-raw.c
473 @@ -57,7 +57,7 @@ static const struct tslib_ops tatung_ops =
474 .read = tatung_read,
477 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
478 +TSAPI struct tslib_module_info *tatung_mod_init(struct tsdev *dev, const char *params)
480 struct tslib_module_info *m;
482 @@ -68,3 +68,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
483 m->ops = &tatung_ops;
484 return m;
487 +#ifndef TSLIB_STATIC_TATUNG_MODULE
488 + TSLIB_MODULE_INIT(tatung_mod_init);
489 +#endif
490 diff --git a/plugins/ucb1x00-raw.c b/plugins/ucb1x00-raw.c
491 index 1f9fd1f..6db7e30 100644
492 --- a/plugins/ucb1x00-raw.c
493 +++ b/plugins/ucb1x00-raw.c
494 @@ -49,7 +49,7 @@ static const struct tslib_ops ucb1x00_ops =
495 .read = ucb1x00_read,
498 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
499 +TSAPI struct tslib_module_info *ucb1x00_mod_init(struct tsdev *dev, const char *params)
501 struct tslib_module_info *m;
503 @@ -60,3 +60,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
504 m->ops = &ucb1x00_ops;
505 return m;
508 +#ifndef TSLIB_STATIC_UCB1X00_MODULE
509 + TSLIB_MODULE_INIT(ucb1x00_mod_init);
510 +#endif
511 diff --git a/plugins/variance.c b/plugins/variance.c
512 index 95e12a4..ec24c3e 100644
513 --- a/plugins/variance.c
514 +++ b/plugins/variance.c
515 @@ -28,6 +28,7 @@
516 #include <string.h>
517 #include <limits.h>
519 +#include "config.h"
520 #include "tslib.h"
521 #include "tslib-filter.h"
523 @@ -161,7 +162,7 @@ static const struct tslib_vars variance_vars[] =
525 #define NR_VARS (sizeof(variance_vars) / sizeof(variance_vars[0]))
527 -TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
528 +TSAPI struct tslib_module_info *variance_mod_init(struct tsdev *dev, const char *params)
530 struct tslib_variance *var;
532 @@ -183,3 +184,7 @@ TSAPI struct tslib_module_info *mod_init(struct tsdev *dev, const char *params)
534 return &var->module;
537 +#ifndef TSLIB_STATIC_VARIANCE_MODULE
538 + TSLIB_MODULE_INIT(variance_mod_init);
539 +#endif
540 diff --git a/src/Makefile.am b/src/Makefile.am
541 index 57b1b09..9f0b4c0 100644
542 --- a/src/Makefile.am
543 +++ b/src/Makefile.am
544 @@ -9,7 +9,7 @@
545 # $Id: Makefile.am,v 1.8 2005/02/28 23:44:12 kergoth Exp $
548 -AM_CFLAGS = -DPLUGIN_DIR=\"@PLUGIN_DIR@\" -DTS_CONF=\"@TS_CONF@\" \
549 +AM_CFLAGS = -DPLUGIN_DIR=\"@PLUGIN_DIR@\" -DTS_CONF=\"@TS_CONF@\" -DTS_POINTERCAL=\"@TS_POINTERCAL@\" \
550 $(DEBUGFLAGS) $(LIBFLAGS) $(VIS_CFLAGS)
552 noinst_HEADERS = tslib-private.h tslib-filter.h
553 @@ -19,6 +19,59 @@ lib_LTLIBRARIES = libts.la
554 libts_la_SOURCES = ts_attach.c ts_close.c ts_config.c ts_error.c \
555 ts_fd.c ts_load_module.c ts_open.c ts_parse_vars.c \
556 ts_read.c ts_read_raw.c ts_option.c
558 +if ENABLE_STATIC_LINEAR_MODULE
559 +libts_la_SOURCES += $(top_srcdir)/plugins/linear.c
560 +endif
562 +if ENABLE_STATIC_DEJITTER_MODULE
563 +libts_la_SOURCES += $(top_srcdir)/plugins/dejitter.c
564 +endif
566 +if ENABLE_STATIC_LINEAR_H2200_MODULE
567 +libts_la_SOURCES += $(top_srcdir)/plugins/linear-h2200.c
568 +endif
570 +if ENABLE_STATIC_VARIANCE_MODULE
571 +libts_la_SOURCES += $(top_srcdir)/plugins/variance.c
572 +endif
574 +if ENABLE_STATIC_PTHRES_MODULE
575 +libts_la_SOURCES += $(top_srcdir)/plugins/pthres.c
576 +endif
578 +if ENABLE_STATIC_UCB1X00_MODULE
579 +libts_la_SOURCES += $(top_srcdir)/plugins/ucb1x00-raw.c
580 +endif
582 +if ENABLE_STATIC_CORGI_MODULE
583 +libts_la_SOURCES += $(top_srcdir)/plugins/corgi-raw.c
584 +endif
586 +if ENABLE_STATIC_COLLIE_MODULE
587 +libts_la_SOURCES += $(top_srcdir)/plugins/collie-raw.c
588 +endif
590 +if ENABLE_STATIC_H3600_MODULE
591 +libts_la_SOURCES += $(top_srcdir)/plugins/h3600-raw.c
592 +endif
594 +if ENABLE_STATIC_MK712_MODULE
595 +libts_la_SOURCES += $(top_srcdir)/plugins/mk712-raw.c
596 +endif
598 +if ENABLE_STATIC_ARCTIC2_MODULE
599 +libts_la_SOURCES += $(top_srcdir)/plugins/arctic2-raw.c
600 +endif
602 +if ENABLE_STATIC_TATUNG_MODULE
603 +libts_la_SOURCES += $(top_srcdir)/plugins/tatung-raw.c
604 +endif
606 +if ENABLE_STATIC_INPUT_MODULE
607 +libts_la_SOURCES += $(top_srcdir)/plugins/input-raw.c
608 +endif
610 libts_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
611 -release $(LT_RELEASE) -export-dynamic
612 libts_la_LIBADD = -ldl
613 diff --git a/src/ts_load_module.c b/src/ts_load_module.c
614 index 9605b5c..fa75d9e 100644
615 --- a/src/ts_load_module.c
616 +++ b/src/ts_load_module.c
617 @@ -22,75 +22,154 @@
619 #include "tslib-private.h"
621 -int __ts_load_module(struct tsdev *ts, const char *module, const char *params, int raw)
622 +#include "../plugins/plugins.h"
624 +static struct {
625 + const char *name;
626 + tslib_module_init mod_init;
627 +} tslib_modules[] = {
628 + /* XXX: sort alphabetically and use a binary search? */
629 +#ifdef TSLIB_STATIC_ARCTIC2_MODULE
630 + { "arctic2", arctic2_mod_init },
631 +#endif
632 +#ifdef TSLIB_STATIC_COLLIE_MODULE
633 + { "collie", collie_mod_init },
634 +#endif
635 +#ifdef TSLIB_STATIC_CORGI_MODULE
636 + { "corgi", corgi_mod_init },
637 +#endif
638 +#ifdef TSLIB_STATIC_DEJITTER_MODULE
639 + { "dejitter", dejitter_mod_init },
640 +#endif
641 +#ifdef TSLIB_STATIC_H3600_MODULE
642 + { "h3600", h3600_mod_init },
643 +#endif
644 +#ifdef TSLIB_STATIC_INPUT_MODULE
645 + { "input", input_mod_init },
646 +#endif
647 +#ifdef TSLIB_STATIC_LINEAR_MODULE
648 + { "linear", linear_mod_init },
649 +#endif
650 +#ifdef TSLIB_STATIC_LINEAR_H2200_MODULE
651 + { "linear_h2200", linear_h2200_mod_init },
652 +#endif
653 +#ifdef TSLIB_STATIC_MK712_MODULE
654 + { "mk712", mk712_mod_init },
655 +#endif
656 +#ifdef TSLIB_STATIC_PTHRES_MODULE
657 + { "pthres", pthres_mod_init },
658 +#endif
659 +#ifdef TSLIB_STATIC_TATUNG_MODULE
660 + { "tatung", tatung_mod_init },
661 +#endif
662 +#ifdef TSLIB_STATIC_UCB1X00_MODULE
663 + { "ucb1x00", ucb1x00_mod_init },
664 +#endif
665 +#ifdef TSLIB_STATIC_VARIANCE_MODULE
666 + { "variance", variance_mod_init },
667 +#endif
670 +#define countof(arr) (sizeof(arr) / sizeof((arr)[0]))
672 +static struct tslib_module_info *__ts_load_module_static(struct tsdev *ts, const char *module, const char *params)
674 + struct tslib_module_info *info = NULL;
675 + unsigned int i;
677 + for (i = 0; i < countof(tslib_modules); i++) {
678 + if (!strcmp(tslib_modules[i].name, module)) {
679 + info = tslib_modules[i].mod_init(ts, params);
680 +#ifdef DEBUG
681 + fprintf(stderr, "static module %s init %s\n", module,
682 + info ? "succeeded" : "failed");
683 +#endif
684 + break;
688 + if (info)
689 + info->handle = NULL;
691 + return info;
694 +static struct tslib_module_info *__ts_load_module_shared(struct tsdev *ts, const char *module, const char *params)
696 - struct tslib_module_info * (*init)(struct tsdev *, const char *);
697 + tslib_module_init *init;
698 struct tslib_module_info *info;
699 char fn[1024];
700 void *handle;
701 - int ret;
702 - char *plugin_directory=NULL;
704 - if( (plugin_directory = getenv("TSLIB_PLUGINDIR")) != NULL ) {
705 - //fn = alloca(sizeof(plugin_directory) + strlen(module) + 4);
706 - strcpy(fn,plugin_directory);
707 - } else {
708 - //fn = alloca(sizeof(PLUGIN_DIR) + strlen(module) + 4);
709 - strcpy(fn, PLUGIN_DIR);
711 + char *plugin_directory = getenv("TSLIB_PLUGINDIR");
713 - strcat(fn, "/");
714 - strcat(fn, module);
715 - strcat(fn, ".so");
716 + if (!plugin_directory)
717 + plugin_directory = PLUGIN_DIR;
719 + snprintf(fn, sizeof fn, "%s/%s.so", plugin_directory, module);
721 -#ifdef DEBUG
722 - printf ("Loading module %s\n", fn);
723 -#endif
724 handle = dlopen(fn, RTLD_NOW);
725 if (!handle) {
726 #ifdef DEBUG
727 fprintf (stderr, "%s dlopen() failed: %s\n", fn, dlerror());
728 #endif
729 - return -1;
730 + return NULL;
733 init = dlsym(handle, "mod_init");
734 - if (!init) {
735 + if (!init || !(*init)) {
736 #ifdef DEBUG
737 fprintf (stderr, "%s dlsym() failed: %s\n", fn, dlerror());
738 #endif
739 dlclose(handle);
740 - return -1;
741 + return NULL;
744 - info = init(ts, params);
745 + info = (*init)(ts, params);
746 if (!info) {
747 #ifdef DEBUG
748 fprintf (stderr, "Can't init %s\n", fn);
749 #endif
750 dlclose(handle);
751 - return -1;
752 + return NULL;
755 info->handle = handle;
757 - if (raw) {
758 + return info;
761 +static int __ts_load_module(struct tsdev *ts, const char *module, const char *params, int raw)
763 + struct tslib_module_info *info;
764 + int ret;
766 +#ifdef DEBUG
767 + printf ("Loading module %s\n", module);
768 +#endif
770 + info = __ts_load_module_static(ts, module, params);
771 + if (!info)
772 + info = __ts_load_module_shared(ts, module, params);
773 + if (!info)
774 + return -1;
776 + if (raw)
777 ret = __ts_attach_raw(ts, info);
778 - } else {
779 + else
780 ret = __ts_attach(ts, info);
783 if (ret) {
784 #ifdef DEBUG
785 - fprintf (stderr, "Can't attach %s\n", fn);
786 + fprintf (stderr, "Can't attach %s\n", module);
787 #endif
788 info->ops->fini(info);
789 - dlclose(handle);
790 + if (info->handle)
791 + dlclose(info->handle);
794 return ret;
798 int ts_load_module(struct tsdev *ts, const char *module, const char *params)
800 return __ts_load_module(ts, module, params, 0);
801 diff --git a/src/tslib-filter.h b/src/tslib-filter.h
802 index e33735e..5ed7788 100644
803 --- a/src/tslib-filter.h
804 +++ b/src/tslib-filter.h
805 @@ -38,6 +38,9 @@ struct tslib_module_info {
806 const struct tslib_ops *ops;
809 +typedef struct tslib_module_info *(*tslib_module_init)(struct tsdev *dev, const char *params);
810 +#define TSLIB_MODULE_INIT(f) TSAPI tslib_module_init mod_init = &f
812 TSAPI extern int tslib_parse_vars(struct tslib_module_info *,
813 const struct tslib_vars *, int,
814 const char *);