Merge lp:~binli/ubuntu/trusty/modemmanager/lp1441095 into lp:ubuntu/trusty/modemmanager

Proposed by Bin Li
Status: Superseded
Proposed branch: lp:~binli/ubuntu/trusty/modemmanager/lp1441095
Merge into: lp:ubuntu/trusty/modemmanager
Diff against target: 2001 lines (+1951/-0)
9 files modified
debian/changelog (+6/-0)
debian/patches/dell-mbim-plugin.patch (+566/-0)
debian/patches/mbm-common-library.patch (+49/-0)
debian/patches/new-sierra-legacy-plugin.patch (+295/-0)
debian/patches/novatel-common-library.patch (+51/-0)
debian/patches/novatel-custom-init.patch (+392/-0)
debian/patches/series (+7/-0)
debian/patches/sierra-common-library.patch (+54/-0)
debian/patches/sierra-custom-init.patch (+531/-0)
To merge this branch: bzr merge lp:~binli/ubuntu/trusty/modemmanager/lp1441095
Reviewer Review Type Date Requested Status
Bin Li (community) Needs Resubmitting
Ubuntu branches Pending
Review via email: mp+255935@code.launchpad.net

This proposal has been superseded by a proposal from 2015-09-23.

Description of the change

Support the MBIM for Dell.

dell-mbim-plugin.patch need novatel-custom-init.patch and sierra-custom-init.patch.

It built successfully, but not test it yet.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks but before doing a backport to trusty the issue should be fixed in wily...

Revision history for this message
Iain Lane (laney) wrote :

said on #ubuntu-desktop

02/09 11:56:37 <Laney> BinLi: hi, I hope you're the right BinLi. Can you look to fix wily for https://code.launchpad.net/~binli/ubuntu/trusty/modemmanager/lp1441095/+merge/255935 per seb128's
                       comment please?
02/09 11:57:45 <Laney> If it's cherry-picks from upstream this can probably go via Debian and maybe cyphermox can help you there

-> Work In Progress - please reset to Needs Review once this is done. Also could you merge the two changelog entries into one please?

Revision history for this message
Bin Li (binli) wrote :

Iain & seb128,

 Thanks for your reply, this week is holiday in China, I will update it next week.

Revision history for this message
Bin Li (binli) wrote :

@Iain, @Seb128,

 In trusty, I have finished the patches, I separated the previous patches based on the upstream commit, I merged these together for convenient in first version, I back-ported modemmanager from master branch(1.5) to trusty(1.0), some data structure was changed which I have updated in the backported patches.

 For Wily, we need to backport these patch from master branch(1.5) to 1.4 which is used by wily, I'm still working on it.

 And yes, if it could be cherry-picks from upstream(1.5) to 1.4, it's the best way, could we let cyphermox to help us? Thanks!

Revision history for this message
Bin Li (binli) wrote :

@Iain, @Seb128,

 I have done for trusty and wily. Thanks!

review: Needs Resubmitting
Revision history for this message
Bin Li (binli) wrote :

Sorry, I just resubmit it to change the status

43. By Bin Li

 * Support the MBIM for Dell. (LP: #1441095)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-02-25 16:12:24 +0000
+++ debian/changelog 2015-09-23 03:12:22 +0000
@@ -1,3 +1,9 @@
1modemmanager (1.0.0-2ubuntu1.1) trusty; urgency=medium
2
3 * Support the MBIM for Dell. (LP: #1441943)
4
5 -- Bin Li <bin.li@canonical.com> Mon, 13 Apr 2015 16:01:58 +0800
6
1modemmanager (1.0.0-2ubuntu1) trusty; urgency=medium7modemmanager (1.0.0-2ubuntu1) trusty; urgency=medium
28
3 * debian/rules: Work around build failure with -O3 by dropping to -O2.9 * debian/rules: Work around build failure with -O3 by dropping to -O2.
410
=== added file 'debian/patches/dell-mbim-plugin.patch'
--- debian/patches/dell-mbim-plugin.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/dell-mbim-plugin.patch 2015-09-23 03:12:22 +0000
@@ -0,0 +1,566 @@
1## Description: new Dell plugin which is backported from develop branch(1.5.x) to 1.0
2## Origin/Author: Aleksander Morgado <aleksander@lanedo.com>
3## Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/trusty/+source/modemmanager/+bug/1441095
4## Source: http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=93d6e4f102da51e72ecd2fbfcfa096cd2fd2e02e
5commit 93d6e4f102da51e72ecd2fbfcfa096cd2fd2e02e
6Author: Aleksander Morgado <aleksander@aleksander.es>
7Date: Fri Feb 6 16:35:52 2015 +0100
8
9 dell: new Dell plugin
10
11 For Dell-branded Novatel, Sierra and Ericsson modems.
12
13 The Novatel plugin will no longer accept every Dell-branded modem, which was
14 the current situation. Instead, a new Dell plugin will take care of probing for
15 the correct vendor string, and based on the results create a specific Novatel,
16 Sierra or Ericsson modem.
17
18 In order to properly support this, the Novatel, Sierra and MBM plugins now
19 export their implementations into non-inst libraries that the Dell plugin will
20 import.
21
22 Also, for now, the Dell plugin doesn't make any difference between e.g. Sierra
23 or Ericsson MBIM implementations, just a generic MBIM modem is created in both
24 cases, as that is anyway what the Ericsson MBM and Sierra plugins do already.
25
26 https://bugs.freedesktop.org/show_bug.cgi?id=86713
27
28=== modified file 'plugins/Makefile.am'
29Index: modemmanager/plugins/Makefile.am
30===================================================================
31--- modemmanager.orig/plugins/Makefile.am
32+++ modemmanager/plugins/Makefile.am
33@@ -61,6 +61,7 @@ pkglib_LTLIBRARIES = \
34 libmm-plugin-motorola.la \
35 libmm-plugin-novatel.la \
36 libmm-plugin-novatel-lte.la \
37+ libmm-plugin-dell.la \
38 libmm-plugin-altair-lte.la \
39 libmm-plugin-samsung.la \
40 libmm-plugin-option.la \
41@@ -381,6 +382,14 @@ libmm_plugin_novatel_la_CPPFLAGS = $(PLU
42 libmm_plugin_novatel_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
43 libmm_plugin_novatel_la_LIBADD = $(NOVATEL_COMMON_LIBADD_FLAGS)
44
45+# Dell (e.g. Novatel or Sierra) modem
46+libmm_plugin_dell_la_SOURCES = \
47+ dell/mm-plugin-dell.c \
48+ dell/mm-plugin-dell.h
49+libmm_plugin_dell_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(NOVATEL_COMMON_COMPILER_FLAGS) $(SIERRA_COMMON_COMPILER_FLAGS) $(MBM_COMMON_COMPILER_FLAGS)
50+libmm_plugin_dell_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
51+libmm_plugin_dell_la_LIBADD = $(NOVATEL_COMMON_LIBADD_FLAGS) $(SIERRA_COMMON_LIBADD_FLAGS) $(MBM_COMMON_LIBADD_FLAGS)
52+
53 # Altair LTE modem
54 libmm_plugin_altair_lte_la_SOURCES = \
55 altair/mm-plugin-altair-lte.c \
56Index: modemmanager/plugins/dell/mm-plugin-dell.c
57===================================================================
58--- /dev/null
59+++ modemmanager/plugins/dell/mm-plugin-dell.c
60@@ -0,0 +1,440 @@
61+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
62+
63+/*
64+ * This program is free software; you can redistribute it and/or
65+ * modify it under the terms of the GNU General Public License as
66+ * published by the Free Software Foundation; either version 2 of the
67+ * License, or (at your option) any later version.
68+ *
69+ * This program is distributed in the hope that it will be useful,
70+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
71+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
72+ * General Public License for more details.
73+ *
74+ * You should have received a copy of the GNU General Public
75+ * License along with this program; if not, write to the
76+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
77+ * Boston, MA 02111-1307, USA.
78+ *
79+ * Copyright (C) 2015 Aleksander Morgado <aleksander@aleksander.es>
80+ */
81+
82+#include <string.h>
83+#include <gmodule.h>
84+
85+#define _LIBMM_INSIDE_MM
86+#include <libmm-glib.h>
87+
88+#include "mm-plugin-dell.h"
89+#include "mm-common-novatel.h"
90+#include "mm-private-boxed-types.h"
91+#include "mm-broadband-modem.h"
92+#include "mm-broadband-modem-novatel.h"
93+#include "mm-common-novatel.h"
94+#include "mm-broadband-modem-sierra.h"
95+#include "mm-common-sierra.h"
96+#include "mm-log.h"
97+
98+#if defined WITH_QMI
99+#include "mm-broadband-modem-qmi.h"
100+#endif
101+
102+#if defined WITH_MBIM
103+#include "mm-broadband-modem-mbim.h"
104+#endif
105+
106+G_DEFINE_TYPE (MMPluginDell, mm_plugin_dell, MM_TYPE_PLUGIN)
107+
108+int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
109+int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
110+
111+#define TAG_DELL_MANUFACTURER "dell-manufacturer"
112+typedef enum {
113+ DELL_MANUFACTURER_UNKNOWN = 0,
114+ DELL_MANUFACTURER_NOVATEL = 1,
115+ DELL_MANUFACTURER_SIERRA = 2,
116+ DELL_MANUFACTURER_ERICSSON = 3
117+} DellManufacturer;
118+
119+/*****************************************************************************/
120+/* Custom init */
121+
122+typedef struct {
123+ MMPortProbe *probe;
124+ MMAtSerialPort *port;
125+ GCancellable *cancellable;
126+ GSimpleAsyncResult *result;
127+ guint gmi_retries;
128+ guint cgmi_retries;
129+ guint ati_retries;
130+} CustomInitContext;
131+
132+static void
133+custom_init_context_complete_and_free (CustomInitContext *ctx)
134+{
135+ g_simple_async_result_complete_in_idle (ctx->result);
136+
137+ if (ctx->cancellable)
138+ g_object_unref (ctx->cancellable);
139+ g_object_unref (ctx->port);
140+ g_object_unref (ctx->probe);
141+ g_object_unref (ctx->result);
142+ g_slice_free (CustomInitContext, ctx);
143+}
144+
145+static gboolean
146+dell_custom_init_finish (MMPortProbe *probe,
147+ GAsyncResult *result,
148+ GError **error)
149+{
150+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
151+}
152+
153+static void
154+novatel_custom_init_ready (MMPortProbe *probe,
155+ GAsyncResult *res,
156+ CustomInitContext *ctx)
157+{
158+ GError *error = NULL;
159+
160+ if (!mm_common_novatel_custom_init_finish (probe, res, &error))
161+ g_simple_async_result_take_error (ctx->result, error);
162+ else
163+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
164+ custom_init_context_complete_and_free (ctx);
165+}
166+
167+static void
168+sierra_custom_init_ready (MMPortProbe *probe,
169+ GAsyncResult *res,
170+ CustomInitContext *ctx)
171+{
172+ GError *error = NULL;
173+
174+ if (!mm_common_sierra_custom_init_finish (probe, res, &error))
175+ g_simple_async_result_take_error (ctx->result, error);
176+ else
177+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
178+ custom_init_context_complete_and_free (ctx);
179+}
180+
181+static void custom_init_step (CustomInitContext *ctx);
182+
183+static void
184+custom_init_step_next_command (CustomInitContext *ctx)
185+{
186+ if (ctx->gmi_retries > 0)
187+ ctx->gmi_retries = 0;
188+ else if (ctx->cgmi_retries > 0)
189+ ctx->cgmi_retries = 0;
190+ else if (ctx->ati_retries > 0)
191+ ctx->ati_retries = 0;
192+ custom_init_step (ctx);
193+}
194+
195+static void
196+response_ready (MMAtSerialPort *port,
197+ GString *response,
198+ GError *error,
199+ CustomInitContext *ctx)
200+{
201+ GString *lower;
202+ DellManufacturer manufacturer;
203+
204+ if (error) {
205+ /* Non-timeout error, jump to next command */
206+ if (!g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
207+ mm_dbg ("(Dell) Error probing AT port: %s", error->message);
208+ custom_init_step_next_command (ctx);
209+ return;
210+ }
211+ /* Directly retry same command on timeout */
212+ custom_init_step (ctx);
213+ return;
214+ }
215+
216+ /* Guess manufacturer from response */
217+ lower = g_string_ascii_down (response);
218+ if (strstr (lower->str, "novatel"))
219+ manufacturer = DELL_MANUFACTURER_NOVATEL;
220+ else if (strstr (lower->str, "sierra"))
221+ manufacturer = DELL_MANUFACTURER_SIERRA;
222+ else if (strstr (lower->str, "ericsson"))
223+ manufacturer = DELL_MANUFACTURER_ERICSSON;
224+ else
225+ manufacturer = DELL_MANUFACTURER_UNKNOWN;
226+ g_free (lower);
227+
228+ /* Tag based on manufacturer */
229+ if (manufacturer != DELL_MANUFACTURER_UNKNOWN) {
230+ g_object_set_data (G_OBJECT (ctx->probe), TAG_DELL_MANUFACTURER, GUINT_TO_POINTER (manufacturer));
231+
232+ /* Run additional custom init, if needed */
233+
234+ if (manufacturer == DELL_MANUFACTURER_NOVATEL) {
235+ mm_common_novatel_custom_init (ctx->probe,
236+ ctx->port,
237+ ctx->cancellable,
238+ (GAsyncReadyCallback) novatel_custom_init_ready,
239+ ctx);
240+ return;
241+ }
242+
243+ if (manufacturer == DELL_MANUFACTURER_SIERRA) {
244+ mm_common_sierra_custom_init (ctx->probe,
245+ ctx->port,
246+ ctx->cancellable,
247+ (GAsyncReadyCallback) sierra_custom_init_ready,
248+ ctx);
249+ return;
250+ }
251+
252+ /* Finish custom_init */
253+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
254+ custom_init_context_complete_and_free (ctx);
255+ return;
256+ }
257+
258+ /* If we got a response, but we didn't get an expected string, try with next command */
259+ custom_init_step_next_command (ctx);
260+}
261+
262+static void
263+custom_init_step (CustomInitContext *ctx)
264+{
265+ /* If cancelled, end */
266+ if (g_cancellable_is_cancelled (ctx->cancellable)) {
267+ mm_dbg ("(Dell) no need to keep on running custom init in (%s)",
268+ mm_port_get_device (MM_PORT (ctx->port)));
269+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
270+ custom_init_context_complete_and_free (ctx);
271+ return;
272+ }
273+
274+#if defined WITH_QMI
275+ /* If device has a QMI port, don't run anything else, as we don't care */
276+ if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list (mm_port_probe_peek_device (ctx->probe)))) {
277+ mm_dbg ("(Dell) no need to run custom init in (%s): device has QMI port",
278+ mm_port_get_device (MM_PORT (ctx->port)));
279+ mm_port_probe_set_result_at (ctx->probe, FALSE);
280+ mm_port_probe_set_result_qcdm (ctx->probe, FALSE);
281+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
282+ custom_init_context_complete_and_free (ctx);
283+ return;
284+ }
285+#endif
286+
287+#if defined WITH_MBIM
288+ /* If device has a MBIM port, don't run anything else, as we don't care */
289+ if (mm_port_probe_list_has_mbim_port (mm_device_peek_port_probe_list (mm_port_probe_peek_device (ctx->probe)))) {
290+ mm_dbg ("(Dell) no need to run custom init in (%s): device has MBIM port",
291+ mm_port_get_device (MM_PORT (ctx->port)));
292+ mm_port_probe_set_result_at (ctx->probe, FALSE);
293+ mm_port_probe_set_result_qcdm (ctx->probe, FALSE);
294+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
295+ custom_init_context_complete_and_free (ctx);
296+ return;
297+ }
298+#endif
299+
300+ if (ctx->gmi_retries > 0) {
301+ ctx->gmi_retries--;
302+ mm_at_serial_port_queue_command (ctx->port,
303+ "AT+GMI",
304+ 3,
305+ FALSE, /* raw */
306+ ctx->cancellable,
307+ (MMAtSerialResponseFn)response_ready,
308+ ctx);
309+ return;
310+ }
311+
312+ if (ctx->cgmi_retries > 0) {
313+ ctx->cgmi_retries--;
314+ mm_at_serial_port_queue_command (ctx->port,
315+ "AT+CGMI",
316+ 3,
317+ FALSE, /* raw */
318+ ctx->cancellable,
319+ (MMAtSerialResponseFn)response_ready,
320+ ctx);
321+ return;
322+ }
323+
324+ if (ctx->ati_retries > 0) {
325+ ctx->ati_retries--;
326+ /* Note: in Ericsson devices, ATI3 seems to reply the vendor string */
327+ mm_at_serial_port_queue_command (ctx->port,
328+ "ATI1I2I3",
329+ 3,
330+ FALSE, /* raw */
331+ ctx->cancellable,
332+ (MMAtSerialResponseFn)response_ready,
333+ ctx);
334+ return;
335+ }
336+
337+ /* Finish custom_init */
338+ mm_dbg ("(Dell) couldn't flip secondary port to AT in (%s): all retries consumed",
339+ mm_port_get_device (MM_PORT (ctx->port)));
340+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
341+ custom_init_context_complete_and_free (ctx);
342+}
343+
344+static void
345+dell_custom_init (MMPortProbe *probe,
346+ MMAtSerialPort *port,
347+ GCancellable *cancellable,
348+ GAsyncReadyCallback callback,
349+ gpointer user_data)
350+{
351+ CustomInitContext *ctx;
352+
353+ ctx = g_slice_new (CustomInitContext);
354+ ctx->result = g_simple_async_result_new (G_OBJECT (probe),
355+ callback,
356+ user_data,
357+ dell_custom_init);
358+ ctx->probe = g_object_ref (probe);
359+ ctx->port = g_object_ref (port);
360+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
361+ ctx->gmi_retries = 3;
362+ ctx->ati_retries = 3;
363+
364+ custom_init_step (ctx);
365+}
366+
367+/*****************************************************************************/
368+
369+static gboolean
370+port_probe_list_has_manufacturer_port (GList *probes,
371+ DellManufacturer manufacturer)
372+{
373+ GList *l;
374+
375+ for (l = probes; l; l = g_list_next (l)) {
376+ if (GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (l->data), TAG_DELL_MANUFACTURER)) == manufacturer)
377+ return TRUE;
378+ }
379+ return FALSE;
380+}
381+
382+static MMBaseModem *
383+create_modem (MMPlugin *self,
384+ const gchar *sysfs_path,
385+ const gchar **drivers,
386+ guint16 vendor,
387+ guint16 product,
388+ GList *probes,
389+ GError **error)
390+{
391+ /* Note: at this point we don't make any difference between different
392+ * Dell-branded QMI or MBIM modems; they may come from Novatel, Ericsson or
393+ * Sierra. */
394+
395+#if defined WITH_QMI
396+ if (mm_port_probe_list_has_qmi_port (probes)) {
397+ mm_dbg ("QMI-powered Dell-branded modem found...");
398+ return MM_BASE_MODEM (mm_broadband_modem_qmi_new (sysfs_path,
399+ drivers,
400+ mm_plugin_get_name (self),
401+ vendor,
402+ product));
403+ }
404+#endif
405+
406+#if defined WITH_MBIM
407+ if (mm_port_probe_list_has_mbim_port (probes)) {
408+ mm_dbg ("MBIM-powered Dell-branded modem found...");
409+ return MM_BASE_MODEM (mm_broadband_modem_mbim_new (sysfs_path,
410+ drivers,
411+ mm_plugin_get_name (self),
412+ vendor,
413+ product));
414+ }
415+#endif
416+
417+ if (port_probe_list_has_manufacturer_port (probes, DELL_MANUFACTURER_NOVATEL)) {
418+ mm_dbg ("Novatel-powered Dell-branded modem found...");
419+ return MM_BASE_MODEM (mm_broadband_modem_novatel_new (sysfs_path,
420+ drivers,
421+ mm_plugin_get_name (self),
422+ vendor,
423+ product));
424+ }
425+
426+ if (port_probe_list_has_manufacturer_port (probes, DELL_MANUFACTURER_SIERRA)) {
427+ mm_dbg ("Sierra-powered Dell-branded modem found...");
428+ return MM_BASE_MODEM (mm_broadband_modem_sierra_new (sysfs_path,
429+ drivers,
430+ mm_plugin_get_name (self),
431+ vendor,
432+ product));
433+ }
434+
435+ mm_dbg ("Dell-branded generic modem found...");
436+ return MM_BASE_MODEM (mm_broadband_modem_new (sysfs_path,
437+ drivers,
438+ mm_plugin_get_name (self),
439+ vendor,
440+ product));
441+}
442+
443+/*****************************************************************************/
444+
445+static gboolean
446+grab_port (MMPlugin *self,
447+ MMBaseModem *modem,
448+ MMPortProbe *probe,
449+ GError **error)
450+{
451+ /* Only Sierra needs custom grab port, due to the port type hints */
452+ if (MM_IS_BROADBAND_MODEM_SIERRA (modem))
453+ return mm_common_sierra_grab_port (self, modem, probe, error);
454+
455+ return mm_base_modem_grab_port (modem,
456+ mm_port_probe_get_port_subsys (probe),
457+ mm_port_probe_get_port_name (probe),
458+ mm_port_probe_get_port_type (probe),
459+ MM_AT_PORT_FLAG_NONE,
460+ error);
461+}
462+
463+/*****************************************************************************/
464+
465+G_MODULE_EXPORT MMPlugin *
466+mm_plugin_create (void)
467+{
468+ static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
469+ static const guint16 vendors[] = { 0x413c, 0 };
470+ static const MMAsyncMethod custom_init = {
471+ .async = G_CALLBACK (dell_custom_init),
472+ .finish = G_CALLBACK (dell_custom_init_finish),
473+ };
474+
475+ return MM_PLUGIN (
476+ g_object_new (MM_TYPE_PLUGIN_DELL,
477+ MM_PLUGIN_NAME, "Dell",
478+ MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
479+ MM_PLUGIN_ALLOWED_VENDOR_IDS, vendors,
480+ MM_PLUGIN_ALLOWED_AT, TRUE,
481+ MM_PLUGIN_CUSTOM_INIT, &custom_init,
482+ MM_PLUGIN_ALLOWED_QCDM, TRUE,
483+ MM_PLUGIN_ALLOWED_QMI, TRUE,
484+ MM_PLUGIN_ALLOWED_MBIM, TRUE,
485+ NULL));
486+}
487+
488+static void
489+mm_plugin_dell_init (MMPluginDell *self)
490+{
491+}
492+
493+static void
494+mm_plugin_dell_class_init (MMPluginDellClass *klass)
495+{
496+ MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
497+
498+ plugin_class->create_modem = create_modem;
499+ plugin_class->grab_port = grab_port;
500+}
501Index: modemmanager/plugins/dell/mm-plugin-dell.h
502===================================================================
503--- /dev/null
504+++ modemmanager/plugins/dell/mm-plugin-dell.h
505@@ -0,0 +1,46 @@
506+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
507+
508+/*
509+ * This program is free software; you can redistribute it and/or
510+ * modify it under the terms of the GNU General Public License as
511+ * published by the Free Software Foundation; either version 2 of the
512+ * License, or (at your option) any later version.
513+ *
514+ * This program is distributed in the hope that it will be useful,
515+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
516+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
517+ * General Public License for more details.
518+ *
519+ * You should have received a copy of the GNU General Public
520+ * License along with this program; if not, write to the
521+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
522+ * Boston, MA 02111-1307, USA.
523+ *
524+ * Copyright (C) 2015 Aleksander Morgado <aleksander@aleksander.es>
525+ */
526+
527+#ifndef MM_PLUGIN_DELL_H
528+#define MM_PLUGIN_DELL_H
529+
530+#include "mm-plugin.h"
531+
532+#define MM_TYPE_PLUGIN_DELL (mm_plugin_dell_get_type ())
533+#define MM_PLUGIN_DELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_DELL, MMPluginDell))
534+#define MM_PLUGIN_DELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_DELL, MMPluginDellClass))
535+#define MM_IS_PLUGIN_DELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_DELL))
536+#define MM_IS_PLUGIN_DELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_DELL))
537+#define MM_PLUGIN_DELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_DELL, MMPluginDellClass))
538+
539+typedef struct {
540+ MMPlugin parent;
541+} MMPluginDell;
542+
543+typedef struct {
544+ MMPluginClass parent;
545+} MMPluginDellClass;
546+
547+GType mm_plugin_dell_get_type (void);
548+
549+G_MODULE_EXPORT MMPlugin *mm_plugin_create (void);
550+
551+#endif /* MM_PLUGIN_DELL_H */
552Index: modemmanager/plugins/novatel/mm-plugin-novatel.c
553===================================================================
554--- modemmanager.orig/plugins/novatel/mm-plugin-novatel.c
555+++ modemmanager/plugins/novatel/mm-plugin-novatel.c
556@@ -90,9 +90,7 @@ G_MODULE_EXPORT MMPlugin *
557 mm_plugin_create (void)
558 {
559 static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
560- static const guint16 vendors[] = { 0x1410, /* Novatel */
561- 0x413c, /* Dell */
562- 0 };
563+ static const guint16 vendors[] = { 0x1410, 0 };
564 static const mm_uint16_pair forbidden_products[] = { { 0x1410, 0x9010 }, /* Novatel E362 */
565 { 0, 0 } };
566 static const MMAsyncMethod custom_init = {
0567
=== added file 'debian/patches/mbm-common-library.patch'
--- debian/patches/mbm-common-library.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/mbm-common-library.patch 2015-09-23 03:12:22 +0000
@@ -0,0 +1,49 @@
1## Description: mbm common library which is backported from develop branch(1.5.x) to 1.0
2## Origin/Author: Aleksander Morgado <aleksander@lanedo.com>
3## Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/trusty/+source/modemmanager/+bug/1441095
4## Source: http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=5a268430c4c89e21d977403ec764c59b86498af8
5commit 5a268430c4c89e21d977403ec764c59b86498af8
6Author: Aleksander Morgado <aleksander@aleksander.es>
7Date: Fri Feb 6 17:11:52 2015 +0100
8
9 mbm: build a common non-inst library with the core Ericsson modem support
10
11Index: modemmanager/plugins/Makefile.am
12===================================================================
13--- modemmanager.orig/plugins/Makefile.am
14+++ modemmanager/plugins/Makefile.am
15@@ -130,18 +130,29 @@ test_modem_helpers_huawei_CPPFLAGS = \
16 test_modem_helpers_huawei_LDFLAGS = $(MM_LIBS) $(top_builddir)/libmm-glib/libmm-glib.la
17
18
19-# MBM
20-libmm_plugin_mbm_la_SOURCES = \
21- mbm/mm-plugin-mbm.c \
22- mbm/mm-plugin-mbm.h \
23+# Common Mbm modem support library
24+noinst_LTLIBRARIES += libmm-utils-mbm.la
25+libmm_utils_mbm_la_SOURCES = \
26 mbm/mm-broadband-modem-mbm.c \
27 mbm/mm-broadband-modem-mbm.h \
28 mbm/mm-broadband-bearer-mbm.c \
29 mbm/mm-broadband-bearer-mbm.h \
30 mbm/mm-sim-mbm.c \
31 mbm/mm-sim-mbm.h
32-libmm_plugin_mbm_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
33+libmm_utils_mbm_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
34+libmm_utils_mbm_la_LIBADD = $(GUDEV_LIBS) $(MM_LIBS)
35+
36+MBM_COMMON_COMPILER_FLAGS = -I$(top_srcdir)/plugins/mbm
37+MBM_COMMON_LIBADD_FLAGS = $(builddir)/libmm-utils-mbm.la
38+
39+# MBM
40+libmm_plugin_mbm_la_SOURCES = \
41+ mbm/mm-plugin-mbm.c \
42+ mbm/mm-plugin-mbm.h
43+libmm_plugin_mbm_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(MBM_COMMON_COMPILER_FLAGS)
44 libmm_plugin_mbm_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
45+libmm_plugin_mbm_la_LIBADD = $(MBM_COMMON_LIBADD_FLAGS)
46+
47 udevrules_DATA += mbm/77-mm-ericsson-mbm.rules
48
49 # Option
050
=== added file 'debian/patches/new-sierra-legacy-plugin.patch'
--- debian/patches/new-sierra-legacy-plugin.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/new-sierra-legacy-plugin.patch 2015-09-23 03:12:22 +0000
@@ -0,0 +1,295 @@
1## Description: new 'sierra-legacy' plugin which is backported from develop branch(1.5.x) to 1.0
2## Origin/Author: Aleksander Morgado <aleksander@lanedo.com>
3## Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/trusty/+source/modemmanager/+bug/1441095
4## Source: http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=6bbc4c1746c9e7c48e12dcb1e1986f1e16327161
5commit 6bbc4c1746c9e7c48e12dcb1e1986f1e16327161
6Author: Aleksander Morgado <aleksander@aleksander.es>
7Date: Fri Feb 6 20:02:20 2015 +0100
8
9 sierra: move all the legacy Sierra support to a new 'sierra-legacy' plugin
10
11 In short:
12
13 * The 'sierra-legacy' plugin will handle all the old AT based modems,
14 including the DirectIP ones. This plugin is filtered by driver ('sierra' or
15 'sierra_net') and forbidden-drivers ('qmi_wwan' and 'cdc_mbim'). This plugin
16 should also grab HP and AT&T branded models if they are handled by the
17 proper kernel driver.
18
19 * The 'sierra' plugin will only handle QMI or MBIM based Sierra modems, which
20 are really all the new ones. This plugin is filtered by VID (0x1199) and
21 driver (qmi_wwan and cdc_mbim).
22
23 For this separation to work, the 'sierra' and 'sierra_net' plugins need to be
24 complementary to each other.
25
26Index: modemmanager/plugins/Makefile.am
27===================================================================
28--- modemmanager.orig/plugins/Makefile.am
29+++ modemmanager/plugins/Makefile.am
30@@ -75,6 +75,7 @@ pkglib_LTLIBRARIES = \
31 libmm-plugin-pantech.la \
32 libmm-plugin-zte.la \
33 libmm-plugin-sierra.la \
34+ libmm-plugin-sierra-legacy.la \
35 libmm-plugin-mbm.la \
36 libmm-plugin-via.la \
37 libmm-plugin-telit.la
38@@ -194,15 +195,22 @@ libmm_utils_sierra_la_LIBADD = $(GUDEV_L
39 SIERRA_COMMON_COMPILER_FLAGS = -I$(top_srcdir)/plugins/sierra
40 SIERRA_COMMON_LIBADD_FLAGS = $(builddir)/libmm-utils-sierra.la
41
42-# Sierra
43+# Sierra (new QMI or MBIM modems)
44 libmm_plugin_sierra_la_SOURCES = \
45 sierra/mm-plugin-sierra.c \
46- sierra/mm-plugin-sierra.h \
47+ sierra/mm-plugin-sierra.h
48+libmm_plugin_sierra_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
49+libmm_plugin_sierra_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
50+
51+# Sierra (legacy)
52+libmm_plugin_sierra_legacy_la_SOURCES = \
53+ sierra/mm-plugin-sierra-legacy.c \
54+ sierra/mm-plugin-sierra-legacy.h \
55 sierra/mm-broadband-modem-sierra-icera.c \
56 sierra/mm-broadband-modem-sierra-icera.h
57-libmm_plugin_sierra_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(ICERA_COMMON_COMPILER_FLAGS) $(SIERRA_COMMON_COMPILER_FLAGS)
58-libmm_plugin_sierra_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
59-libmm_plugin_sierra_la_LIBADD = $(ICERA_COMMON_LIBADD_FLAGS) $(SIERRA_COMMON_LIBADD_FLAGS)
60+libmm_plugin_sierra_legacy_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(ICERA_COMMON_COMPILER_FLAGS) $(SIERRA_COMMON_COMPILER_FLAGS)
61+libmm_plugin_sierra_legacy_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
62+libmm_plugin_sierra_legacy_la_LIBADD = $(ICERA_COMMON_LIBADD_FLAGS) $(SIERRA_COMMON_LIBADD_FLAGS)
63
64 # Wavecom (Sierra Airlink)
65 libmm_plugin_wavecom_la_SOURCES = \
66Index: modemmanager/plugins/sierra/mm-plugin-sierra-legacy.c
67===================================================================
68--- /dev/null
69+++ modemmanager/plugins/sierra/mm-plugin-sierra-legacy.c
70@@ -0,0 +1,99 @@
71+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
72+/*
73+ * This program is free software; you can redistribute it and/or modify
74+ * it under the terms of the GNU General Public License as published by
75+ * the Free Software Foundation; either version 2 of the License, or
76+ * (at your option) any later version.
77+ *
78+ * This program is distributed in the hope that it will be useful,
79+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
80+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81+ * GNU General Public License for more details:
82+ *
83+ * Copyright (C) 2008 - 2009 Novell, Inc.
84+ * Copyright (C) 2009 - 2012 Red Hat, Inc.
85+ * Copyright (C) 2012 Lanedo GmbH
86+ * Copyright (C) 2015 Aleksander Morgado <aleksander@aleksander.es>
87+ */
88+
89+#include <stdlib.h>
90+#include <gmodule.h>
91+
92+#define _LIBMM_INSIDE_MM
93+#include <libmm-glib.h>
94+
95+#include "mm-log.h"
96+#include "mm-plugin-sierra-legacy.h"
97+#include "mm-common-sierra.h"
98+#include "mm-broadband-modem-sierra.h"
99+#include "mm-broadband-modem-sierra-icera.h"
100+
101+G_DEFINE_TYPE (MMPluginSierraLegacy, mm_plugin_sierra_legacy, MM_TYPE_PLUGIN)
102+
103+int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
104+int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
105+
106+/*****************************************************************************/
107+
108+static MMBaseModem *
109+create_modem (MMPlugin *self,
110+ const gchar *sysfs_path,
111+ const gchar **drivers,
112+ guint16 vendor,
113+ guint16 product,
114+ GList *probes,
115+ GError **error)
116+{
117+ if (mm_common_sierra_port_probe_list_is_icera (probes))
118+ return MM_BASE_MODEM (mm_broadband_modem_sierra_icera_new (sysfs_path,
119+ drivers,
120+ mm_plugin_get_name (self),
121+ vendor,
122+ product));
123+
124+ return MM_BASE_MODEM (mm_broadband_modem_sierra_new (sysfs_path,
125+ drivers,
126+ mm_plugin_get_name (self),
127+ vendor,
128+ product));
129+}
130+
131+/*****************************************************************************/
132+
133+G_MODULE_EXPORT MMPlugin *
134+mm_plugin_create (void)
135+{
136+ static const gchar *subsystems[] = { "tty", "net", NULL };
137+ static const gchar *drivers[] = { "sierra", "sierra_net", NULL };
138+ static const gchar *forbidden_drivers[] = { "qmi_wwan", "cdc_mbim", NULL };
139+ static const MMAsyncMethod custom_init = {
140+ .async = G_CALLBACK (mm_common_sierra_custom_init),
141+ .finish = G_CALLBACK (mm_common_sierra_custom_init_finish),
142+ };
143+
144+ return MM_PLUGIN (
145+ g_object_new (MM_TYPE_PLUGIN_SIERRA_LEGACY,
146+ MM_PLUGIN_NAME, "Sierra (legacy)",
147+ MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
148+ MM_PLUGIN_ALLOWED_DRIVERS, drivers,
149+ MM_PLUGIN_FORBIDDEN_DRIVERS, forbidden_drivers,
150+ MM_PLUGIN_ALLOWED_AT, TRUE,
151+ MM_PLUGIN_CUSTOM_INIT, &custom_init,
152+ MM_PLUGIN_ICERA_PROBE, TRUE,
153+ MM_PLUGIN_REMOVE_ECHO, FALSE,
154+ NULL));
155+}
156+
157+static void
158+mm_plugin_sierra_legacy_init (MMPluginSierraLegacy *self)
159+{
160+}
161+
162+static void
163+mm_plugin_sierra_legacy_class_init (MMPluginSierraLegacyClass *klass)
164+{
165+ MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
166+
167+ plugin_class->create_modem = create_modem;
168+ plugin_class->grab_port = mm_common_sierra_grab_port;
169+}
170Index: modemmanager/plugins/sierra/mm-plugin-sierra-legacy.h
171===================================================================
172--- /dev/null
173+++ modemmanager/plugins/sierra/mm-plugin-sierra-legacy.h
174@@ -0,0 +1,40 @@
175+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
176+/*
177+ * This program is free software; you can redistribute it and/or modify
178+ * it under the terms of the GNU General Public License as published by
179+ * the Free Software Foundation; either version 2 of the License, or
180+ * (at your option) any later version.
181+ *
182+ * This program is distributed in the hope that it will be useful,
183+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
184+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
185+ * GNU General Public License for more details:
186+ *
187+ * Copyright (C) 2015 Aleksander Morgado <aleksander@aleksander.es>
188+ */
189+
190+#ifndef MM_PLUGIN_SIERRA_LEGACY_H
191+#define MM_PLUGIN_SIERRA_LEGACY_H
192+
193+#include "mm-plugin.h"
194+
195+#define MM_TYPE_PLUGIN_SIERRA_LEGACY (mm_plugin_sierra_legacy_get_type ())
196+#define MM_PLUGIN_SIERRA_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_SIERRA_LEGACY, MMPluginSierraLegacy))
197+#define MM_PLUGIN_SIERRA_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_SIERRA_LEGACY, MMPluginSierraLegacyClass))
198+#define MM_IS_PLUGIN_SIERRA_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_SIERRA_LEGACY))
199+#define MM_IS_PLUGIN_SIERRA_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_SIERRA_LEGACY))
200+#define MM_PLUGIN_SIERRA_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_SIERRA_LEGACY, MMPluginSierraLegacyClass))
201+
202+typedef struct {
203+ MMPlugin parent;
204+} MMPluginSierraLegacy;
205+
206+typedef struct {
207+ MMPluginClass parent;
208+} MMPluginSierraLegacyClass;
209+
210+GType mm_plugin_sierra_legacy_get_type (void);
211+
212+G_MODULE_EXPORT MMPlugin *mm_plugin_create (void);
213+
214+#endif /* MM_PLUGIN_SIERRA_LEGACY_H */
215Index: modemmanager/plugins/sierra/mm-plugin-sierra.c
216===================================================================
217--- modemmanager.orig/plugins/sierra/mm-plugin-sierra.c
218+++ modemmanager/plugins/sierra/mm-plugin-sierra.c
219@@ -13,6 +13,7 @@
220 * Copyright (C) 2008 - 2009 Novell, Inc.
221 * Copyright (C) 2009 - 2012 Red Hat, Inc.
222 * Copyright (C) 2012 Lanedo GmbH
223+ * Copyright (C) 2015 Aleksander Morgado <aleksander@aleksander.es>
224 */
225
226 #include <stdlib.h>
227@@ -23,9 +24,6 @@
228
229 #include "mm-log.h"
230 #include "mm-plugin-sierra.h"
231-#include "mm-common-sierra.h"
232-#include "mm-broadband-modem-sierra.h"
233-#include "mm-broadband-modem-sierra-icera.h"
234
235 #if defined WITH_QMI
236 #include "mm-broadband-modem-qmi.h"
237@@ -73,18 +71,12 @@ create_modem (MMPlugin *self,
238 }
239 #endif
240
241- if (mm_common_sierra_port_probe_list_is_icera (probes))
242- return MM_BASE_MODEM (mm_broadband_modem_sierra_icera_new (sysfs_path,
243- drivers,
244- mm_plugin_get_name (self),
245- vendor,
246- product));
247-
248- return MM_BASE_MODEM (mm_broadband_modem_sierra_new (sysfs_path,
249- drivers,
250- mm_plugin_get_name (self),
251- vendor,
252- product));
253+ /* Fallback to default modem in the worst case */
254+ return MM_BASE_MODEM (mm_broadband_modem_new (sysfs_path,
255+ drivers,
256+ mm_plugin_get_name (self),
257+ vendor,
258+ product));
259 }
260
261 /*****************************************************************************/
262@@ -93,24 +85,19 @@ G_MODULE_EXPORT MMPlugin *
263 mm_plugin_create (void)
264 {
265 static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
266- static const gchar *drivers[] = { "sierra", "sierra_net", NULL };
267- static const MMAsyncMethod custom_init = {
268- .async = G_CALLBACK (mm_common_sierra_custom_init),
269- .finish = G_CALLBACK (mm_common_sierra_custom_init_finish),
270- };
271+ static const guint16 vendor_ids[] = { 0x1199, 0 };
272+ static const gchar *drivers[] = { "qmi_wwan", "cdc_mbim", NULL };
273
274 return MM_PLUGIN (
275 g_object_new (MM_TYPE_PLUGIN_SIERRA,
276 MM_PLUGIN_NAME, "Sierra",
277 MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
278+ MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
279 MM_PLUGIN_ALLOWED_DRIVERS, drivers,
280 MM_PLUGIN_ALLOWED_AT, TRUE,
281 MM_PLUGIN_ALLOWED_QCDM, TRUE,
282 MM_PLUGIN_ALLOWED_QMI, TRUE,
283 MM_PLUGIN_ALLOWED_MBIM, TRUE,
284- MM_PLUGIN_CUSTOM_INIT, &custom_init,
285- MM_PLUGIN_ICERA_PROBE, TRUE,
286- MM_PLUGIN_REMOVE_ECHO, FALSE,
287 NULL));
288 }
289
290@@ -125,5 +112,4 @@ mm_plugin_sierra_class_init (MMPluginSie
291 MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
292
293 plugin_class->create_modem = create_modem;
294- plugin_class->grab_port = mm_common_sierra_grab_port;
295 }
0296
=== added file 'debian/patches/novatel-common-library.patch'
--- debian/patches/novatel-common-library.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/novatel-common-library.patch 2015-09-23 03:12:22 +0000
@@ -0,0 +1,51 @@
1## Description: novatel common library which is backported from develop branch(1.5.x) to 1.0
2## Origin/Author: Aleksander Morgado <aleksander@lanedo.com>
3## Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/trusty/+source/modemmanager/+bug/1441095
4## Source: http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=60a17df4c78d7bd9f27ca1425dba6c53298fd3d3
5commit 60a17df4c78d7bd9f27ca1425dba6c53298fd3d3
6Author: Aleksander Morgado <aleksander@aleksander.es>
7Date: Fri Feb 6 15:55:18 2015 +0100
8
9 novatel: build a common non-inst library with the core Novatel modem support
10
11Index: modemmanager/plugins/Makefile.am
12===================================================================
13--- modemmanager.orig/plugins/Makefile.am
14+++ modemmanager/plugins/Makefile.am
15@@ -319,6 +319,19 @@ libmm_plugin_iridium_la_SOURCES = \
16 libmm_plugin_iridium_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
17 libmm_plugin_iridium_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
18
19+# Common Novatel modem support library
20+noinst_LTLIBRARIES += libmm-utils-novatel.la
21+libmm_utils_novatel_la_SOURCES = \
22+ novatel/mm-common-novatel.c \
23+ novatel/mm-common-novatel.h \
24+ novatel/mm-broadband-modem-novatel.c \
25+ novatel/mm-broadband-modem-novatel.h
26+libmm_utils_novatel_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
27+libmm_utils_novatel_la_LIBADD = $(GUDEV_LIBS) $(MM_LIBS)
28+
29+NOVATEL_COMMON_COMPILER_FLAGS = -I$(top_srcdir)/plugins/novatel
30+NOVATEL_COMMON_LIBADD_FLAGS = $(builddir)/libmm-utils-novatel.la
31+
32 # Novatel LTE modem
33 libmm_plugin_novatel_lte_la_SOURCES = \
34 novatel/mm-plugin-novatel-lte.c \
35@@ -335,13 +348,10 @@ libmm_plugin_novatel_lte_la_LDFLAGS = $(
36 # Novatel non-LTE modem
37 libmm_plugin_novatel_la_SOURCES = \
38 novatel/mm-plugin-novatel.c \
39- novatel/mm-plugin-novatel.h \
40- novatel/mm-common-novatel.c \
41- novatel/mm-common-novatel.h \
42- novatel/mm-broadband-modem-novatel.c \
43- novatel/mm-broadband-modem-novatel.h
44-libmm_plugin_novatel_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
45+ novatel/mm-plugin-novatel.h
46+libmm_plugin_novatel_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(NOVATEL_COMMON_COMPILER_FLAGS)
47 libmm_plugin_novatel_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
48+libmm_plugin_novatel_la_LIBADD = $(NOVATEL_COMMON_LIBADD_FLAGS)
49
50 # Altair LTE modem
51 libmm_plugin_altair_lte_la_SOURCES = \
052
=== added file 'debian/patches/novatel-custom-init.patch'
--- debian/patches/novatel-custom-init.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/novatel-custom-init.patch 2015-09-23 03:12:22 +0000
@@ -0,0 +1,392 @@
1## Description: novatel custome init which is backported from develop branch(1.5.x) to 1.0
2## Origin/Author: Aleksander Morgado <aleksander@lanedo.com>
3## Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/trusty/+source/modemmanager/+bug/1441095
4## Source: http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=7c929b5cf19ca6fd3ed8c5667efc026df13046a1
5commit 7c929b5cf19ca6fd3ed8c5667efc026df13046a1
6Author: Aleksander Morgado <aleksander@aleksander.es>
7Date: Fri Feb 6 15:30:50 2015 +0100
8
9 novatel: move custom init method to separate source files
10
11Index: modemmanager/plugins/Makefile.am
12===================================================================
13--- modemmanager.orig/plugins/Makefile.am
14+++ modemmanager/plugins/Makefile.am
15@@ -336,6 +336,8 @@ libmm_plugin_novatel_lte_la_LDFLAGS = $(
16 libmm_plugin_novatel_la_SOURCES = \
17 novatel/mm-plugin-novatel.c \
18 novatel/mm-plugin-novatel.h \
19+ novatel/mm-common-novatel.c \
20+ novatel/mm-common-novatel.h \
21 novatel/mm-broadband-modem-novatel.c \
22 novatel/mm-broadband-modem-novatel.h
23 libmm_plugin_novatel_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
24Index: modemmanager/plugins/novatel/mm-common-novatel.c
25===================================================================
26--- /dev/null
27+++ modemmanager/plugins/novatel/mm-common-novatel.c
28@@ -0,0 +1,165 @@
29+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
30+/*
31+ * This program is free software; you can redistribute it and/or modify
32+ * it under the terms of the GNU General Public License as published by
33+ * the Free Software Foundation; either version 2 of the License, or
34+ * (at your option) any later version.
35+ *
36+ * This program is distributed in the hope that it will be useful,
37+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
38+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39+ * GNU General Public License for more details:
40+ *
41+ * Copyright (C) 2015 Aleksander Morgado <aleksander@aleksander.es>
42+ */
43+
44+#include "mm-common-novatel.h"
45+#include "mm-log.h"
46+
47+
48+/*****************************************************************************/
49+/* Custom commands for AT probing */
50+
51+
52+/* We need to explicitly flip secondary ports to AT mode.
53+ * We also use this command also for checking AT support in the current port.
54+ */
55+static const MMPortProbeAtCommand custom_at_probe[] = {
56+ { "$NWDMAT=1", 3, mm_port_probe_response_processor_is_at },
57+ { "$NWDMAT=1", 3, mm_port_probe_response_processor_is_at },
58+ { "$NWDMAT=1", 3, mm_port_probe_response_processor_is_at },
59+ { NULL }
60+};
61+
62+/*****************************************************************************/
63+/* Custom init */
64+
65+typedef struct {
66+ MMPortProbe *probe;
67+ MMAtSerialPort *port;
68+ GCancellable *cancellable;
69+ GSimpleAsyncResult *result;
70+ guint nwdmat_retries;
71+ guint wait_time;
72+} CustomInitContext;
73+
74+static void
75+custom_init_context_complete_and_free (CustomInitContext *ctx)
76+{
77+ g_simple_async_result_complete_in_idle (ctx->result);
78+
79+ if (ctx->cancellable)
80+ g_object_unref (ctx->cancellable);
81+ g_object_unref (ctx->port);
82+ g_object_unref (ctx->probe);
83+ g_object_unref (ctx->result);
84+ g_slice_free (CustomInitContext, ctx);
85+}
86+
87+gboolean
88+mm_common_novatel_custom_init_finish (MMPortProbe *probe,
89+ GAsyncResult *result,
90+ GError **error)
91+{
92+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
93+}
94+
95+static void custom_init_step (CustomInitContext *ctx);
96+
97+static void
98+nwdmat_ready (MMAtSerialPort *port,
99+ GString *response,
100+ GError *error,
101+ CustomInitContext *ctx)
102+{
103+ if (error) {
104+ if (g_error_matches (error,
105+ MM_SERIAL_ERROR,
106+ MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
107+ custom_init_step (ctx);
108+ return;
109+ }
110+
111+ mm_dbg ("(Novatel) Error flipping secondary ports to AT mode: %s", error->message);
112+ }
113+
114+ /* Finish custom_init */
115+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
116+ custom_init_context_complete_and_free (ctx);
117+}
118+
119+static gboolean
120+custom_init_wait_cb (CustomInitContext *ctx)
121+{
122+ custom_init_step (ctx);
123+ return FALSE;
124+}
125+
126+static void
127+custom_init_step (CustomInitContext *ctx)
128+{
129+ /* If cancelled, end */
130+ if (g_cancellable_is_cancelled (ctx->cancellable)) {
131+ mm_dbg ("(Novatel) no need to keep on running custom init in (%s)",
132+ mm_port_get_device (MM_PORT (ctx->port)));
133+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
134+ custom_init_context_complete_and_free (ctx);
135+ return;
136+ }
137+
138+ /* If device has a QMI port, don't run $NWDMAT */
139+ if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list (mm_port_probe_peek_device (ctx->probe)))) {
140+ mm_dbg ("(Novatel) no need to run custom init in (%s): device has QMI port",
141+ mm_port_get_device (MM_PORT (ctx->port)));
142+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
143+ custom_init_context_complete_and_free (ctx);
144+ return;
145+ }
146+
147+ if (ctx->wait_time > 0) {
148+ ctx->wait_time--;
149+ g_timeout_add_seconds (1, (GSourceFunc)custom_init_wait_cb, ctx);
150+ return;
151+ }
152+
153+ if (ctx->nwdmat_retries > 0) {
154+ ctx->nwdmat_retries--;
155+ mm_at_serial_port_queue_command (ctx->port,
156+ "$NWDMAT=1",
157+ 3,
158+ FALSE, /* raw */
159+ ctx->cancellable,
160+ (MMAtSerialResponseFn)nwdmat_ready,
161+ ctx);
162+ return;
163+ }
164+
165+ /* Finish custom_init */
166+ mm_dbg ("(Novatel) couldn't flip secondary port to AT in (%s): all retries consumed",
167+ mm_port_get_device (MM_PORT (ctx->port)));
168+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
169+ custom_init_context_complete_and_free (ctx);
170+}
171+
172+void
173+mm_common_novatel_custom_init (MMPortProbe *probe,
174+ MMAtSerialPort *port,
175+ GCancellable *cancellable,
176+ GAsyncReadyCallback callback,
177+ gpointer user_data)
178+{
179+ CustomInitContext *ctx;
180+
181+ ctx = g_slice_new (CustomInitContext);
182+ ctx->result = g_simple_async_result_new (G_OBJECT (probe),
183+ callback,
184+ user_data,
185+ mm_common_novatel_custom_init);
186+ ctx->probe = g_object_ref (probe);
187+ ctx->port = g_object_ref (port);
188+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
189+ ctx->nwdmat_retries = 3;
190+ ctx->wait_time = 2;
191+
192+ custom_init_step (ctx);
193+}
194Index: modemmanager/plugins/novatel/mm-common-novatel.h
195===================================================================
196--- /dev/null
197+++ modemmanager/plugins/novatel/mm-common-novatel.h
198@@ -0,0 +1,31 @@
199+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
200+/*
201+ * This program is free software; you can redistribute it and/or modify
202+ * it under the terms of the GNU General Public License as published by
203+ * the Free Software Foundation; either version 2 of the License, or
204+ * (at your option) any later version.
205+ *
206+ * This program is distributed in the hope that it will be useful,
207+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
208+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
209+ * GNU General Public License for more details:
210+ *
211+ * Copyright (C) 2015 Aleksander Morgado <aleksander@aleksander.es>
212+ */
213+
214+#ifndef MM_COMMON_NOVATEL_H
215+#define MM_COMMON_NOVATEL_H
216+
217+#include "glib.h"
218+#include "mm-plugin.h"
219+
220+void mm_common_novatel_custom_init (MMPortProbe *probe,
221+ MMAtSerialPort *port,
222+ GCancellable *cancellable,
223+ GAsyncReadyCallback callback,
224+ gpointer user_data);
225+gboolean mm_common_novatel_custom_init_finish (MMPortProbe *probe,
226+ GAsyncResult *result,
227+ GError **error);
228+
229+#endif /* MM_COMMON_NOVATEL_H */
230Index: modemmanager/plugins/novatel/mm-plugin-novatel.c
231===================================================================
232--- modemmanager.orig/plugins/novatel/mm-plugin-novatel.c
233+++ modemmanager/plugins/novatel/mm-plugin-novatel.c
234@@ -28,6 +28,7 @@
235 #include <libmm-glib.h>
236
237 #include "mm-plugin-novatel.h"
238+#include "mm-common-novatel.h"
239 #include "mm-private-boxed-types.h"
240 #include "mm-broadband-modem-novatel.h"
241 #include "mm-log.h"
242@@ -55,139 +56,6 @@ static const MMPortProbeAtCommand custom
243 };
244
245 /*****************************************************************************/
246-/* Custom init */
247-
248-typedef struct {
249- MMPortProbe *probe;
250- MMAtSerialPort *port;
251- GCancellable *cancellable;
252- GSimpleAsyncResult *result;
253- guint nwdmat_retries;
254- guint wait_time;
255-} CustomInitContext;
256-
257-static void
258-custom_init_context_complete_and_free (CustomInitContext *ctx)
259-{
260- g_simple_async_result_complete_in_idle (ctx->result);
261-
262- if (ctx->cancellable)
263- g_object_unref (ctx->cancellable);
264- g_object_unref (ctx->port);
265- g_object_unref (ctx->probe);
266- g_object_unref (ctx->result);
267- g_slice_free (CustomInitContext, ctx);
268-}
269-
270-static gboolean
271-novatel_custom_init_finish (MMPortProbe *probe,
272- GAsyncResult *result,
273- GError **error)
274-{
275- return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
276-}
277-
278-static void custom_init_step (CustomInitContext *ctx);
279-
280-static void
281-nwdmat_ready (MMAtSerialPort *port,
282- GString *response,
283- GError *error,
284- CustomInitContext *ctx)
285-{
286- if (error) {
287- if (g_error_matches (error,
288- MM_SERIAL_ERROR,
289- MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
290- custom_init_step (ctx);
291- return;
292- }
293-
294- mm_dbg ("(Novatel) Error flipping secondary ports to AT mode: %s", error->message);
295- }
296-
297- /* Finish custom_init */
298- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
299- custom_init_context_complete_and_free (ctx);
300-}
301-
302-static gboolean
303-custom_init_wait_cb (CustomInitContext *ctx)
304-{
305- custom_init_step (ctx);
306- return FALSE;
307-}
308-
309-static void
310-custom_init_step (CustomInitContext *ctx)
311-{
312- /* If cancelled, end */
313- if (g_cancellable_is_cancelled (ctx->cancellable)) {
314- mm_dbg ("(Novatel) no need to keep on running custom init in (%s)",
315- mm_port_get_device (MM_PORT (ctx->port)));
316- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
317- custom_init_context_complete_and_free (ctx);
318- return;
319- }
320-
321- /* If device has a QMI port, don't run $NWDMAT */
322- if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list (mm_port_probe_peek_device (ctx->probe)))) {
323- mm_dbg ("(Novatel) no need to run custom init in (%s): device has QMI port",
324- mm_port_get_device (MM_PORT (ctx->port)));
325- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
326- custom_init_context_complete_and_free (ctx);
327- return;
328- }
329-
330- if (ctx->wait_time > 0) {
331- ctx->wait_time--;
332- g_timeout_add_seconds (1, (GSourceFunc)custom_init_wait_cb, ctx);
333- return;
334- }
335-
336- if (ctx->nwdmat_retries > 0) {
337- ctx->nwdmat_retries--;
338- mm_at_serial_port_queue_command (ctx->port,
339- "$NWDMAT=1",
340- 3,
341- FALSE, /* raw */
342- ctx->cancellable,
343- (MMAtSerialResponseFn)nwdmat_ready,
344- ctx);
345- return;
346- }
347-
348- /* Finish custom_init */
349- mm_dbg ("(Novatel) couldn't flip secondary port to AT in (%s): all retries consumed",
350- mm_port_get_device (MM_PORT (ctx->port)));
351- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
352- custom_init_context_complete_and_free (ctx);
353-}
354-
355-static void
356-novatel_custom_init (MMPortProbe *probe,
357- MMAtSerialPort *port,
358- GCancellable *cancellable,
359- GAsyncReadyCallback callback,
360- gpointer user_data)
361-{
362- CustomInitContext *ctx;
363-
364- ctx = g_slice_new (CustomInitContext);
365- ctx->result = g_simple_async_result_new (G_OBJECT (probe),
366- callback,
367- user_data,
368- novatel_custom_init);
369- ctx->probe = g_object_ref (probe);
370- ctx->port = g_object_ref (port);
371- ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
372- ctx->nwdmat_retries = 3;
373- ctx->wait_time = 2;
374-
375- custom_init_step (ctx);
376-}
377-
378-/*****************************************************************************/
379
380 static MMBaseModem *
381 create_modem (MMPlugin *self,
382@@ -228,8 +96,8 @@ mm_plugin_create (void)
383 static const mm_uint16_pair forbidden_products[] = { { 0x1410, 0x9010 }, /* Novatel E362 */
384 { 0, 0 } };
385 static const MMAsyncMethod custom_init = {
386- .async = G_CALLBACK (novatel_custom_init),
387- .finish = G_CALLBACK (novatel_custom_init_finish),
388+ .async = G_CALLBACK (mm_common_novatel_custom_init),
389+ .finish = G_CALLBACK (mm_common_novatel_custom_init_finish),
390 };
391
392 return MM_PLUGIN (
0393
=== modified file 'debian/patches/series'
--- debian/patches/series 2014-01-14 10:02:26 +0000
+++ debian/patches/series 2015-09-23 03:12:22 +0000
@@ -4,3 +4,10 @@
4linux-default-usb-id.patch4linux-default-usb-id.patch
5glib_fixes.patch5glib_fixes.patch
6lp1229748_bluegiga_blacklist.patch6lp1229748_bluegiga_blacklist.patch
7novatel-custom-init.patch
8novatel-common-library.patch
9sierra-common-library.patch
10mbm-common-library.patch
11sierra-custom-init.patch
12new-sierra-legacy-plugin.patch
13dell-mbim-plugin.patch
714
=== added file 'debian/patches/sierra-common-library.patch'
--- debian/patches/sierra-common-library.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/sierra-common-library.patch 2015-09-23 03:12:22 +0000
@@ -0,0 +1,54 @@
1## Description: sierra common library which is backported from develop branch(1.5.x) to 1.0
2## Origin/Author: Aleksander Morgado <aleksander@lanedo.com>
3## Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/trusty/+source/modemmanager/+bug/1441095
4## Source: http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=299280166301d00c2b0e2b8868a96013388b2a3f
5commit 299280166301d00c2b0e2b8868a96013388b2a3f
6Author: Aleksander Morgado <aleksander@aleksander.es>
7Date: Fri Feb 6 16:51:13 2015 +0100
8
9 sierra: build a common non-inst library with the core Sierra modem support
10
11Index: modemmanager/plugins/Makefile.am
12===================================================================
13--- modemmanager.orig/plugins/Makefile.am
14+++ modemmanager/plugins/Makefile.am
15@@ -166,10 +166,9 @@ libmm_plugin_hso_la_SOURCES = \
16 libmm_plugin_hso_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
17 libmm_plugin_hso_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
18
19-# Sierra
20-libmm_plugin_sierra_la_SOURCES = \
21- sierra/mm-plugin-sierra.c \
22- sierra/mm-plugin-sierra.h \
23+# Common Sierra modem support library
24+noinst_LTLIBRARIES += libmm-utils-sierra.la
25+libmm_utils_sierra_la_SOURCES = \
26 sierra/mm-common-sierra.c \
27 sierra/mm-common-sierra.h \
28 sierra/mm-sim-sierra.c \
29@@ -177,12 +176,22 @@ libmm_plugin_sierra_la_SOURCES = \
30 sierra/mm-broadband-bearer-sierra.c \
31 sierra/mm-broadband-bearer-sierra.h \
32 sierra/mm-broadband-modem-sierra.c \
33- sierra/mm-broadband-modem-sierra.h \
34+ sierra/mm-broadband-modem-sierra.h
35+libmm_utils_sierra_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
36+libmm_utils_sierra_la_LIBADD = $(GUDEV_LIBS) $(MM_LIBS)
37+
38+SIERRA_COMMON_COMPILER_FLAGS = -I$(top_srcdir)/plugins/sierra
39+SIERRA_COMMON_LIBADD_FLAGS = $(builddir)/libmm-utils-sierra.la
40+
41+# Sierra
42+libmm_plugin_sierra_la_SOURCES = \
43+ sierra/mm-plugin-sierra.c \
44+ sierra/mm-plugin-sierra.h \
45 sierra/mm-broadband-modem-sierra-icera.c \
46 sierra/mm-broadband-modem-sierra-icera.h
47-libmm_plugin_sierra_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(ICERA_COMMON_COMPILER_FLAGS)
48+libmm_plugin_sierra_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(ICERA_COMMON_COMPILER_FLAGS) $(SIERRA_COMMON_COMPILER_FLAGS)
49 libmm_plugin_sierra_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
50-libmm_plugin_sierra_la_LIBADD = $(ICERA_COMMON_LIBADD_FLAGS)
51+libmm_plugin_sierra_la_LIBADD = $(ICERA_COMMON_LIBADD_FLAGS) $(SIERRA_COMMON_LIBADD_FLAGS)
52
53 # Wavecom (Sierra Airlink)
54 libmm_plugin_wavecom_la_SOURCES = \
055
=== added file 'debian/patches/sierra-custom-init.patch'
--- debian/patches/sierra-custom-init.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/sierra-custom-init.patch 2015-09-23 03:12:22 +0000
@@ -0,0 +1,531 @@
1## Description: sierra custom init which is backported from develop branch(1.5.x) to 1.0
2## Origin/Author: Aleksander Morgado <aleksander@lanedo.com>
3## Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/trusty/+source/modemmanager/+bug/1441095
4## Source: http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=b1159453998e6dc89ba31a803c4c3886c8da0605
5commit b1159453998e6dc89ba31a803c4c3886c8da0605
6Author: Aleksander Morgado <aleksander@aleksander.es>
7Date: Fri Feb 6 17:29:56 2015 +0100
8
9 sierra: move custom init and port grabbing methods to separate source files
10
11Index: modemmanager/plugins/sierra/mm-common-sierra.c
12===================================================================
13--- modemmanager.orig/plugins/sierra/mm-common-sierra.c
14+++ modemmanager/plugins/sierra/mm-common-sierra.c
15@@ -15,6 +15,9 @@
16 * Copyright (C) 2012 Lanedo GmbH
17 */
18
19+#include <stdlib.h>
20+#include <string.h>
21+
22 #include "mm-common-sierra.h"
23 #include "mm-base-modem-at.h"
24 #include "mm-log.h"
25@@ -24,6 +27,211 @@
26 static MMIfaceModem *iface_modem_parent;
27
28 /*****************************************************************************/
29+/* Custom init and port type hints */
30+
31+#define TAG_SIERRA_APP_PORT "sierra-app-port"
32+#define TAG_SIERRA_APP1_PPP_OK "sierra-app1-ppp-ok"
33+
34+gboolean
35+mm_common_sierra_grab_port (MMPlugin *self,
36+ MMBaseModem *modem,
37+ MMPortProbe *probe,
38+ GError **error)
39+{
40+ MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE;
41+ MMPortType ptype;
42+
43+ ptype = mm_port_probe_get_port_type (probe);
44+
45+ /* Is it a GSM secondary port? */
46+ if (g_object_get_data (G_OBJECT (probe), TAG_SIERRA_APP_PORT)) {
47+ if (g_object_get_data (G_OBJECT (probe), TAG_SIERRA_APP1_PPP_OK))
48+ pflags = MM_AT_PORT_FLAG_PPP;
49+ else
50+ pflags = MM_AT_PORT_FLAG_SECONDARY;
51+ } else if (ptype == MM_PORT_TYPE_AT)
52+ pflags = MM_AT_PORT_FLAG_PRIMARY;
53+
54+ return mm_base_modem_grab_port (modem,
55+ mm_port_probe_get_port_subsys (probe),
56+ mm_port_probe_get_port_name (probe),
57+ ptype,
58+ pflags,
59+ error);
60+}
61+
62+gboolean
63+mm_common_sierra_port_probe_list_is_icera (GList *probes)
64+{
65+ GList *l;
66+
67+ for (l = probes; l; l = g_list_next (l)) {
68+ /* Only assume the Icera probing check is valid IF the port is not
69+ * secondary. This will skip the stupid ports which reply OK to every
70+ * AT command, even the one we use to check for Icera support */
71+ if (mm_port_probe_is_icera (MM_PORT_PROBE (l->data)) &&
72+ !g_object_get_data (G_OBJECT (l->data), TAG_SIERRA_APP_PORT))
73+ return TRUE;
74+ }
75+
76+ return FALSE;
77+}
78+
79+typedef struct {
80+ MMPortProbe *probe;
81+ MMAtSerialPort *port;
82+ GCancellable *cancellable;
83+ GSimpleAsyncResult *result;
84+ guint retries;
85+} SierraCustomInitContext;
86+
87+static void
88+sierra_custom_init_context_complete_and_free (SierraCustomInitContext *ctx)
89+{
90+ g_simple_async_result_complete_in_idle (ctx->result);
91+
92+ if (ctx->cancellable)
93+ g_object_unref (ctx->cancellable);
94+ g_object_unref (ctx->port);
95+ g_object_unref (ctx->probe);
96+ g_object_unref (ctx->result);
97+ g_slice_free (SierraCustomInitContext, ctx);
98+}
99+
100+gboolean
101+mm_common_sierra_custom_init_finish (MMPortProbe *probe,
102+ GAsyncResult *result,
103+ GError **error)
104+{
105+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
106+}
107+
108+static void sierra_custom_init_step (SierraCustomInitContext *ctx);
109+
110+static void
111+gcap_ready (MMAtSerialPort *port,
112+ GString *response,
113+ GError *error,
114+ SierraCustomInitContext *ctx)
115+{
116+ if (error) {
117+ /* If consumed all tries and the last error was a timeout, assume the
118+ * port is not AT */
119+ if (ctx->retries == 0 &&
120+ g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
121+ mm_port_probe_set_result_at (ctx->probe, FALSE);
122+ }
123+ /* If reported a hard parse error, this port is definitely not an AT
124+ * port, skip trying. */
125+ else if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_PARSE_FAILED)) {
126+ mm_port_probe_set_result_at (ctx->probe, FALSE);
127+ ctx->retries = 0;
128+ }
129+ /* Some Icera-based devices (eg, USB305) have an AT-style port that
130+ * replies to everything with ERROR, so tag as unsupported; sometimes
131+ * the real AT ports do this too, so let a retry tag the port as
132+ * supported if it responds correctly later. */
133+ else if (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN)) {
134+ mm_port_probe_set_result_at (ctx->probe, FALSE);
135+ }
136+
137+ /* Just retry... */
138+ sierra_custom_init_step (ctx);
139+ return;
140+ }
141+
142+ /* A valid reply to ATI tells us this is an AT port already */
143+ mm_port_probe_set_result_at (ctx->probe, TRUE);
144+
145+ /* Sierra APPx ports have limited AT command parsers that just reply with
146+ * "OK" to most commands. These can sometimes be used for PPP while the
147+ * main port is used for status and control, but older modems tend to crash
148+ * or fail PPP. So we whitelist modems that are known to allow PPP on the
149+ * secondary APP ports.
150+ */
151+ if (strstr (response->str, "APP1")) {
152+ g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP_PORT, GUINT_TO_POINTER (TRUE));
153+
154+ /* PPP-on-APP1-port whitelist */
155+ if (strstr (response->str, "C885") ||
156+ strstr (response->str, "USB 306") ||
157+ strstr (response->str, "MC8790"))
158+ g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP1_PPP_OK, GUINT_TO_POINTER (TRUE));
159+
160+ /* For debugging: let users figure out if their device supports PPP
161+ * on the APP1 port or not.
162+ */
163+ if (getenv ("MM_SIERRA_APP1_PPP_OK")) {
164+ mm_dbg ("Sierra: APP1 PPP OK '%s'", response->str);
165+ g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP1_PPP_OK, GUINT_TO_POINTER (TRUE));
166+ }
167+ } else if (strstr (response->str, "APP2") ||
168+ strstr (response->str, "APP3") ||
169+ strstr (response->str, "APP4")) {
170+ /* Additional APP ports don't support most AT commands, so they cannot
171+ * be used as the primary port.
172+ */
173+ g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP_PORT, GUINT_TO_POINTER (TRUE));
174+ }
175+
176+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
177+ sierra_custom_init_context_complete_and_free (ctx);
178+}
179+
180+static void
181+sierra_custom_init_step (SierraCustomInitContext *ctx)
182+{
183+ /* If cancelled, end */
184+ if (g_cancellable_is_cancelled (ctx->cancellable)) {
185+ mm_dbg ("(Sierra) no need to keep on running custom init in '%s'",
186+ mm_port_get_device (MM_PORT (ctx->port)));
187+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
188+ sierra_custom_init_context_complete_and_free (ctx);
189+ return;
190+ }
191+
192+ if (ctx->retries == 0) {
193+ mm_dbg ("(Sierra) Couldn't get port type hints from '%s'",
194+ mm_port_get_device (MM_PORT (ctx->port)));
195+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
196+ sierra_custom_init_context_complete_and_free (ctx);
197+ return;
198+ }
199+
200+ ctx->retries--;
201+ mm_at_serial_port_queue_command (
202+ ctx->port,
203+ "ATI",
204+ 3,
205+ FALSE, /* raw */
206+ ctx->cancellable,
207+ (MMAtSerialResponseFn)gcap_ready,
208+ ctx);
209+}
210+
211+void
212+mm_common_sierra_custom_init (MMPortProbe *probe,
213+ MMAtSerialPort *port,
214+ GCancellable *cancellable,
215+ GAsyncReadyCallback callback,
216+ gpointer user_data)
217+{
218+ SierraCustomInitContext *ctx;
219+
220+ ctx = g_slice_new (SierraCustomInitContext);
221+ ctx->result = g_simple_async_result_new (G_OBJECT (probe),
222+ callback,
223+ user_data,
224+ mm_common_sierra_custom_init);
225+ ctx->probe = g_object_ref (probe);
226+ ctx->port = g_object_ref (port);
227+ ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
228+ ctx->retries = 3;
229+
230+ sierra_custom_init_step (ctx);
231+}
232+
233+/*****************************************************************************/
234 /* Modem power up (Modem interface) */
235
236 gboolean
237Index: modemmanager/plugins/sierra/mm-common-sierra.h
238===================================================================
239--- modemmanager.orig/plugins/sierra/mm-common-sierra.h
240+++ modemmanager/plugins/sierra/mm-common-sierra.h
241@@ -18,9 +18,26 @@
242 #ifndef MM_COMMON_SIERRA_H
243 #define MM_COMMON_SIERRA_H
244
245+#include "mm-plugin.h"
246 #include "mm-broadband-modem.h"
247 #include "mm-iface-modem.h"
248
249+gboolean mm_common_sierra_grab_port (MMPlugin *self,
250+ MMBaseModem *modem,
251+ MMPortProbe *probe,
252+ GError **error);
253+
254+gboolean mm_common_sierra_port_probe_list_is_icera (GList *probes);
255+
256+void mm_common_sierra_custom_init (MMPortProbe *probe,
257+ MMAtSerialPort *port,
258+ GCancellable *cancellable,
259+ GAsyncReadyCallback callback,
260+ gpointer user_data);
261+gboolean mm_common_sierra_custom_init_finish (MMPortProbe *probe,
262+ GAsyncResult *result,
263+ GError **error);
264+
265 void mm_common_sierra_load_power_state (MMIfaceModem *self,
266 GAsyncReadyCallback callback,
267 gpointer user_data);
268Index: modemmanager/plugins/sierra/mm-plugin-sierra.c
269===================================================================
270--- modemmanager.orig/plugins/sierra/mm-plugin-sierra.c
271+++ modemmanager/plugins/sierra/mm-plugin-sierra.c
272@@ -15,7 +15,6 @@
273 * Copyright (C) 2012 Lanedo GmbH
274 */
275
276-#include <string.h>
277 #include <stdlib.h>
278 #include <gmodule.h>
279
280@@ -24,6 +23,7 @@
281
282 #include "mm-log.h"
283 #include "mm-plugin-sierra.h"
284+#include "mm-common-sierra.h"
285 #include "mm-broadband-modem-sierra.h"
286 #include "mm-broadband-modem-sierra-icera.h"
287
288@@ -41,181 +41,6 @@ int mm_plugin_major_version = MM_PLUGIN_
289 int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
290
291 /*****************************************************************************/
292-/* Custom init */
293-
294-#define TAG_SIERRA_APP_PORT "sierra-app-port"
295-#define TAG_SIERRA_APP1_PPP_OK "sierra-app1-ppp-ok"
296-
297-typedef struct {
298- MMPortProbe *probe;
299- MMAtSerialPort *port;
300- GCancellable *cancellable;
301- GSimpleAsyncResult *result;
302- guint retries;
303-} SierraCustomInitContext;
304-
305-static void
306-sierra_custom_init_context_complete_and_free (SierraCustomInitContext *ctx)
307-{
308- g_simple_async_result_complete_in_idle (ctx->result);
309-
310- if (ctx->cancellable)
311- g_object_unref (ctx->cancellable);
312- g_object_unref (ctx->port);
313- g_object_unref (ctx->probe);
314- g_object_unref (ctx->result);
315- g_slice_free (SierraCustomInitContext, ctx);
316-}
317-
318-static gboolean
319-sierra_custom_init_finish (MMPortProbe *probe,
320- GAsyncResult *result,
321- GError **error)
322-{
323- return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
324-}
325-
326-static void sierra_custom_init_step (SierraCustomInitContext *ctx);
327-
328-static void
329-gcap_ready (MMAtSerialPort *port,
330- GString *response,
331- GError *error,
332- SierraCustomInitContext *ctx)
333-{
334- if (error) {
335- /* If consumed all tries and the last error was a timeout, assume the
336- * port is not AT */
337- if (ctx->retries == 0 &&
338- g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
339- mm_port_probe_set_result_at (ctx->probe, FALSE);
340- }
341- /* If reported a hard parse error, this port is definitely not an AT
342- * port, skip trying. */
343- else if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_PARSE_FAILED)) {
344- mm_port_probe_set_result_at (ctx->probe, FALSE);
345- ctx->retries = 0;
346- }
347- /* Some Icera-based devices (eg, USB305) have an AT-style port that
348- * replies to everything with ERROR, so tag as unsupported; sometimes
349- * the real AT ports do this too, so let a retry tag the port as
350- * supported if it responds correctly later. */
351- else if (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN)) {
352- mm_port_probe_set_result_at (ctx->probe, FALSE);
353- }
354-
355- /* Just retry... */
356- sierra_custom_init_step (ctx);
357- return;
358- }
359-
360- /* A valid reply to ATI tells us this is an AT port already */
361- mm_port_probe_set_result_at (ctx->probe, TRUE);
362-
363- /* Sierra APPx ports have limited AT command parsers that just reply with
364- * "OK" to most commands. These can sometimes be used for PPP while the
365- * main port is used for status and control, but older modems tend to crash
366- * or fail PPP. So we whitelist modems that are known to allow PPP on the
367- * secondary APP ports.
368- */
369- if (strstr (response->str, "APP1")) {
370- g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP_PORT, GUINT_TO_POINTER (TRUE));
371-
372- /* PPP-on-APP1-port whitelist */
373- if (strstr (response->str, "C885") || strstr (response->str, "USB 306") || strstr (response->str, "MC8790"))
374- g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP1_PPP_OK, GUINT_TO_POINTER (TRUE));
375-
376- /* For debugging: let users figure out if their device supports PPP
377- * on the APP1 port or not.
378- */
379- if (getenv ("MM_SIERRA_APP1_PPP_OK")) {
380- mm_dbg ("Sierra: APP1 PPP OK '%s'", response->str);
381- g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP1_PPP_OK, GUINT_TO_POINTER (TRUE));
382- }
383- } else if (strstr (response->str, "APP2") ||
384- strstr (response->str, "APP3") ||
385- strstr (response->str, "APP4")) {
386- /* Additional APP ports don't support most AT commands, so they cannot
387- * be used as the primary port.
388- */
389- g_object_set_data (G_OBJECT (ctx->probe), TAG_SIERRA_APP_PORT, GUINT_TO_POINTER (TRUE));
390- }
391-
392- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
393- sierra_custom_init_context_complete_and_free (ctx);
394-}
395-
396-static void
397-sierra_custom_init_step (SierraCustomInitContext *ctx)
398-{
399- /* If cancelled, end */
400- if (g_cancellable_is_cancelled (ctx->cancellable)) {
401- mm_dbg ("(Sierra) no need to keep on running custom init in '%s'",
402- mm_port_get_device (MM_PORT (ctx->port)));
403- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
404- sierra_custom_init_context_complete_and_free (ctx);
405- return;
406- }
407-
408- if (ctx->retries == 0) {
409- mm_dbg ("(Sierra) Couldn't get port type hints from '%s'",
410- mm_port_get_device (MM_PORT (ctx->port)));
411- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
412- sierra_custom_init_context_complete_and_free (ctx);
413- return;
414- }
415-
416- ctx->retries--;
417- mm_at_serial_port_queue_command (
418- ctx->port,
419- "ATI",
420- 3,
421- FALSE, /* raw */
422- ctx->cancellable,
423- (MMAtSerialResponseFn)gcap_ready,
424- ctx);
425-}
426-
427-static void
428-sierra_custom_init (MMPortProbe *probe,
429- MMAtSerialPort *port,
430- GCancellable *cancellable,
431- GAsyncReadyCallback callback,
432- gpointer user_data)
433-{
434- SierraCustomInitContext *ctx;
435-
436- ctx = g_slice_new (SierraCustomInitContext);
437- ctx->result = g_simple_async_result_new (G_OBJECT (probe),
438- callback,
439- user_data,
440- sierra_custom_init);
441- ctx->probe = g_object_ref (probe);
442- ctx->port = g_object_ref (port);
443- ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
444- ctx->retries = 3;
445-
446- sierra_custom_init_step (ctx);
447-}
448-
449-/*****************************************************************************/
450-
451-static gboolean
452-sierra_port_probe_list_is_icera (GList *probes)
453-{
454- GList *l;
455-
456- for (l = probes; l; l = g_list_next (l)) {
457- /* Only assume the Icera probing check is valid IF the port is not
458- * secondary. This will skip the stupid ports which reply OK to every
459- * AT command, even the one we use to check for Icera support */
460- if (mm_port_probe_is_icera (MM_PORT_PROBE (l->data)) &&
461- !g_object_get_data (G_OBJECT (l->data), TAG_SIERRA_APP_PORT))
462- return TRUE;
463- }
464-
465- return FALSE;
466-}
467
468 static MMBaseModem *
469 create_modem (MMPlugin *self,
470@@ -248,7 +73,7 @@ create_modem (MMPlugin *self,
471 }
472 #endif
473
474- if (sierra_port_probe_list_is_icera (probes))
475+ if (mm_common_sierra_port_probe_list_is_icera (probes))
476 return MM_BASE_MODEM (mm_broadband_modem_sierra_icera_new (sysfs_path,
477 drivers,
478 mm_plugin_get_name (self),
479@@ -262,34 +87,6 @@ create_modem (MMPlugin *self,
480 product));
481 }
482
483-static gboolean
484-grab_port (MMPlugin *self,
485- MMBaseModem *modem,
486- MMPortProbe *probe,
487- GError **error)
488-{
489- MMAtPortFlag pflags = MM_AT_PORT_FLAG_NONE;
490- MMPortType ptype;
491-
492- ptype = mm_port_probe_get_port_type (probe);
493-
494- /* Is it a GSM secondary port? */
495- if (g_object_get_data (G_OBJECT (probe), TAG_SIERRA_APP_PORT)) {
496- if (g_object_get_data (G_OBJECT (probe), TAG_SIERRA_APP1_PPP_OK))
497- pflags = MM_AT_PORT_FLAG_PPP;
498- else
499- pflags = MM_AT_PORT_FLAG_SECONDARY;
500- } else if (ptype == MM_PORT_TYPE_AT)
501- pflags = MM_AT_PORT_FLAG_PRIMARY;
502-
503- return mm_base_modem_grab_port (modem,
504- mm_port_probe_get_port_subsys (probe),
505- mm_port_probe_get_port_name (probe),
506- ptype,
507- pflags,
508- error);
509-}
510-
511 /*****************************************************************************/
512
513 G_MODULE_EXPORT MMPlugin *
514@@ -298,8 +95,8 @@ mm_plugin_create (void)
515 static const gchar *subsystems[] = { "tty", "net", "usb", NULL };
516 static const gchar *drivers[] = { "sierra", "sierra_net", NULL };
517 static const MMAsyncMethod custom_init = {
518- .async = G_CALLBACK (sierra_custom_init),
519- .finish = G_CALLBACK (sierra_custom_init_finish),
520+ .async = G_CALLBACK (mm_common_sierra_custom_init),
521+ .finish = G_CALLBACK (mm_common_sierra_custom_init_finish),
522 };
523
524 return MM_PLUGIN (
525@@ -328,5 +125,5 @@ mm_plugin_sierra_class_init (MMPluginSie
526 MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
527
528 plugin_class->create_modem = create_modem;
529- plugin_class->grab_port = grab_port;
530+ plugin_class->grab_port = mm_common_sierra_grab_port;
531 }

Subscribers

People subscribed via source and target branches

to all changes: