Make qcom-msim plugin able to use other SIM slot than first SIM slot. #188

Merged
merged 6 commits into from Jun 12, 2015

Conversation

Projects
None yet
3 participants
Contributor

peat-psuwit commented Jun 1, 2015

This is improvement of qcom-msim plugin that allow you to use other SIM slot and be able to select which SIM will prefer 3G. This modem has limitation that only 1 SIM can prefer 3G at a time, so the new radio-settings driver will make sure that other SIMs prefer 2G before setting a SIM to prefer 3G. I code this to support more than 2 SIM slots, but there are some constants which assume that only 2 SIM slots are available. If, in the future, there are phones with more than 2 SIM slots, these constants can be edited to support them.

plugins/ril.h
@@ -19,6 +19,18 @@
*
*/
+struct ril_data {
+ struct _GRil *ril;
@alfonsosanchezbeato

alfonsosanchezbeato Jun 2, 2015

Contributor

Please keep this as "GRil" instead of "struct _GRil"

drivers/qcommsimmodem/radio-settings.c
+ struct pending_pref_setting *pps;
+};
+
+#define MULTISIM_RS_LAST 2
@alfonsosanchezbeato

alfonsosanchezbeato Jun 2, 2015

Contributor

This should be defined in a header specific to your driver, something like drivers/qcommsimmodem/qcomutil.h, so you can share with other atoms if/when needed.

include/radio-settings.h
@@ -136,6 +136,9 @@ void ofono_radio_settings_remove(struct ofono_radio_settings *rs);
void ofono_radio_settings_set_data(struct ofono_radio_settings *rs, void *data);
void *ofono_radio_settings_get_data(struct ofono_radio_settings *rs);
+void radio_set_rat_mode(struct ofono_radio_settings *rs,
@alfonsosanchezbeato

alfonsosanchezbeato Jun 2, 2015

Contributor

If you need to export this, please change the name to ofono_radio_set_rat_mode()

Contributor

alfonsosanchezbeato commented Jun 2, 2015

The main issue I see is that the changes to plugins/qcom-msim.c and plugins/ril.* are not needed. I would rather change "create_gril" in ril.c to support multi-sim, which is simply a matter of retrieving the slot number and using it in a couple of places. Having one slot would still work. To create your specific radio-settings driver you can compare rd->vendor to OFONO_RIL_VENDOR_QCOM_MSIM and use RILMODEM or QCOMMSIMMODEM depending on that.

Beside that, in general looks great to me.

Contributor

peat-psuwit commented Jun 2, 2015

Ok, new commits pushed.

drivers/qcommsimmodem/qcom_msim_util.h
+ *
+ */
+
+#define MULTISIM_RS_LAST 2
@alfonsosanchezbeato

alfonsosanchezbeato Jun 3, 2015

Contributor

This should be renamed to something like QCOMMSIM_NUM_SLOTS

drivers/qcommsimmodem/qcom_msim_util.h
+
+#define MULTISIM_RS_LAST 2
+
+struct qcom_msim_pending_pref_setting {
@alfonsosanchezbeato

alfonsosanchezbeato Jun 3, 2015

Contributor

Defining the number of slots here makes sense, but I do not see the reason for defining in the header qcom_msim_pending_pref_setting and qcom_msim_set_2g_rat, which would be used only in the RS atom

@peat-psuwit

peat-psuwit Jun 3, 2015

Contributor

Then there would be only SIM slots amount defined in this file. Maybe I should move this constant to another file. qcom_msim_constants.h?

@alfonsosanchezbeato

alfonsosanchezbeato Jun 3, 2015

Contributor

I think that can be fine too

drivers/qcommsimmodem/radio-settings.c
+#include "qcom_msim_modem.h"
+#include "qcom_msim_util.h"
+
+static struct ofono_radio_settings *multisim_rs[MULTISIM_RS_LAST] = {};
@alfonsosanchezbeato

alfonsosanchezbeato Jun 3, 2015

Contributor

Remove the initialization or use { NULL } instead (you need to set the default value for the first array element, letting empty braces do the same is a gcc extension iirc)

drivers/qcommsimmodem/radio-settings.c
+ return FALSE;
+}
+
+static void qcom_msim_query_modem_rats(struct ofono_radio_settings *rs,
@alfonsosanchezbeato

alfonsosanchezbeato Jun 3, 2015

Contributor

This implementation is the same as the rilmodem one. Please declare ril_query_modem_rats in "drivers/rilmodem/radio-settings.h" and use it instead.

plugins/ril.c
@@ -70,7 +71,8 @@
#define RILD_MAX_CONNECT_RETRIES 5
#define RILD_CONNECT_RETRY_TIME_S 5
-#define RILD_CMD_SOCKET "/dev/socket/rild"
+char *RILD_CMD_SOCKET[2] = {"/dev/socket/rild", "/dev/socket/rild1"};
+char *GRIL_HEX_PREFIX[2] = {"Device 0: ", "Device 1: "};
@alfonsosanchezbeato

alfonsosanchezbeato Jun 3, 2015

Contributor

You do not need the "2" in these two definitions.

peat-psuwit added some commits Jun 2, 2015

plugins/ril: add support for multiple SIM slots.
This is accomplished by connecting to different socket for different
slot. Currently, there are only 2 socket paths for 2 slots, but if
there are phones with more than 2 SIM slots, more paths can be easily
added.
radio-settings: make radio_set_rat_mode public.
This is needed to make driver be able to change radio mode without
being called from radio-settings. To do this, the function name
is changed to ofono_radio_settings_set_rat_mode.
Contributor

tonyespy commented Jun 5, 2015

This looks pretty good, however in addition to a couple of in-line comments, there are a few issues with the commits themselves.

First, ofono uses the 50/72 rule for commit short/long descriptions.

Please revise:

  • "rilmodem: declare ril_query_modem_rats..."; I would suggest:

"rilmodem: export ril_query_modem_rats
Export ril_query_modem_rats in radio_settings header
so that it can be used by other rilmodem-based drivers."

  • qcommsimmodem: Add new radio-settings...."; I would suggest:

    "qcommsimmodem: Add radio-settings atom

    This atom ensures that only one modem slot can be
    used for 3g at any given time. When a modem slot's
    radio technology is set to 3g, this atom will set the other
    slot to 2g first."

Also, please split out the build change from the qcommsimmodem commit. It should be a subsequent commit which enables the new directory in the Makefile. Eg.

build: enable qcommsimmodem radio-settings atom

Finally, does your device support LTE, or is it a 3g only device?

drivers/qcommsimmodem/radio-settings.c
+ }
+
+ if (pref != PREF_NET_TYPE_GSM_ONLY && multisim_rs_amount > 1) {
+ struct qcom_msim_pending_pref_setting *pps = g_try_new0(
@tonyespy

tonyespy Jun 5, 2015

Contributor

I think I'd prefer to see this wrapped after the =, so it'd look like this:

struct qcom_msim_pending_pref_setting *pps =
                g_try_new0(struct qcom_msim_pending_pref_setting, 1); 
+ pps->cbd = NULL;
+ g_free(cbd);
+ g_free(set_2g_rat_data);
+ CALLBACK_WITH_FAILURE(cb, data);
@tonyespy

tonyespy Jun 5, 2015

Contributor

I think you need to free pps too, otherwise you have a leak.

drivers/qcommsimmodem/radio-settings.c
+ if (multisim_rs[i] == rs)
+ continue;
+
+ current_rd = ofono_radio_settings_get_data(
@tonyespy

tonyespy Jun 5, 2015

Contributor

You might want to change this to temp_rd, as it confused me because it's not really the current_rd ( ie. you return if multisim_rs[i] == rs ). Maybe temp_rd would be a better name?

drivers/qcommsimmodem/radio-settings.c
+};
+
+static struct ofono_radio_settings *multisim_rs[QCOMMSIM_NUM_SLOTS_MAX];
+static int multisim_rs_amount;
@tonyespy

tonyespy Jun 5, 2015

Contributor

I would change this to multisim_num_slots.

Contributor

peat-psuwit commented Jun 6, 2015

@tonyespy My device, LG L90 Dual, is 3G only device. But I think other dual SIM with LTE device from Qualcomm will benefit from this too.

rilmodem: export ril_query_modem_rats
Export ril_query_modem_rats in radio_settings header
so that it can be used by other rilmodem-based drivers.
drivers/qcommsimmodem/radio-settings.c
+ continue;
+
+ temp_rd = ofono_radio_settings_get_data(
+ multisim_rs[i]);
@tonyespy

tonyespy Jun 10, 2015

Contributor

The above line doesn't need to be wrapped; un-wrapped it's exactly 80 characters.

drivers/qcommsimmodem/radio-settings.c
+ temp_rd = ofono_radio_settings_get_data(
+ multisim_rs[i]);
+ set_2g_rat_data = g_try_new0(
+ struct qcom_msim_set_2g_rat, 1);
@tonyespy

tonyespy Jun 10, 2015

Contributor

Please wrap the above line after the "=". It's easier to read. You'll find plenty of wraps after "=", but zero function calls ( at least that I could find ) with the first parameter wrapped like this.

drivers/qcommsimmodem/radio-settings.c
+ set_2g_rat_data->rs = multisim_rs[i];
+
+ g_ril_request_set_preferred_network_type(
+ temp_rd->ril,
@tonyespy

tonyespy Jun 10, 2015

Contributor

Please put "temp_rd->ril," on the same line as the function name, as it fits within the 80 char limit and again prevents a line ending with "(".

drivers/qcommsimmodem/radio-settings.c
+};
+
+static struct ofono_radio_settings *multisim_rs[QCOMMSIM_NUM_SLOTS_MAX];
+static int multisim_num_slot;
@tonyespy

tonyespy Jun 10, 2015

Contributor

This really should be plural... multisim_num_slots, as that's what it is, the number of slots.

Contributor

tonyespy commented Jun 10, 2015

Thanks for re-working the commit messages and addressing my comments. I still have three more formatting issues ( see inline comments ) that need fixing, and then it'll be good to merge.

Contributor

tonyespy commented Jun 10, 2015

Actually one other comment. I asked about whether or not your device supported LTE, as your code as written makes the same assumption about LTE as it does 3G with respect to slot capabilities. If the user sets the radio tech of one of the slots/modems to LTE, then the other slot is set first to 2G ( same as for 3G ), but it might be possible for one slot to do LTE and the other 3G. I guess we won't know till we see a QCom dual-SIM that supports LTE, so let's leave this as is.

Contributor

tonyespy commented Jun 11, 2015

@ratchanan

Please add a comment whenever you update, as it makes it a bit easier to notice.

Thanks for the last round of changes... It's almost merge-able, however when you changed the multisim_num_slots variable, you only changed its declaration, not it's usage elsewhere in the file, so the code doesn't compile.

peat-psuwit added some commits Jun 2, 2015

qcommsimmodem: Add radio-settings atom
This atom ensures that only one modem slot can be
used for 3g at any given time. When a modem slot's
radio technology is set to 3g, this atom will set the other
slot to 2g first.
Contributor

peat-psuwit commented Jun 11, 2015

@tonyespy Ok, new version pushed. It was shameful to forget that. I'll keep that as a lesson.

Contributor

tonyespy commented Jun 12, 2015

Approved.

tonyespy added a commit that referenced this pull request Jun 12, 2015

Merge pull request #188 from peat-psuwit/lg-d410-msim-merge
Make qcom-msim plugin able to use other SIM slot than first SIM slot.

@tonyespy tonyespy merged commit b2ce438 into rilmodem:master Jun 12, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment