From ab58196e316ed832001da6aa0dd26bd5ff2be430 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 18 Sep 2017 20:05:01 -0500 Subject: [PATCH] mbimmodem: Add skeleton driver --- Makefile.am | 7 +++++ configure.ac | 5 +++ drivers/mbimmodem/mbimmodem.c | 41 +++++++++++++++++++++++++ drivers/mbimmodem/mbimmodem.h | 22 ++++++++++++++ drivers/mbimmodem/util.h | 57 +++++++++++++++++++++++++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 drivers/mbimmodem/mbimmodem.c create mode 100644 drivers/mbimmodem/mbimmodem.h create mode 100644 drivers/mbimmodem/util.h diff --git a/Makefile.am b/Makefile.am index d0ecb934..7644b5c1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -605,6 +605,13 @@ builtin_sources += plugins/allowed-apns.c if ELL builtin_cflags += @ELL_CFLAGS@ builtin_libadd += @ELL_LIBS@ + +if MBIMMODEM +builtin_modules += mbimmodem +builtin_sources += drivers/mbimmodem/util.h \ + drivers/mbimmodem/mbimmodem.h \ + drivers/mbimmodem/mbimmodem.c +endif endif sbin_PROGRAMS = src/ofonod diff --git a/configure.ac b/configure.ac index e9b8491a..f3148a40 100644 --- a/configure.ac +++ b/configure.ac @@ -218,6 +218,10 @@ AC_ARG_ENABLE(upower, AC_HELP_STRING([--disable-upower], [enable_upower=${enableval}]) AM_CONDITIONAL(UPOWER, test "${enable_power}" != "no") +AC_ARG_ENABLE(mbimmodem, AC_HELP_STRING([--enable-mbimmodem], + [enable MBIM based modem support]), + [enable_mbimmodem=${enableval}]) + AC_ARG_ENABLE(ell, AC_HELP_STRING([--enable-ell], [enable support for ell]), [enable_ell=${enableval}]) @@ -230,6 +234,7 @@ if (test "${enable_ell}" = "yes"); then AC_SUBST(ELL_LIBS) fi +AM_CONDITIONAL(MBIMMODEM, test "${enable_ell}" != "no" && test "${enable_mbimmodem}" = "yes") AM_CONDITIONAL(ELL, test "${enable_ell}" != "no") AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles], diff --git a/drivers/mbimmodem/mbimmodem.c b/drivers/mbimmodem/mbimmodem.c new file mode 100644 index 00000000..6238abd4 --- /dev/null +++ b/drivers/mbimmodem/mbimmodem.c @@ -0,0 +1,41 @@ +/* + * + * oFono - Open Source Telephony + * + * Copyright (C) 2017 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#define OFONO_API_SUBJECT_TO_CHANGE +#include + +#include "mbimmodem.h" + +static int mbimmodem_init(void) +{ + return 0; +} + +static void mbimmodem_exit(void) +{ +} + +OFONO_PLUGIN_DEFINE(mbimmodem, "MBIM modem driver", VERSION, + OFONO_PLUGIN_PRIORITY_DEFAULT, mbimmodem_init, mbimmodem_exit) diff --git a/drivers/mbimmodem/mbimmodem.h b/drivers/mbimmodem/mbimmodem.h new file mode 100644 index 00000000..2cff8a41 --- /dev/null +++ b/drivers/mbimmodem/mbimmodem.h @@ -0,0 +1,22 @@ +/* + * + * oFono - Open Source Telephony + * + * Copyright (C) 2017 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "util.h" diff --git a/drivers/mbimmodem/util.h b/drivers/mbimmodem/util.h new file mode 100644 index 00000000..51552156 --- /dev/null +++ b/drivers/mbimmodem/util.h @@ -0,0 +1,57 @@ +/* + * + * oFono - Open Source Telephony + * + * Copyright (C) 2017 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +struct cb_data { + void *cb; + void *data; + void *user; +}; + +static inline struct cb_data *cb_data_new(void *cb, void *data) +{ + struct cb_data *ret; + + ret = l_new(struct cb_data, 1); + ret->cb = cb; + ret->data = data; + ret->user = NULL; + + return ret; +} + +#define CALLBACK_WITH_FAILURE(cb, args...) \ + do { \ + struct ofono_error cb_e; \ + cb_e.type = OFONO_ERROR_TYPE_FAILURE; \ + cb_e.error = 0; \ + \ + cb(&cb_e, ##args); \ + } while (0) \ + +#define CALLBACK_WITH_SUCCESS(f, args...) \ + do { \ + struct ofono_error e; \ + e.type = OFONO_ERROR_TYPE_NO_ERROR; \ + e.error = 0; \ + f(&e, ##args); \ + } while (0)