Commit 98b357f3 authored by Slava Monich's avatar Slava Monich

Merge branch 'recap' into 'master'

Refactring radio caps code

See merge request mer-core/ofono!261
parents 98ffc61a 56c488d1
......@@ -2,7 +2,7 @@
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2019 Open Mobile Platform LLC.
* Copyright (C) 2019-2020 Open Mobile Platform LLC.
*
* 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
......@@ -81,6 +81,7 @@ typedef struct ril_data RilData;
enum ril_data_io_event_id {
IO_EVENT_DATA_CALL_LIST_CHANGED,
IO_EVENT_RESTRICTED_STATE_CHANGED,
IO_EVENT_EOF,
IO_EVENT_COUNT
};
......@@ -192,6 +193,7 @@ struct ril_data_request_allow_data {
static void ril_data_manager_check_network_mode(struct ril_data_manager *dm);
static void ril_data_call_deact_cid(struct ril_data *data, int cid);
static void ril_data_cancel_all_requests(struct ril_data *self);
static void ril_data_power_update(struct ril_data *self);
static void ril_data_signal_emit(struct ril_data *self, enum ril_data_signal id)
{
......@@ -1230,6 +1232,17 @@ static void ril_data_settings_changed(struct ril_sim_settings *settings,
ril_data_manager_check_network_mode(RIL_DATA(user_data)->priv->dm);
}
static void ril_data_ril_disconnected_cb(GRilIoChannel *io, void *user_data)
{
struct ril_data *self = RIL_DATA(user_data);
struct ril_data_priv *priv = self->priv;
DBG_(self, "disconnected");
priv->flags = RIL_DATA_FLAG_NONE;
priv->restricted_state = 0;
ril_data_cancel_all_requests(self);
}
static gint ril_data_compare_cb(gconstpointer a, gconstpointer b)
{
const struct ril_data *d1 = a;
......@@ -1289,6 +1302,9 @@ struct ril_data *ril_data_new(struct ril_data_manager *dm, const char *name,
grilio_channel_add_unsol_event_handler(io,
ril_data_restricted_state_changed_cb,
RIL_UNSOL_RESTRICTED_STATE_CHANGED, self);
priv->io_event_id[IO_EVENT_EOF] =
grilio_channel_add_disconnected_handler(io,
ril_data_ril_disconnected_cb, self);
priv->settings_event_id[SETTINGS_EVENT_IMSI_CHANGED] =
ril_sim_settings_add_imsi_changed_handler(settings,
......@@ -1415,6 +1431,20 @@ static void ril_data_cancel_requests(struct ril_data *self,
}
}
static void ril_data_cancel_all_requests(struct ril_data *self)
{
struct ril_data_priv *priv = self->priv;
struct ril_data_request *req = priv->req_queue;
ril_data_request_do_cancel(priv->pending_req);
while (req) {
struct ril_data_request *next = req->next;
ril_data_request_do_cancel(req);
req = next;
}
}
static void ril_data_disallow(struct ril_data *self)
{
struct ril_data_priv *priv = self->priv;
......@@ -1586,24 +1616,11 @@ static void ril_data_dispose(GObject *object)
struct ril_data *self = RIL_DATA(object);
struct ril_data_priv *priv = self->priv;
struct ril_data_manager *dm = priv->dm;
struct ril_network *network = priv->network;
struct ril_sim_settings *settings = network->settings;
struct ril_data_request *req;
ril_sim_settings_remove_handlers(settings, priv->settings_event_id,
G_N_ELEMENTS(priv->settings_event_id));
grilio_channel_remove_all_handlers(priv->io, priv->io_event_id);
grilio_queue_cancel_all(priv->q, FALSE);
priv->query_id = 0;
ril_data_request_do_cancel(priv->pending_req);
req = priv->req_queue;
while (req) {
struct ril_data_request *next = req->next;
ril_data_request_do_cancel(req);
req = next;
}
ril_data_cancel_all_requests(self);
dm->data_list = g_slist_remove(dm->data_list, self);
ril_data_manager_check_data(dm);
g_hash_table_destroy(priv->grab);
......@@ -1614,6 +1631,11 @@ static void ril_data_finalize(GObject *object)
{
struct ril_data *self = RIL_DATA(object);
struct ril_data_priv *priv = self->priv;
struct ril_network *network = priv->network;
struct ril_sim_settings *settings = network->settings;
ril_sim_settings_remove_all_handlers(settings, priv->settings_event_id);
grilio_channel_remove_all_handlers(priv->io, priv->io_event_id);
g_free(priv->log_prefix);
grilio_queue_unref(priv->q);
......@@ -1699,34 +1721,39 @@ static void ril_data_manager_check_network_mode(struct ril_data_manager *self)
if ((self->flags & RIL_DATA_MANAGER_FORCE_GSM_ON_OTHER_SLOTS) &&
ril_data_manager_handover(self)) {
struct ril_network *lte_network = NULL;
int non_gsm_count = 0;
struct ril_network *lte_network = NULL, *best_network = NULL;
enum ofono_radio_access_mode best_mode =
OFONO_RADIO_ACCESS_MODE_ANY;
/*
* Count number of SIMs for which non-GSM mode is selected
*/
/* Find a SIM for internet access */
for (l= self->data_list; l; l = l->next) {
struct ril_data *data = l->data;
struct ril_data_priv *priv = data->priv;
struct ril_network *network = priv->network;
struct ril_sim_settings *sim = network->settings;
enum ofono_radio_access_mode mode;
if (sim->pref_mode != OFONO_RADIO_ACCESS_MODE_GSM) {
non_gsm_count++;
if ((priv->flags & RIL_DATA_FLAG_MAX_SPEED) &&
!lte_network) {
lte_network = network;
}
/* Select the first network with internet role */
if ((sim->pref_mode != OFONO_RADIO_ACCESS_MODE_GSM) &&
(priv->flags & RIL_DATA_FLAG_MAX_SPEED)) {
lte_network = network;
break;
}
/* At the same time, look for a suitable slot */
mode = ril_network_max_supported_mode(network);
if (mode > best_mode) {
best_network = network;
best_mode = mode;
}
}
/*
* If there's no SIM selected for internet access
* then choose the first slot for LTE.
* then use a slot with highest capabilities for LTE.
*/
if (!lte_network) {
struct ril_data *data = self->data_list->data;
lte_network = data->priv->network;
lte_network = best_network;
}
for (l= self->data_list; l; l = l->next) {
......
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2019 Jolla Ltd.
* Copyright (C) 2016-2020 Jolla Ltd.
* Copyright (C) 2019 Open Mobile Platform LLC.
*
* This program is free software; you can redistribute it and/or modify
......@@ -79,12 +79,6 @@ struct ril_data_options {
unsigned int data_call_retry_delay_ms;
};
enum ril_data_role {
RIL_DATA_ROLE_NONE, /* Data not allowed */
RIL_DATA_ROLE_MMS, /* Data is allowed at any speed */
RIL_DATA_ROLE_INTERNET /* Data is allowed at full speed */
};
struct ril_data_manager;
struct ril_data_manager *ril_data_manager_new(enum ril_data_manager_flags flg);
struct ril_data_manager *ril_data_manager_ref(struct ril_data_manager *dm);
......
......@@ -421,6 +421,7 @@ static void ril_modem_remove(struct ofono_modem *ofono)
ofono_modem_set_data(ofono, NULL);
ril_radio_remove_handler(modem->radio, md->radio_state_event_id);
ril_radio_set_online(modem->radio, FALSE);
ril_radio_power_off(modem->radio, RADIO_POWER_TAG(md));
ril_radio_set_online(modem->radio, FALSE);
ril_radio_unref(modem->radio);
......
......@@ -18,6 +18,7 @@
#include "ril_network.h"
#include "ril_radio.h"
#include "ril_radio_caps.h"
#include "ril_sim_card.h"
#include "ril_sim_settings.h"
#include "ril_vendor.h"
......@@ -35,6 +36,7 @@
#include <ofono/watch.h>
#include <ofono/gprs.h>
#include "ofono.h"
#include "common.h"
#define SET_PREF_MODE_HOLDOFF_SEC RIL_RETRY_SECS
......@@ -54,6 +56,12 @@ enum ril_network_radio_event {
RADIO_EVENT_COUNT
};
enum ril_network_radio_caps_mgr_events {
RADIO_CAPS_MGR_TX_DONE,
RADIO_CAPS_MGR_TX_ABORTED,
RADIO_CAPS_MGR_EVENT_COUNT
};
enum ril_network_sim_events {
SIM_EVENT_STATUS_CHANGED,
SIM_EVENT_IO_ACTIVE_CHANGED,
......@@ -62,7 +70,6 @@ enum ril_network_sim_events {
enum ril_network_unsol_event {
UNSOL_EVENT_NETWORK_STATE,
UNSOL_EVENT_RADIO_CAPABILITY,
UNSOL_EVENT_COUNT
};
......@@ -90,6 +97,7 @@ struct ril_network_priv {
GRilIoChannel *io;
GRilIoQueue *q;
struct ril_radio *radio;
struct ril_radio_caps *caps;
struct ril_sim_card *simcard;
struct ril_vendor *vendor;
struct ofono_watch *watch;
......@@ -106,6 +114,8 @@ struct ril_network_priv {
gulong set_rat_id;
gulong unsol_event_id[UNSOL_EVENT_COUNT];
gulong settings_event_id;
gulong supported_modes_event_id;
gulong caps_mgr_event_id[RADIO_CAPS_MGR_EVENT_COUNT];
gulong radio_event_id[RADIO_EVENT_COUNT];
gulong simcard_event_id[SIM_EVENT_COUNT];
gulong watch_ids[WATCH_EVENT_COUNT];
......@@ -125,7 +135,6 @@ enum ril_network_signal {
SIGNAL_VOICE_STATE_CHANGED,
SIGNAL_DATA_STATE_CHANGED,
SIGNAL_PREF_MODE_CHANGED,
SIGNAL_MAX_PREF_MODE_CHANGED,
SIGNAL_COUNT
};
......@@ -133,7 +142,6 @@ enum ril_network_signal {
#define SIGNAL_VOICE_STATE_CHANGED_NAME "ril-network-voice-state-changed"
#define SIGNAL_DATA_STATE_CHANGED_NAME "ril-network-data-state-changed"
#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-network-pref-mode-changed"
#define SIGNAL_MAX_PREF_MODE_CHANGED_NAME "ril-network-max-pref-mode-changed"
static guint ril_network_signals[SIGNAL_COUNT] = { 0 };
......@@ -525,6 +533,17 @@ static int ril_network_mode_to_rat(struct ril_network *self,
}
}
enum ofono_radio_access_mode ril_network_max_supported_mode
(struct ril_network *self)
{
struct ril_sim_settings *settings = self->settings;
struct ril_network_priv *priv = self->priv;
const struct ril_radio_caps *caps = priv->caps;
return caps ? __ofono_radio_access_max_mode(caps->supported_modes) :
__ofono_radio_access_max_mode(settings->techs);
}
static enum ofono_radio_access_mode ril_network_actual_pref_mode
(struct ril_network *self)
{
......@@ -548,9 +567,16 @@ static enum ofono_radio_access_mode ril_network_actual_pref_mode
* and max_pref_mode are not ANY, we pick the smallest value.
* Otherwise we take any non-zero value if there is one.
*/
return (settings->pref_mode && max_pref_mode) ?
const enum ofono_radio_access_mode pref_mode =
(settings->pref_mode && max_pref_mode) ?
MIN(settings->pref_mode, max_pref_mode) :
settings->pref_mode ? settings->pref_mode : max_pref_mode;
/* Do not try to set unsupported mode */
const enum ofono_radio_access_mode max_mode =
ril_network_max_supported_mode(self);
return pref_mode ? MIN(pref_mode, max_mode) : max_mode;
}
static gboolean ril_network_need_initial_attach_apn(struct ril_network *self)
......@@ -561,9 +587,9 @@ static gboolean ril_network_need_initial_attach_apn(struct ril_network *self)
if (watch->gprs && radio->state == RADIO_STATE_ON) {
switch (ril_network_actual_pref_mode(self)) {
case OFONO_RADIO_ACCESS_MODE_ANY:
case OFONO_RADIO_ACCESS_MODE_LTE:
return TRUE;
case OFONO_RADIO_ACCESS_MODE_ANY:
case OFONO_RADIO_ACCESS_MODE_UMTS:
case OFONO_RADIO_ACCESS_MODE_GSM:
break;
......@@ -968,6 +994,14 @@ static void ril_network_check_pref_mode(struct ril_network *self,
}
}
static void ril_network_assert_pref_mode(struct ril_network *self)
{
struct ril_network_priv *priv = self->priv;
priv->assert_rat = TRUE;
ril_network_check_pref_mode(self, FALSE);
}
static int ril_network_parse_pref_resp(const void *data, guint len)
{
GRilIoParser rilp;
......@@ -997,10 +1031,10 @@ static void ril_network_startup_query_pref_mode_cb(GRilIoChannel *io,
}
/*
* Unlike ril_network_query_pref_mode_cb, this one always
* checks the preferred mode.
* At startup, the device may have an inconsistency between
* voice and data network modes, so it needs to be asserted.
*/
ril_network_check_pref_mode(self, FALSE);
ril_network_assert_pref_mode(self);
}
}
......@@ -1053,19 +1087,79 @@ void ril_network_set_max_pref_mode(struct ril_network *self,
DBG_(self, "rat mode %d (%s)", max_mode,
ofono_radio_access_mode_to_string(max_mode));
self->max_pref_mode = max_mode;
ril_network_emit(self, SIGNAL_MAX_PREF_MODE_CHANGED);
ril_network_check_initial_attach_apn(self);
}
ril_network_check_pref_mode(self, TRUE);
}
}
void ril_network_assert_pref_mode(struct ril_network *self, gboolean immediate)
static void ril_network_supported_modes_handler(struct ril_radio_caps *caps,
void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
DBG_(self, "%s", ofono_radio_access_mode_to_string
(caps->supported_modes));
ril_network_check_pref_mode(self, TRUE);
}
static void ril_network_radio_capability_tx_done_cb
(struct ril_radio_caps_manager *mgr, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
DBG_(self, "");
ril_network_assert_pref_mode(self);
}
static void ril_network_release_radio_caps(struct ril_network *self)
{
struct ril_network_priv *priv = self->priv;
struct ril_radio_caps *caps = priv->caps;
priv->assert_rat = TRUE;
ril_network_check_pref_mode(self, immediate);
if (caps) {
ril_radio_caps_manager_remove_all_handlers(caps->mgr,
priv->caps_mgr_event_id);
ril_radio_caps_remove_handler(caps,
priv->supported_modes_event_id);
ril_radio_caps_unref(caps);
priv->caps = NULL;
priv->supported_modes_event_id = 0;
}
}
static void ril_network_attach_radio_caps(struct ril_network *self,
struct ril_radio_caps *caps)
{
struct ril_network_priv *priv = self->priv;
priv->caps = ril_radio_caps_ref(caps);
priv->supported_modes_event_id =
ril_radio_caps_add_supported_modes_handler(caps,
ril_network_supported_modes_handler, self);
priv->caps_mgr_event_id[RADIO_CAPS_MGR_TX_DONE] =
ril_radio_caps_manager_add_tx_done_handler(caps->mgr,
ril_network_radio_capability_tx_done_cb, self);
priv->caps_mgr_event_id[RADIO_CAPS_MGR_TX_ABORTED] =
ril_radio_caps_manager_add_tx_aborted_handler(caps->mgr,
ril_network_radio_capability_tx_done_cb, self);
}
void ril_network_set_radio_caps(struct ril_network *self,
struct ril_radio_caps *caps)
{
if (self) {
struct ril_network_priv *priv = self->priv;
if (priv->caps != caps) {
ril_network_release_radio_caps(self);
if (caps) {
ril_network_attach_radio_caps(self, caps);
}
ril_network_check_pref_mode(self, TRUE);
}
}
}
gulong ril_network_add_operator_changed_handler(struct ril_network *self,
......@@ -1096,13 +1190,6 @@ gulong ril_network_add_pref_mode_changed_handler(struct ril_network *self,
SIGNAL_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *self,
ril_network_cb_t cb, void *arg)
{
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
SIGNAL_MAX_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
}
void ril_network_remove_handler(struct ril_network *self, gulong id)
{
if (G_LIKELY(self) && G_LIKELY(id)) {
......@@ -1125,16 +1212,6 @@ static void ril_network_state_changed_cb(GRilIoChannel *io, guint code,
ril_network_poll_state(self);
}
static void ril_network_radio_capability_changed_cb(GRilIoChannel *io,
guint code, const void *data, guint len, void *user_data)
{
struct ril_network *self = RIL_NETWORK(user_data);
DBG_(self, "");
GASSERT(code == RIL_UNSOL_RADIO_CAPABILITY);
ril_network_assert_pref_mode(self, FALSE);
}
static void ril_network_radio_state_cb(struct ril_radio *radio, void *data)
{
struct ril_network *self = RIL_NETWORK(data);
......@@ -1267,10 +1344,6 @@ struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
grilio_channel_add_unsol_event_handler(priv->io,
ril_network_state_changed_cb,
RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, self);
priv->unsol_event_id[UNSOL_EVENT_RADIO_CAPABILITY] =
grilio_channel_add_unsol_event_handler(priv->io,
ril_network_radio_capability_changed_cb,
RIL_UNSOL_RADIO_CAPABILITY, self);
priv->radio_event_id[RADIO_EVENT_STATE_CHANGED] =
ril_radio_add_state_changed_handler(priv->radio,
......@@ -1365,6 +1438,7 @@ static void ril_network_finalize(GObject *object)
grilio_channel_remove_all_handlers(priv->io, priv->unsol_event_id);
grilio_channel_unref(priv->io);
grilio_queue_unref(priv->q);
ril_network_release_radio_caps(self);
ril_radio_remove_all_handlers(priv->radio, priv->radio_event_id);
ril_radio_unref(priv->radio);
ril_sim_card_remove_all_handlers(priv->simcard, priv->simcard_event_id);
......@@ -1386,7 +1460,6 @@ static void ril_network_class_init(RilNetworkClass *klass)
RIL_NETWORK_SIGNAL(klass, VOICE_STATE);
RIL_NETWORK_SIGNAL(klass, DATA_STATE);
RIL_NETWORK_SIGNAL(klass, PREF_MODE);
RIL_NETWORK_SIGNAL(klass, MAX_PREF_MODE);
}
/*
......
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2015-2019 Jolla Ltd.
* Copyright (C) 2015-2020 Jolla Ltd.
* Copyright (C) 2020 Open Mobile Platform LLC.
*
* 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
......@@ -21,6 +22,7 @@
#include <glib-object.h>
struct ofono_network_operator;
struct ril_radio_caps;
struct ril_registration_state {
int status; /* enum network_registration_status */
......@@ -42,7 +44,6 @@ struct ril_network {
struct ril_sim_settings *settings;
};
struct ofono_sim;
typedef void (*ril_network_cb_t)(struct ril_network *net, void *arg);
struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
......@@ -54,10 +55,13 @@ struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
struct ril_network *ril_network_ref(struct ril_network *net);
void ril_network_unref(struct ril_network *net);
void ril_network_set_radio_caps(struct ril_network *net,
struct ril_radio_caps *caps);
void ril_network_set_max_pref_mode(struct ril_network *net,
enum ofono_radio_access_mode max_pref_mode,
gboolean force_check);
void ril_network_assert_pref_mode(struct ril_network *net, gboolean immediate);
enum ofono_radio_access_mode ril_network_max_supported_mode
(struct ril_network *self);
void ril_network_query_registration_state(struct ril_network *net);
gulong ril_network_add_operator_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
......@@ -67,8 +71,6 @@ gulong ril_network_add_data_state_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
gulong ril_network_add_pref_mode_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *net,
ril_network_cb_t cb, void *arg);
void ril_network_remove_handler(struct ril_network *net, gulong id);
void ril_network_remove_handlers(struct ril_network *net, gulong *ids, int n);
......
......@@ -230,6 +230,7 @@ typedef struct sailfish_slot_impl {
struct ril_modem *modem;
struct ril_radio *radio;
struct ril_radio_caps *caps;
struct ril_radio_caps_request *caps_req;
struct ril_network *network;
struct ril_sim_card *sim_card;
struct ril_sim_settings *sim_settings;
......@@ -392,7 +393,10 @@ static void ril_plugin_shutdown_slot(ril_slot *slot, gboolean kill_io)
}
if (slot->caps) {
ril_radio_caps_unref(slot->caps);
ril_network_set_radio_caps(slot->network, NULL);
ril_radio_caps_request_free(slot->caps_req);
ril_radio_caps_drop(slot->caps);
slot->caps_req = NULL;
slot->caps = NULL;
}
......@@ -906,7 +910,7 @@ static void ril_plugin_radio_caps_cb(const struct ril_radio_capability *cap,
plugin->caps_manager = ril_radio_caps_manager_new
(plugin->data_manager);
plugin->caps_manager_event_id =
ril_radio_caps_manager_add_aborted_handler(
ril_radio_caps_manager_add_tx_aborted_handler(
plugin->caps_manager,
ril_plugin_caps_switch_aborted,
plugin);
......@@ -914,9 +918,10 @@ static void ril_plugin_radio_caps_cb(const struct ril_radio_capability *cap,
GASSERT(!slot->caps);
slot->caps = ril_radio_caps_new(plugin->caps_manager,
ril_plugin_log_prefix(slot), slot->io, slot->data,
slot->radio, slot->sim_card, slot->network,
&slot->config, cap);
ril_plugin_log_prefix(slot), slot->io, slot->watch,
slot->data, slot->radio, slot->sim_card,
slot->sim_settings, &slot->config, cap);
ril_network_set_radio_caps(slot->network, slot->caps);
}
}
......@@ -1148,6 +1153,8 @@ static void ril_plugin_slot_modem_changed(struct ofono_watch *w,
slot->modem = NULL;
ril_data_allow(slot->data, RIL_DATA_ROLE_NONE);
ril_radio_caps_request_free(slot->caps_req);
slot->caps_req = NULL;
}
}
......@@ -2192,10 +2199,24 @@ static void ril_plugin_manager_free(ril_plugin *plugin)
static void ril_slot_set_data_role(ril_slot *slot, enum sailfish_data_role r)
{
ril_data_allow(slot->data,
enum ril_data_role role =
(r == SAILFISH_DATA_ROLE_INTERNET) ? RIL_DATA_ROLE_INTERNET :
(r == SAILFISH_DATA_ROLE_MMS) ? RIL_DATA_ROLE_MMS :
RIL_DATA_ROLE_NONE);
RIL_DATA_ROLE_NONE;
ril_data_allow(slot->data, role);
ril_radio_caps_request_free(slot->caps_req);
if (role == RIL_DATA_ROLE_NONE) {
slot->caps_req = NULL;
} else {
const enum ofono_radio_access_mode mode =
(r == SAILFISH_DATA_ROLE_MMS) ?
OFONO_RADIO_ACCESS_MODE_GSM :
__ofono_radio_access_max_mode
(slot->sim_settings->techs);
slot->caps_req = ril_radio_caps_request_new
(slot->caps, mode, role);
}
}
static void ril_slot_enabled_changed(struct sailfish_slot_impl *s)
......
This diff is collapsed.
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2017 Jolla Ltd.
* Copyright (C) 2017-2020 Jolla Ltd.
*
* 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
......@@ -19,12 +19,16 @@
#include "ril_types.h"
struct ril_data_manager;
struct ril_sim_settings;
struct ril_radio_caps;
struct ril_radio_caps_manager;
struct ril_radio_capability;
struct ril_radio_caps_request;
typedef void (*ril_radio_caps_cb_t)(struct ril_radio_caps *caps, void *arg);
typedef void (*ril_radio_caps_manager_cb_t)(struct ril_radio_caps_manager *mgr,
void *user_data);
/* ril_radio_capability pointer is NULL if functionality is unsupported */
typedef void (*ril_radio_caps_check_cb_t)
(const struct ril_radio_capability *cap, void *user_data);
......@@ -39,21 +43,47 @@ struct ril_radio_caps_manager *ril_radio_caps_manager_new
struct ril_radio_caps_manager *ril_radio_caps_manager_ref
(struct ril_radio_caps_manager *mgr);
void ril_radio_caps_manager_unref(struct ril_radio_caps_manager *mgr);
gulong ril_radio_caps_manager_add_aborted_handler
gulong ril_radio_caps_manager_add_tx_aborted_handler
(struct ril_radio_caps_manager *mgr,
ril_radio_caps_manager_cb_t cb, void *arg);
gulong ril_radio_caps_manager_add_tx_done_handler
(struct ril_radio_caps_manager *mgr,
ril_radio_caps_manager_cb_t cb, void *arg);
void ril_radio_caps_manager_remove_handler(struct ril_radio_caps_manager *mgr,
gulong id);
gulong id);
void ril_radio_caps_manager_remove_handlers(struct ril_radio_caps_manager *mgr,
gulong *ids, int count);
#define ril_radio_caps_manager_remove_all_handlers(mgr, ids) \
ril_radio_caps_manager_remove_handlers(mgr, ids, G_N_ELEMENTS(ids))
/* And one ril_radio_caps object per modem */
struct ril_radio_caps {
struct ril_radio_caps_manager *mgr;
enum ofono_radio_access_mode supported_modes;
};
struct ril_radio_caps *ril_radio_caps_new(struct ril_radio_caps_manager *mgr,
const char *log_prefix, GRilIoChannel *io,
struct ofono_watch *watch,
struct ril_data *data, struct ril_radio *radio,
struct ril_sim_card *sim, struct ril_network *net,
struct ril_sim_card *sim, struct ril_sim_settings *settings,
const struct ril_slot_config *config,
const struct ril_radio_capability *cap);
struct ril_radio_caps *ril_radio_caps_ref(struct ril_radio_caps *caps);
void ril_radio_caps_unref(struct ril_radio_caps *caps);
void ril_radio_caps_drop(struct ril_radio_caps *caps);
gulong ril_radio_caps_add_supported_modes_handler
(struct ril_radio_caps *caps,
ril_radio_caps_cb_t cb, void *arg);
void ril_radio_caps_remove_handler(struct ril_radio_caps *caps, gulong id);
/* Data requests */
struct ril_radio_caps_request *ril_radio_caps_request_new
(struct ril_radio_caps *caps, enum ofono_radio_access_mode mode,
enum ril_data_role role);
void ril_radio_caps_request_free(struct ril_radio_caps_request *req);
#endif /* RIL_RADIO_CAPS_H */
......
/*
* oFono - Open Source Telephony - RIL-based devices
*
* Copyright (C) 2016-2018 Jolla Ltd.
* Copyright (C) 2016-2020 Jolla Ltd.
*
* 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
......@@ -45,6 +45,8 @@ gulong ril_sim_settings_add_pref_mode_changed_handler(struct ril_sim_settings *s
void ril_sim_settings_remove_handler(struct ril_sim_settings *s, gulong id);
void ril_sim_settings_remove_handlers(struct ril_sim_settings *s, gulong *ids,
int count);
#define ril_sim_settings_remove_all_handlers(s,ids) \
ril_sim_settings_remove_handlers(s, ids, G_N_ELEMENTS(ids))
#endif /* RIL_SIM_SETTINGS_H */
......
......@@ -24,6 +24,7 @@
#include <grilio_types.h>
#include <gutil_macros.h>
struct ofono_watch;
struct ofono_modem;
struct ofono_sim;
......@@ -49,6 +50,12 @@ struct ril_network;
struct ril_sim_card;
struct ril_vendor;
enum ril_data_role {
RIL_DATA_ROLE_NONE, /* Mobile data not required */
RIL_DATA_ROLE_MMS, /* Data is needed at any speed */
RIL_DATA_ROLE_INTERNET /* Data is needed at full speed */
};
struct ril_slot_config {
guint slot;
enum ofono_radio_access_mode techs;
......
......@@ -283,6 +283,10 @@ enum ofono_gprs_context_type __ofono_gprs_context_get_assigned_type(
struct ofono_gprs_context *gc);
#include <ofono/radio-settings.h>
enum ofono_radio_access_mode __ofono_radio_access_max_mode(
enum ofono_radio_access_mode modes);
#include <ofono/audio-settings.h>
#include <ofono/ctm.h>
#include <ofono/location-reporting.h>
......
......@@ -2,7 +2,8 @@
*
* oFono - Open Source Telephony
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
* Copyright (C) 2014-2020 Jolla Ltd.
*
* 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
......@@ -61,10 +62,22 @@ struct ofono_radio_settings {
struct ofono_atom *atom;
};
enum ofono_radio_access_mode __ofono_radio_access_max_mode(