[PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem

2010-08-16 Thread Sjur Brændeland
---
Changes since last patch set:
o Moved updates to plugins/ste to separate patch.
o Updated error handling.
o Style issues.


 Makefile.am   |4 +-
 drivers/stemodem/radio-settings.c |  223 +
 drivers/stemodem/stemodem.c   |2 +
 drivers/stemodem/stemodem.h   |2 +
 4 files changed, 230 insertions(+), 1 deletions(-)
 create mode 100644 drivers/stemodem/radio-settings.c

diff --git a/Makefile.am b/Makefile.am
index 2f0b745..3e1efde 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -204,7 +204,9 @@ builtin_sources += drivers/atmodem/atutil.h \
drivers/stemodem/voicecall.c \
drivers/stemodem/gprs-context.c \
drivers/stemodem/caif_socket.h \
-   drivers/stemodem/if_caif.h
+   drivers/stemodem/if_caif.h \
+   drivers/stemodem/radio-settings.c
+
 
 builtin_modules += phonesim
 builtin_sources += plugins/phonesim.c
diff --git a/drivers/stemodem/radio-settings.c 
b/drivers/stemodem/radio-settings.c
new file mode 100644
index 000..0c5b438
--- /dev/null
+++ b/drivers/stemodem/radio-settings.c
@@ -0,0 +1,223 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *  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 config.h
+#endif
+
+#define _GNU_SOURCE
+#include string.h
+#include stdlib.h
+#include stdio.h
+#include errno.h
+
+#include glib.h
+
+#include ofono/log.h
+#include ofono/modem.h
+#include ofono/radio-settings.h
+
+#include gatchat.h
+#include gatresult.h
+
+#include stemodem.h
+
+static const char *none_prefix[] = { NULL };
+static const char *cfun_prefix[] = { +CFUN:, NULL };
+
+struct radio_settings_data {
+   GAtChat *chat;
+};
+
+enum ste_radio_mode {
+   STE_RADIO_OFF = 0,
+   STE_RADIO_ON = 1,
+   STE_RADIO_FLIGHT_MODE = 4,
+   STE_RADIO_GSM_ONLY = 5,
+   STE_RADIO_WCDMA_ONLY = 6
+};
+
+static gboolean ste_mode_to_ofono_mode(enum ste_radio_mode stemode,
+   enum ofono_radio_access_mode *mode)
+{
+   switch (stemode) {
+   case STE_RADIO_ON:
+   *mode = OFONO_RADIO_ACCESS_MODE_ANY;
+   return TRUE;
+   case STE_RADIO_GSM_ONLY:
+   *mode = OFONO_RADIO_ACCESS_MODE_GSM;
+   return TRUE;
+   case STE_RADIO_WCDMA_ONLY:
+   *mode = OFONO_RADIO_ACCESS_MODE_UMTS;
+   return TRUE;
+   default:
+   return FALSE;
+   }
+}
+
+static gboolean ofono_mode_to_ste_mode(enum ofono_radio_access_mode mode,
+   enum ste_radio_mode *stemode)
+{
+   switch (mode) {
+   case OFONO_RADIO_ACCESS_MODE_ANY:
+   *stemode = STE_RADIO_ON;
+   return TRUE;
+   case OFONO_RADIO_ACCESS_MODE_GSM:
+   *stemode = STE_RADIO_GSM_ONLY;
+   return TRUE;
+
+   case OFONO_RADIO_ACCESS_MODE_UMTS:
+   *stemode = STE_RADIO_WCDMA_ONLY;
+   return TRUE;
+   default:
+   return FALSE;
+   }
+}
+
+static void sterat_query_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+   struct cb_data *cbd = user_data;
+   ofono_radio_settings_rat_mode_query_cb_t cb = cbd-cb;
+   enum ofono_radio_access_mode mode;
+   GAtResultIter iter;
+   int value;
+
+   decode_at_error(error, g_at_result_final_response(result));
+
+   if (!ok) {
+   cb(error, -1, cbd-data);
+   return;
+   }
+
+   g_at_result_iter_init(iter, result);
+
+   if (!g_at_result_iter_next(iter, +CFUN:))
+   goto err;
+
+   if (!g_at_result_iter_next_number(iter, value))
+   goto err;
+
+   if (!ste_mode_to_ofono_mode(value, mode))
+   goto err;
+
+   CALLBACK_WITH_SUCCESS(cb, mode, cbd-data);
+
+   return;
+
+err:
+   CALLBACK_WITH_FAILURE(cb, -1, cbd-data);
+}
+
+static void ste_query_rat_mode(struct ofono_radio_settings *rs,
+   ofono_radio_settings_rat_mode_query_cb_t cb,
+   void *data)
+{
+   struct radio_settings_data *rsd = ofono_radio_settings_get_data(rs);

Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem

2010-08-16 Thread Marcel Holtmann
Hi Sjur,

 Changes since last patch set:
 o Moved updates to plugins/ste to separate patch.
 o Updated error handling.
 o Style issues.
 
 
  Makefile.am   |4 +-
  drivers/stemodem/radio-settings.c |  223 
 +
  drivers/stemodem/stemodem.c   |2 +
  drivers/stemodem/stemodem.h   |2 +
  4 files changed, 230 insertions(+), 1 deletions(-)
  create mode 100644 drivers/stemodem/radio-settings.c

is this identical to how MBM does it? If yes, then I prefer we add this
to drivers/mbmmodem/ and you just reference it. If not then I like to
see the MBM version of this and where it actually differs. Maybe a MBM
version with a STE quirk is better.

I prefer doing this in MBM since that modem driver was just the first.
There is no other preference here ;)

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem

2010-08-16 Thread Sjur Brændeland
Marcel Holtmann mar...@holtmann.org wrote:
 Hi Sjur,

 Changes since last patch set:
 o Moved updates to plugins/ste to separate patch.
 o Updated error handling.
 o Style issues.


  Makefile.am                       |    4 +-
  drivers/stemodem/radio-settings.c |  223 
 +
  drivers/stemodem/stemodem.c       |    2 +
  drivers/stemodem/stemodem.h       |    2 +
  4 files changed, 230 insertions(+), 1 deletions(-)
  create mode 100644 drivers/stemodem/radio-settings.c

 is this identical to how MBM does it? If yes, then I prefer we add this
 to drivers/mbmmodem/ and you just reference it. If not then I like to
 see the MBM version of this and where it actually differs. Maybe a MBM
 version with a STE quirk is better.

Actually this is not yet implemented by MBM, so I guess STE is master
this time ;-)

 I prefer doing this in MBM since that modem driver was just the first.
 There is no other preference here ;)

This actually raises one question. How should we handle version variations from
the same Modem vendor.
The differences will be larger as we start adding support for LTE, and
support different
bearers (PC cards with USB and Modems with CAIF).
Should we create more entries in the vendor enum, or do you have something
else in mind?

Regards
Sjur
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCHv2 4/7] stemodem: Add Radio Settings to STE Modem

2010-08-16 Thread Marcel Holtmann
Hi Sjur,

  Changes since last patch set:
  o Moved updates to plugins/ste to separate patch.
  o Updated error handling.
  o Style issues.
 
 
   Makefile.am   |4 +-
   drivers/stemodem/radio-settings.c |  223 
  +
   drivers/stemodem/stemodem.c   |2 +
   drivers/stemodem/stemodem.h   |2 +
   4 files changed, 230 insertions(+), 1 deletions(-)
   create mode 100644 drivers/stemodem/radio-settings.c
 
  is this identical to how MBM does it? If yes, then I prefer we add this
  to drivers/mbmmodem/ and you just reference it. If not then I like to
  see the MBM version of this and where it actually differs. Maybe a MBM
  version with a STE quirk is better.
 
 Actually this is not yet implemented by MBM, so I guess STE is master
 this time ;-)

I thought that part would be similar in both cards. Then I am fine with
this.

  I prefer doing this in MBM since that modem driver was just the first.
  There is no other preference here ;)
 
 This actually raises one question. How should we handle version variations 
 from
 the same Modem vendor.
 The differences will be larger as we start adding support for LTE, and
 support different
 bearers (PC cards with USB and Modems with CAIF).
 Should we create more entries in the vendor enum, or do you have something
 else in mind?

We cross that bridge when we get to it.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono