view src/aci2/aci/cmh_mmis.c @ 600:8f50b202e81f

board preprocessor conditionals: prep for more FC hw in the future This change eliminates the CONFIG_TARGET_FCDEV3B preprocessor symbol and all preprocessor conditionals throughout the code base that tested for it, replacing them with CONFIG_TARGET_FCFAM or CONFIG_TARGET_FCMODEM. These new symbols are specified as follows: CONFIG_TARGET_FCFAM is intended to cover all hardware designs created by Mother Mychaela under the FreeCalypso trademark. This family will include modem products (repackagings of the FCDEV3B, possibly with RFFE or even RF transceiver changes), and also my desired FreeCalypso handset product. CONFIG_TARGET_FCMODEM is intended to cover all FreeCalypso modem products (which will be firmware-compatible with the FCDEV3B if they use TI Rita transceiver, or will require a different fw build if we switch to one of Silabs Aero transceivers), but not the handset product. Right now this CONFIG_TARGET_FCMODEM preprocessor symbol is used to conditionalize everything dealing with MCSI. At the present moment the future of FC hardware evolution is still unknown: it is not known whether we will ever have any beyond-FCDEV3B hardware at all (contingent on uncertain funding), and if we do produce further FC hardware designs, it is not known whether they will retain the same FIC modem core (triband), if we are going to have a quadband design that still retains the classic Rita transceiver, or if we are going to switch to Silabs Aero II or some other transceiver. If we produce a quadband modem that still uses Rita, it will run exactly the same fw as the FCDEV3B thanks to the way we define TSPACT signals for the RF_FAM=12 && CONFIG_TARGET_FCFAM combination, and the current fcdev3b build target will be renamed to fcmodem. OTOH, if that putative quadband modem will be Aero-based, then it will require a different fw build target, the fcdev3b target will stay as it is, and the two targets will both define CONFIG_TARGET_FCFAM and CONFIG_TARGET_FCMODEM, but will have different RF_FAM numbers. But no matter which way we are going to evolve, it is not right to have conditionals on CONFIG_TARGET_FCDEV3B in places like ACI, and the present change clears the way for future evolution.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 01 Apr 2019 01:05:24 +0000
parents 93999a60b835
children
line wrap: on
line source

/* 
+----------------------------------------------------------------------------- 
|  Project :  GSM-PS (6147)
|  Modul   :  CMH_MMIS
+----------------------------------------------------------------------------- 
|  Copyright 2002 Texas Instruments Berlin, AG 
|                 All rights reserved. 
| 
|                 This file is confidential and a trade secret of Texas 
|                 Instruments Berlin, AG 
|                 The receipt of or possession of this file does not convey 
|                 any rights to reproduce or disclose its contents or to 
|                 manufacture, use, or sell anything it may describe, in 
|                 whole, or in part, without the specific written consent of 
|                 Texas Instruments Berlin, AG. 
+----------------------------------------------------------------------------- 
|  Purpose :  This module provides the set functions related to the 
|             protocol stack adapter for the man machine interface.
+----------------------------------------------------------------------------- 
*/ 

#ifndef CMH_MMIS_C
#define CMH_MMIS_C
#endif

#include "aci_all.h"

/*==== INCLUDES ===================================================*/
#include "aci_cmh.h"
#include "ati_cmd.h"
#include "aci_cmd.h"
#include "psa_mmi.h"
#include "cmh_mmi.h"
#include "pcm.h"

#ifdef UART
#include "dti.h"      /* functionality of the dti library */
#include "dti_conn_mng.h"
#endif

#ifdef FAX_AND_DATA
#include "aci_fd.h"
#endif    /* of #ifdef FAX_AND_DATA */
#include "psa.h"
#include "psa_sim.h"
#include "cmh.h"
#include "cmh_sim.h"
#include "cmh_cc.h"
#include "aoc.h"

#include "aci_prs.h"

#ifdef ACI
#include "gdi.h"
#include "audio.h"
#include "aci_lst.h"
#include "ati_int.h"
#endif

/*==== CONSTANTS ==================================================*/

/*==== EXPORT =====================================================*/

/*==== VARIABLES ==================================================*/

/*==== FUNCTIONS ==================================================*/

/*=================================================================*/

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : CMH_MMIS                 |
| STATE   : code                  ROUTINE : sAT_PercentDRV           |
+--------------------------------------------------------------------+

  PURPOSE : This is the functional counterpart to the %DRV AT command
            which is responsible to set the parameters for relatet 
            operations regarding audio and keyboard.

            <device>:      defines the addressed device.
            <function>:    defines the function to access 
            <val1>,<val2>: additional parameters
*/
#if 0
GLOBAL T_ACI_RETURN sAT_PercentDRV( T_ACI_CMD_SRC srcId,
                                    T_ACI_DRV_DEV device, 
                                    T_ACI_DRV_FCT function,
                                    UBYTE         val1,
                                    UBYTE         val2,
                                    void*         ptr1 )
{

  TRACE_FUNCTION ("sAT_PercentDRV()");
  
  /* process the <device> and <function> parameter */  
  if(device EQ DRV_DEV_Display )
  { 
    if(function EQ DRV_FCT_DisplayReq )
    {
       mmiShrdPrm.dspRq = ptr1;
       psaMMI_Display();
       return( AT_CMPL );
    }
  }
  return(AT_FAIL);
}
#endif

/*
+-------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)    MODULE  : CMH_MMIS                     |
| STATE   : code             ROUTINE : sAT_PlusCLAN                 |
+-------------------------------------------------------------------+

  PURPOSE : PURPOSE : This is the functional counterpart to the +CLAN
            AT command which is responsible for test supporetd 
            language  code in ME.

            <lngCode>: string language Code
*/
GLOBAL T_ACI_RETURN sAT_PlusCLAN ( T_ACI_CMD_SRC  srcId, 
                                   T_ACI_LAN_SUP  *lngCode)
                                   
{
  CHAR          *ef = EF_CLNG_ID;
  EF_CLNG       lng; 
  CHAR          *auptr="au";
  T_SIM_CMD_PRM *pSIMCmdPrm; /* points to SIM command parameters  */
  T_PHB_CMD_PRM *pPHBCmdPrm; /* points to PHB command parameter */
  T_ACI_LAN_SUP LngPCMsupLst[MAX_LAN]; 
  SHORT         lastIdx;
  BOOL          Suplng = FALSE;
  
  TRACE_FUNCTION ("sAT_PlusCLAN ()");

  /*
   *-----------------------------------------------------------------
   * check command source
   *-----------------------------------------------------------------
   */  
  if(!cmh_IsVldCmdSrc (srcId)) 
  { 
    ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
    return( AT_FAIL );
  }

  pSIMCmdPrm = &cmhPrm[srcId].simCmdPrm; 
  pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm;

/*
 *-------------------------------------------------------------------
 *  if Automatic language is set then read language from the sim   
 *-------------------------------------------------------------------
 */  
  if ( lngCode->lng EQ CLAN_LNG_AUT )
  {
    /*
     *-------------------------------------------------------------
     * check entity status
     *-------------------------------------------------------------
     */  
     if( simEntStat.curCmd NEQ AT_CMD_NONE )
      return( AT_BUSY );

     pSIMCmdPrm->CLANact=CLAN_ACT_Write;
    /*
     *-------------------------------------------------------------
     * request EF ELP from SIM
     *-------------------------------------------------------------
     */  
    return cmhSIM_ReqLanguage (srcId);
  }     
  
  /*
   *-------------------------------------------------------------
   * check if the language is supported in PCM
   *-------------------------------------------------------------
   */      
   getSupLangFromPCM(&LngPCMsupLst[0], &lastIdx);
   Suplng=checkSuppLang(&LngPCMsupLst[0],lastIdx, lngCode); 
   
   if (Suplng)
   {
     /*
      *-------------------------------------------------------------
      * copy the set code and write it in PCM
      *-------------------------------------------------------------
      */    
      
      memcpy ( lng.data, lngCode->str,CLAN_CODE_LEN);

      if ( pcm_WriteFile (( UBYTE* )ef,SIZE_EF_CLNG,( UBYTE*) &lng) EQ PCM_OK)
      {
        
       /*
        *-------------------------------------------------------------
        * check if the result code after setting is enabled
        *-------------------------------------------------------------
        */      
        if (pPHBCmdPrm->CLAEmode EQ CLAE_MOD_Enable)  
        {R_AT( RAT_CLAE, srcId ) (lngCode);}
        return( AT_CMPL );
      }
      else 
      {
        ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_MemFail );
        return( AT_FAIL );
      }

   }
   else 
   {
     ACI_ERR_DESC( ACI_ERR_CLASS_Cme, CME_ERR_Unknown );
     return( AT_FAIL );
   }

}

/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : CMH_MMIS                 |
| STATE   : code                  ROUTINE : sAT_PlusCLAE             |
+--------------------------------------------------------------------+

  PURPOSE : This is the functional counterpart to the +CLAE AT command
            which is responsible to enable or disable the presentation
            of Language Event.

*/

GLOBAL T_ACI_RETURN sAT_PlusCLAE ( T_ACI_CMD_SRC srcId,
                                   T_ACI_CLAE_MOD mode )
{
  T_PHB_CMD_PRM * pPHBCmdPrm; /* points to PHB command parameter */

  TRACE_FUNCTION ("sAT_PlusCLAE()");

/*
 *-------------------------------------------------------------------
 * check command source
 *-------------------------------------------------------------------
 */
  if(!cmh_IsVldCmdSrc (srcId))
  {
    ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
    return( AT_FAIL );
  }

  pPHBCmdPrm = &cmhPrm[srcId].phbCmdPrm;

/*
 *-------------------------------------------------------------------
 * process the mode parameter
 *-------------------------------------------------------------------
 */
  switch( mode )
  {
    case( CLAE_MOD_Disable ):
    case( CLAE_MOD_Enable  ):
      pPHBCmdPrm -> CLAEmode = mode;
      break;

    default:
      ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
      return( AT_FAIL );
  }

  return( AT_CMPL );
}


/*
+-------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : CMH_MMIS                |
|                                 ROUTINE : sAT_PercentCUST  |
+-------------------------------------------------------------------+

PURPOSE :    This function will set the customisation mode for the ACI and
                    other required entities
*/ 

GLOBAL T_ACI_RETURN sAT_PercentCUST( T_ACI_CMD_SRC srcId,
                                          T_CUST_MOD customisation_mode)
{
    /*
    *-------------------------------------------------------------------
    * check command source
    *-------------------------------------------------------------------
    */  
    if(!cmh_IsVldCmdSrc (srcId)) 
    { 
        ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
        return( AT_FAIL );
    }

    /*
    ** This command is only valid before the ME is put into Fully Functional Mode
    */
    if (psaSIM_hasCustModeBeenSet() != FALSE)
    {
        ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Unknown);
        return( AT_FAIL );
    }

    /*
    ** Switch on the Customisation mode
    */
    switch (customisation_mode)
    {
        case CUST_NORMAL_BEHAVIOUR: /* Default Value, No Customisation */
        case CUST_MODE_BEHAVIOUR_1: /* Cust1 */

            if (simShrdPrm.setPrm[srcId].cust_mode != customisation_mode)
            {
                /*
                ** Set the customisation mode, and notify ALL other affected entities
                */
                simShrdPrm.setPrm[srcId].cust_mode = customisation_mode;
            }
            break;

        default:
            /*
            ** This is an error
            */
            ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
            return (AT_FAIL);
    }

    return (AT_CMPL);

}


/*
+-------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : CMH_MMIS                |
|                                 ROUTINE : sAT_PercentSATCC  |
+-------------------------------------------------------------------+

PURPOSE :    This function will set the call and short message control by SIM functionality
                    to Enabled or Disabled according to the value in sat_cc_mode.
*/ 

GLOBAL T_ACI_RETURN sAT_PercentSATCC( T_ACI_CMD_SRC srcId,
                                          T_SAT_CC_MOD sat_cc_mode)
{
    /*
    *-------------------------------------------------------------------
    * check command source
    *-------------------------------------------------------------------
    */  
    if(!cmh_IsVldCmdSrc (srcId)) 
    { 
        ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
        return( AT_FAIL );
    }

    /*
    ** Enable or Disbale the Call or Short Message Control by SIM, according to the passed parameter
    */
    switch (sat_cc_mode)
    {
        case SATCC_CONTROL_BY_SIM_INACTIVE:
        case SATCC_CONTROL_BY_SIM_ACTIVE:
            simShrdPrm.setPrm[srcId].sat_cc_mode = sat_cc_mode;
            break;

        default:
            ACI_ERR_DESC( ACI_ERR_CLASS_Ext, EXT_ERR_Parameter );
            return( AT_FAIL );
    }
    
    return (AT_CMPL);

}


/* 
 * Implemetation of IBT handling by ME for ACI only stacks
 */

#ifdef ACI

/*
+-------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : CMH_MMIS                |
|                                 ROUTINE : cmhMMI_setAudioVolume   |
+-------------------------------------------------------------------+

PURPOSE : This function sets the volume for the audio input and
          audio output path.

          <audioIn>:  input volume
          <audioOut>: output volume
*/ 

GLOBAL void cmhMMI_setAudioVolume (BYTE audioIn, BYTE audioOut)
{
  TRACE_FUNCTION("cmhMMI_setAudioVolume");

  audio_SetAmplf (AUDIO_MICROPHONE, audioIn);
  audio_SetAmplf (AUDIO_SPEAKER,    audioOut);

}

/*
+-------------------------------------------------------------------+
| PROJECT : GSM-PS (6147)         MODULE  : CMH_MMIS                |
|                                 ROUTINE : cmhMMI_handleAudioTone  |
+-------------------------------------------------------------------+

PURPOSE : This function is to switch on/off a specified tone.

          <cmdId>:    command identifier
          <response>: response type
          <msgType>:  CPI message type
*/ 

GLOBAL void cmhMMI_handleAudioTone (T_ACI_AT_CMD  cmdId,
                                    UBYTE         response,
                                    T_ACI_CPI_MSG msgType )
{
  T_ACI_IBT_ACT new_audio_action = SWITCH_AUDIO_NONE;

  TRACE_FUNCTION("cmhMMI_handleAudioTone");

  /* only for test purposes */
  /*ibt_params.ati_currTch = CPI_TCH_False;*/

  switch (response)
  {
  case RAT_CCWA:
    new_audio_action = SWITCH_AUDIO_CALLWAIT;
    break;

  case RAT_BUSY:
    new_audio_action = SWITCH_AUDIO_BUSY;
    break;

  case RAT_OK:
    if ((cmdId EQ AT_CMD_H) OR (cmdId EQ AT_CMD_D) OR (cmdId EQ AT_CMD_CTFR))
    {
      new_audio_action = SWITCH_AUDIO_OFF;
    }
    break;

  case RAT_CONNECT:
    if ((ibt_params.ati_currIbt NEQ CPI_IBT_True) OR 
        (ibt_params.ati_currTch NEQ CPI_TCH_True))
    {
      new_audio_action = SWITCH_AUDIO_OFF;
    }
    break;

  case RAT_NO_ANSWER:
  case RAT_NO_CARRIER:
    if (cmdId EQ AT_CMD_D)
    {
      new_audio_action = SWITCH_AUDIO_OFF;
    }
    break;

  case RAT_CPI:
    /* The network is not allowed to stop the BUSY tone.
       This can only be done by ATH */
    if (ibt_params.last_action NEQ SWITCH_AUDIO_BUSY)
    {
      if ((ibt_params.ati_currIbt EQ CPI_IBT_True) AND
          (ibt_params.ati_currTch EQ CPI_TCH_True))
      {
        new_audio_action = SWITCH_AUDIO_OFF;
      }
      else
      {
        if ((msgType EQ CPI_MSG_Disc) OR (msgType EQ CPI_MSG_Conn))
        {
          new_audio_action = SWITCH_AUDIO_OFF;
        }
        else if (msgType EQ CPI_MSG_Alert)
        {
          new_audio_action = SWITCH_AUDIO_ALERT;
        }
      }
    } /* if (ibt_params.last_action NEQ SWITCH_AUDIO_BUSY) */
    break;

  case RAT_CME:
    if ((cmdId EQ AT_CMD_D) OR (cmdId EQ AT_CMD_CHLD))
    {
      if (curAbrtCmd NEQ AT_CMD_ABRT)
      {
        new_audio_action = SWITCH_AUDIO_OFF;
      }
    }
    break;

  default:
    break;
  }

  if (new_audio_action EQ ibt_params.last_action)
  {
    if(!((rdlPrm.rdlMod EQ AUTOM_REPEAT_ON) AND (rdlPrm.rdlcId NEQ -1)))
    {
    /* it is not necessary to perform the same action twice */
      return;
    }
  }

  switch (new_audio_action)
  {
  case SWITCH_AUDIO_OFF:
    if (ibt_params.last_action EQ SWITCH_AUDIO_ALERT)
    {
      audio_StopSoundbyID (AUDIO_SPEAKER, TONES_RINGING_TONE);
    }
    else if (ibt_params.last_action EQ SWITCH_AUDIO_BUSY)
    {
      audio_StopSoundbyID (AUDIO_SPEAKER, TONES_BUSY);
    }
    else if (ibt_params.last_action EQ SWITCH_AUDIO_CALLWAIT)
    {
      audio_StopSoundbyID (AUDIO_SPEAKER, TONES_CW);
    }
    
    TRACE_EVENT("AUDIO FUNCTION CALLED: OFF");
    ibt_params.last_action = SWITCH_AUDIO_OFF;
    break;

  case SWITCH_AUDIO_ALERT:
    audio_PlaySoundID (AUDIO_SPEAKER,
                       TONES_RINGING_TONE,
                       RINGER,
                       AUDIO_PLAY_INFINITE);
    TRACE_EVENT("AUDIO FUNCTION CALLED: ALERT");
    ibt_params.last_action = SWITCH_AUDIO_ALERT;
    break;

  case SWITCH_AUDIO_BUSY:
    audio_PlaySoundID (AUDIO_SPEAKER,
                       TONES_BUSY,
                       RINGER,
                       AUDIO_PLAY_ONCE);
    TRACE_EVENT("AUDIO FUNCTION CALLED: BUSY");
    ibt_params.last_action = SWITCH_AUDIO_BUSY;
    break;

  case SWITCH_AUDIO_CALLWAIT:
    audio_PlaySoundID (AUDIO_SPEAKER,
                       TONES_CW,
                       RINGER,
                       AUDIO_PLAY_ONCE);
    TRACE_EVENT("AUDIO FUNCTION CALLED: CALL WAIT");
    ibt_params.last_action = SWITCH_AUDIO_CALLWAIT;
  
  default:
    break;
  }
}


#endif
/*==== EOF ========================================================*/