fixeria has submitted this change. ( 
https://gerrit.osmocom.org/c/osmocom-bb/+/30455 )

Change subject: mobile: support RTP and TI specific TCH frame I/O formats
......................................................................

mobile: support RTP and TI specific TCH frame I/O formats

Change-Id: Ib41f8c39c82c243b62a76433f59a2b98e175f894
Related: OS#3400
---
M src/host/layer23/include/osmocom/bb/mobile/settings.h
M src/host/layer23/src/mobile/gapk_io.c
M src/host/layer23/src/mobile/settings.c
M src/host/layer23/src/mobile/vty_interface.c
4 files changed, 73 insertions(+), 12 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  osmith: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved



diff --git a/src/host/layer23/include/osmocom/bb/mobile/settings.h 
b/src/host/layer23/include/osmocom/bb/mobile/settings.h
index 2800fea..879be54 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/settings.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/settings.h
@@ -31,8 +31,21 @@
 static inline const char *audio_io_handler_name(enum audio_io_handler val)
 { return get_value_string(audio_io_handler_names, val); }

+/* TCH frame I/O format */
+enum audio_io_format {
+       /* RTP format (RFC3551 for FR/EFR, RFC5993 for HR, RFC4867 for AMR) */
+       AUDIO_IOF_RTP,
+       /* Texas Instruments format, used by Calypso based phones (e.g. 
Motorola C1xx) */
+       AUDIO_IOF_TI,
+};
+
+extern const struct value_string audio_io_format_names[];
+static inline const char *audio_io_format_name(enum audio_io_format val)
+{ return get_value_string(audio_io_format_names, val); }
+
 struct audio_settings {
        enum audio_io_handler   io_handler;
+       enum audio_io_format    io_format;
        char alsa_output_dev[128];
        char alsa_input_dev[128];
 };
diff --git a/src/host/layer23/src/mobile/gapk_io.c 
b/src/host/layer23/src/mobile/gapk_io.c
index b2b55d9..4e3cd75 100644
--- a/src/host/layer23/src/mobile/gapk_io.c
+++ b/src/host/layer23/src/mobile/gapk_io.c
@@ -258,22 +258,18 @@
        if (rc)
                goto error;

-#if 0
-       /* TODO: PHY specific format -> canonical */
+       /* PHY specific format -> canonical */
        rc = osmo_gapk_pq_queue_fmt_convert(pq, gapk_io->phy_fmt_desc, 0);
        if (rc)
                goto error;
-#endif

        /* Optional ECU (Error Concealment Unit) */
        osmo_gapk_pq_queue_ecu(pq, gapk_io->codec_desc);

-#if 0
-       /* TODO: canonical -> decoder specific format */
+       /* Canonical -> decoder specific format */
        rc = pq_queue_codec_fmt_conv(pq, gapk_io->codec_desc, false);
        if (rc)
                goto error;
-#endif

        /* Frame decoder */
        rc = osmo_gapk_pq_queue_codec(pq, gapk_io->codec_desc, 0);
@@ -362,6 +358,25 @@
 }

 /**
+ * Picks the corresponding PHY's frame format for a given codec.
+ * To be used with PHYs that produce audio in TI Calypso format.
+ */
+static enum osmo_gapk_format_type phy_fmt_pick_ti(enum osmo_gapk_codec_type 
codec)
+{
+       switch (codec) {
+       case CODEC_HR:
+               return FMT_TI_HR;
+       case CODEC_FR:
+               return FMT_TI_FR;
+       case CODEC_EFR:
+               return FMT_TI_EFR;
+       case CODEC_AMR: /* not supported */
+       default:
+               return FMT_INVALID;
+       }
+}
+
+/**
  * Allocates both TCH frame I/O buffers
  * and prepares both processing queues (chains).
  * Should be called when a voice call is initiated...
@@ -393,12 +408,15 @@
                return -ENOTSUP;
        }

-       /**
-        * Pick the corresponding PHY's frame format
-        * TODO: ask PHY, which format is supported?
-        * FIXME: RTP (valid for trxcon) is used for now
-        */
-       phy_fmt = phy_fmt_pick_rtp(codec);
+       switch (set->audio.io_format) {
+       case AUDIO_IOF_RTP:
+               phy_fmt = phy_fmt_pick_rtp(codec);
+               break;
+       case AUDIO_IOF_TI:
+               phy_fmt = phy_fmt_pick_ti(codec);
+               break;
+       }
+
        phy_fmt_desc = osmo_gapk_fmt_get_from_type(phy_fmt);
        if (phy_fmt_desc == NULL) {
                LOGP(DGAPK, LOGL_ERROR, "Failed to pick the PHY specific "
diff --git a/src/host/layer23/src/mobile/settings.c 
b/src/host/layer23/src/mobile/settings.c
index 02a5ff7..445190e 100644
--- a/src/host/layer23/src/mobile/settings.c
+++ b/src/host/layer23/src/mobile/settings.c
@@ -212,3 +212,9 @@
        { AUDIO_IOH_LOOPBACK,   "loopback" },
        { 0x00, NULL}
 };
+
+const struct value_string audio_io_format_names[] = {
+       { AUDIO_IOF_RTP,        "rtp" },
+       { AUDIO_IOF_TI,         "ti" },
+       { 0x00, NULL}
+};
diff --git a/src/host/layer23/src/mobile/vty_interface.c 
b/src/host/layer23/src/mobile/vty_interface.c
index 3bab608..16eedf2 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -1546,6 +1546,8 @@
        vty_out(vty, "  io-handler %s%s",
                audio_io_handler_name(set->audio.io_handler), VTY_NEWLINE);
        if (set->audio.io_handler == AUDIO_IOH_GAPK) {
+               vty_out(vty, "  io-tch-format %s%s",
+                       audio_io_format_name(set->audio.io_format), 
VTY_NEWLINE);
                vty_out(vty, "  alsa-output-dev %s%s",
                        set->audio.alsa_output_dev, VTY_NEWLINE);
                vty_out(vty, "  alsa-input-dev %s%s",
@@ -2872,6 +2874,27 @@
        return set_audio_io_handler(vty, AUDIO_IOH_NONE);
 }

+DEFUN(cfg_ms_audio_io_tch_format, cfg_ms_audio_io_tch_format_cmd,
+       "io-tch-format (rtp|ti)",
+       "Set TCH I/O frame format used by the L1 PHY (for GAPK only)\n"
+       "RTP format (RFC3551 for FR/EFR, RFC5993 for HR, RFC4867 for AMR)\n"
+       "Texas Instruments format, used by Calypso based phones (e.g. Motorola 
C1xx)\n")
+{
+       int val = get_string_value(audio_io_format_names, argv[0]);
+       struct osmocom_ms *ms = (struct osmocom_ms *) vty->index;
+       struct gsm_settings *set = &ms->settings;
+
+       if (set->audio.io_handler != AUDIO_IOH_GAPK) {
+               vty_out(vty, "This parameter is only valid for GAPK%s", 
VTY_NEWLINE);
+               return CMD_WARNING;
+       }
+
+       OSMO_ASSERT(val >= 0);
+       set->audio.io_format = val;
+
+       return CMD_SUCCESS;
+}
+
 DEFUN(cfg_ms_audio_alsa_out_dev, cfg_ms_audio_alsa_out_dev_cmd,
        "alsa-output-dev (default|NAME)",
        "Set ALSA output (playback) device name (for GAPK only)\n"
@@ -3176,6 +3199,7 @@
        install_node(&audio_node, config_write_dummy);
        install_element(AUDIO_NODE, &cfg_ms_audio_io_handler_cmd);
        install_element(AUDIO_NODE, &cfg_ms_audio_no_io_handler_cmd);
+       install_element(AUDIO_NODE, &cfg_ms_audio_io_tch_format_cmd);
        install_element(AUDIO_NODE, &cfg_ms_audio_alsa_out_dev_cmd);
        install_element(AUDIO_NODE, &cfg_ms_audio_alsa_in_dev_cmd);


--
To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/30455
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Ib41f8c39c82c243b62a76433f59a2b98e175f894
Gerrit-Change-Number: 30455
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to