view src/cs/services/audio/audio_mode_volume.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 838eeafb0051
children
line wrap: on
line source

/****************************************************************************/
/*                                                                          */
/*  File Name:  audio_mode_volume.c                                         */
/*                                                                          */
/*  Purpose:  This file contains all the functions used for audio mode      */
/*            speaker volume services.                                      */
/*                                                                          */
/*  Version   0.1                                                           */
/*                                                                          */
/*  Date        Modification                                                */
/*  ------------------------------------------------------------------------*/
/*  14 Jan 2002  Create                                                     */
/*                                                                          */
/*  Author      Francois Mazard                                             */
/*                                                                          */
/* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
/****************************************************************************/

#include "rv/rv_defined_swe.h"

#ifdef RVM_AUDIO_MAIN_SWE
  #ifndef _WINDOWS
    #include "config/swconfig.cfg"
    #include "config/sys.cfg"
    #include "config/chipset.cfg"
  #endif

  #include "l1_confg.h"
  #include "rv/rv_general.h"
  #include "rvm/rvm_gen.h"
  #include "audio/audio_ffs_i.h"
  #include "audio/audio_api.h"
  #include "audio/audio_structs_i.h"
  #include "audio/audio_error_hdlr_i.h"
  #include "audio/audio_var_i.h"
  #include "audio/audio_messages_i.h"
  #include "audio/audio_macro_i.h"
  #include "rvf/rvf_target.h"
  #include "audio/audio_const_i.h"

  /* include the usefull L1 header */
  #ifdef _WINDOWS
    #define BOOL_FLAG
    //#define CHAR_FLAG
  #endif
  #include "l1_types.h"
  #include "l1audio_const.h"
  #include "l1audio_cust.h"
  #include "l1audio_defty.h"
  #include "l1audio_msgty.h"
  #include "l1audio_signa.h"
  #if TESTMODE
   #include "l1tm_defty.h"
  #endif
  #if (L1_GTT == 1)
    #include "l1gtt_const.h"
    #include "l1gtt_defty.h"
  #endif
  #include "l1_const.h"
  #include "l1_defty.h"
  #include "l1_msgty.h"
  #include "l1_signa.h"
  #ifdef _WINDOWS
    #define L1_ASYNC_C
  #endif
  #include "l1_varex.h"

  #ifdef _WINDOWS
    #include "audio/tests/audio_test.h"
  #endif

  /* external functions */
  /* write */
  extern T_AUDIO_RET audio_mode_speaker_volume_write          (T_AUDIO_SPEAKER_LEVEL *data);
  /* read */
  extern T_AUDIO_RET audio_mode_speaker_volume_read           (T_AUDIO_SPEAKER_LEVEL *data);

  /********************************************************************************/
  /*                                                                              */
  /*    Function Name:   audio_mode_speaker_volume_send_status                    */
  /*                                                                              */
  /*    Purpose:  This function sends the audio mode speaker volume status to     */
  /*              the entity.                                                     */
  /*                                                                              */
  /*    Input Parameters:                                                         */
  /*        status,                                                               */
  /*        return path                                                           */
  /*                                                                              */
  /*    Output Parameters:                                                        */
  /*        None.                                                                 */
  /*                                                                              */
  /*    Note:                                                                     */
  /*        None.                                                                 */
  /*                                                                              */
  /*    Revision History:                                                         */
  /*        None.                                                                 */
  /*                                                                              */
  /********************************************************************************/
  void audio_mode_speaker_volume_send_status (T_AUDIO_RET status, T_RV_RETURN return_path)
  {
    void *p_send_message = NULL;
    T_RVF_MB_STATUS mb_status = RVF_RED;

    while (mb_status == RVF_RED)
    {
      /* allocate the message buffer */
      mb_status = rvf_get_buf (p_audio_gbl_var->mb_external,
                               sizeof (T_AUDIO_VOLUME_DONE),
                               (T_RVF_BUFFER **) (&p_send_message));

      /* If insufficient resources, then report a memory error and abort.               */
      /* and wait until more ressource is given */
      if (mb_status == RVF_RED)
      {
        audio_mode_error_trace(AUDIO_ENTITY_NO_MEMORY);
        rvf_delay(RVF_MS_TO_TICKS(1000));
      }
    }
    /*fill the header of the message */
    ((T_AUDIO_VOLUME_DONE *)(p_send_message))->os_hdr.msg_id =
      AUDIO_SPEAKER_VOLUME_DONE;

    /* fill the status parameters */
    ((T_AUDIO_VOLUME_DONE *)(p_send_message))->status = status;

    if (return_path.callback_func == NULL)
    {
      /* send the message to the entity */
      rvf_send_msg (return_path.addr_id,
                    p_send_message);
    }
    else
    {
      /* call the callback function */
      (*return_path.callback_func)((void *)(p_send_message));
	  rvf_free_buf((T_RVF_BUFFER *)p_send_message);
    }
  }

  /********************************************************************************/
  /*                                                                              */
  /*    Function Name:   audio_mode_speaker_volume_manager                        */
  /*                                                                              */
  /*    Purpose:  This function manage the audio mode save services.              */
  /*                                                                              */
  /*    Input Parameters:                                                         */
  /*        Audio message.                                                        */
  /*                                                                              */
  /*    Output Parameters:                                                        */
  /*        None.                                                                 */
  /*                                                                              */
  /*    Note:                                                                     */
  /*        None.                                                                 */
  /*                                                                              */
  /*    Revision History:                                                         */
  /*        None.                                                                 */
  /*                                                                              */
  /********************************************************************************/
  void audio_mode_speaker_volume_manager (T_RV_HDR *p_message)
  {
    T_AUDIO_SPEAKER_LEVEL volume;
    #ifndef _WINDOWS
      T_FFS_FD              audio_volume_ffs_fd;
    #endif

    switch (((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->volume.volume_action)
    {
      case AUDIO_SPEAKER_VOLUME_INCREASE:
      {
        if ( (audio_mode_speaker_volume_read(&volume)) == AUDIO_ERROR )
        {
          AUDIO_SEND_TRACE("AUDIO MODE SPEAKER VOLUME: can't read the current volume", RV_TRACE_LEVEL_ERROR);
          audio_mode_speaker_volume_send_status (AUDIO_ERROR,
            ((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->return_path);
          return;
        }

        if (volume.audio_speaker_level == AUDIO_SPEAKER_VOLUME_MUTE)
        {
          volume.audio_speaker_level = AUDIO_SPEAKER_VOLUME_24dB;
        }
        else
        if (volume.audio_speaker_level == AUDIO_SPEAKER_VOLUME_24dB)
        {
          volume.audio_speaker_level = AUDIO_SPEAKER_VOLUME_18dB;
        }
        else
        if (volume.audio_speaker_level == AUDIO_SPEAKER_VOLUME_0dB)
        {
          volume.audio_speaker_level = AUDIO_SPEAKER_VOLUME_0dB;
        }
        else
        {
          volume.audio_speaker_level += 50;
        }
        break;
      }
      case AUDIO_SPEAKER_VOLUME_DECREASE:
      {
        if ( (audio_mode_speaker_volume_read(&volume)) == AUDIO_ERROR )
        {
          AUDIO_SEND_TRACE("AUDIO MODE SPEAKER VOLUME: can't read the current volume", RV_TRACE_LEVEL_ERROR);
          audio_mode_speaker_volume_send_status (AUDIO_ERROR,
            ((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->return_path);
          return;
        }

        if (volume.audio_speaker_level == AUDIO_SPEAKER_VOLUME_MUTE)
        {
          volume.audio_speaker_level = AUDIO_SPEAKER_VOLUME_MUTE;
        }
        else
        if (volume.audio_speaker_level == AUDIO_SPEAKER_VOLUME_24dB)
        {
          volume.audio_speaker_level = AUDIO_SPEAKER_VOLUME_MUTE;
        }
        else
        if (volume.audio_speaker_level == AUDIO_SPEAKER_VOLUME_18dB)
        {
          volume.audio_speaker_level = AUDIO_SPEAKER_VOLUME_24dB;
        }
        else
        {
          volume.audio_speaker_level -= 50;
        }
        break;
      }
      case AUDIO_SPEAKER_VOLUME_SET:
      {
        volume.audio_speaker_level = ((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->volume.value;
        break;
      }
    }

    /* Open the volume file */
    #ifndef _WINDOWS
      audio_volume_ffs_fd = ffs_open(p_audio_gbl_var->audio_mode_var.audio_volume_var.audio_volume_path_name,
          FFS_O_CREATE | FFS_O_WRONLY | FFS_O_TRUNC | FFS_O_APPEND);
      if (audio_volume_ffs_fd <= 0)
      {
          AUDIO_SEND_TRACE("AUDIO MODE SPEAKER VOLUME: can't open the current volume file", RV_TRACE_LEVEL_ERROR);
          /* Close the file */
          ffs_close(audio_volume_ffs_fd);

          audio_mode_speaker_volume_send_status (AUDIO_ERROR,
            ((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->return_path);
        return;
      }

      /* Save the audio speaker volume structure from the FFS */
      if ( (ffs_write (audio_volume_ffs_fd,
                      &volume,
                      sizeof(T_AUDIO_SPEAKER_LEVEL))) < EFFS_OK )
      {
        AUDIO_SEND_TRACE("AUDIO MODE SPEAKER VOLUME: impossible to save the current speaker volume", RV_TRACE_LEVEL_ERROR);

        /* Close the file */
        ffs_close(audio_volume_ffs_fd);

        /* send the status message */
        audio_mode_speaker_volume_send_status (AUDIO_ERROR,
          ((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->return_path);
        return;
      }

      /* Close the file */
      ffs_close(audio_volume_ffs_fd);
    #else
      #if ((AUDIO_REGR == SW_COMPILED) || (AUDIO_MISC == SW_COMPILED))
        p_audio_test->speaker_volume_1.audio_speaker_level = volume.audio_speaker_level;
      #endif
    #endif

    /* Fill the audio volume structure */
    if ( (audio_mode_speaker_volume_write(&volume)) == AUDIO_ERROR)
    {
      AUDIO_SEND_TRACE("AUDIO MODE LOAD: error in the the audio speaker volume set function", RV_TRACE_LEVEL_ERROR);

      /* send the status message */
      audio_mode_speaker_volume_send_status (AUDIO_ERROR,
        ((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->return_path);

      return;
    }

    /* send the good status message */
    audio_mode_speaker_volume_send_status (AUDIO_OK,
      ((T_AUDIO_SPEAKER_VOLUME_REQ *)p_message)->return_path);
  }
#endif /* RVM_AUDIO_MAIN_SWE */