# HG changeset patch # User Space Falcon # Date 1429771373 0 # Node ID 549b7ac60300b136f03da27165f7c744a1917712 # Parent 56e3d8560d69a192936688ef1f3c9c56d17e51b3 gsm-fw/g23m-glue/gdi/*.c: import from Leonardo source diff -r 56e3d8560d69 -r 549b7ac60300 gsm-fw/g23m-glue/gdi/audio.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/gdi/audio.c Thu Apr 23 06:42:53 2015 +0000 @@ -0,0 +1,2153 @@ +/* ++----------------------------------------------------------------------------- +| Project : GSM-PS +| Modul : DRV_AUDIO ++----------------------------------------------------------------------------- +| 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 defines the audio driver interface. +| for the G23 protocol stack. +| +| This driver is used to control all audio and audio-related +| devices of the mobile such as speaker, microphone, etc. +| A device, e.g. a speaker, may have the capability to play +| sounds and/or melodies indirectly. This means a sound +| generator may be attached to a speaker or its amplifier. +| The format of the sound/melody images is implementation +| dependent and therefore not in the scope of the generic +| driver interface. Therefore a application may play pre- +| defined, driver specific sounds identifying them via a +| sound ID. In addition the API of this driver has foreseen +| that an application may copy a sound image into its local +| buffer, modify it and let it play by the driver. In this +| case the application has to have the knowledge about the +| sound image format. ++----------------------------------------------------------------------------- +| History : +| Apr 04, 2005 REF: ENH 30063 xdeepadh +| Description: Buzzer removal activity for Locosto MMI +| Fix:All the Buzzer related calls are under the compilation flag FF_BUZZER. +| The GSM tones which were playing in the buzzer are now routed to the speaker(Audio). ++----------------------------------------------------------------------------- + $History: + + + xpradipg - GSM-ENH-32494 : 23 June 2005 + Description: Support for various audio profiles + Solution: The support for audio device's carkit/headset/loudspeaker/handheld. + The audio device is enabled as per the user actions. + + June 13, 2005 REF : GSM_ENH_32062 - xpradipg + Description:The audio uplink not working in the connected call + Solution: The audio uplink was configured to mute state at initialization + The configuration is changed to be in unmute state + + Apr 26, 2005 REF : CRR 30627 xpradipg + Bug : Replace the ABB APIs with Audio Service APIs + Fix : The ABB APIs are used in muting/unmuting and setting the volume of + the speaker and microphone. These ABB APIs are replaced with the + audio serivce APIs +******************************************************************************/ + +#ifndef DRV_AUDIO_C +#define DRV_AUDIO_C +#endif +#define ENTITY_CST + +/* +in order to stay backwardcompatible this riv_audio define is entered as only +ti15++ version do have the riveria frame it needs to be disabled for the rest +*/ + +#if defined (ALR) +#define RIV_AUDIO 1 +#else +#undef RIV_AUDIO +#endif + +#if defined (_SIMULATION_) +#define _TTY_SIMU +#endif + +/*==== INCLUDES ===================================================*/ + +#include +#include "typedefs.h" +#include "vsi.h" +#include "custom.h" +#ifdef ALR + #include "p_mphc.h" +#elif defined(FF_GTI) + /* GTI*/ + /* do nothing */ +#else + #include "p_mph5.h" +#endif /* ALR, FF_GTI */ +#include "prim.h" +#include "gsm.h" +#include "tok.h" +#include "cst/cst.h" +#include "cst/cus_cst.h" +#include "gdi.h" +#include "audio.h" + +#if defined (RIV_AUDIO) +/* #include "bt_general.h" */ +#include "rv/rv_general.h" +#if /*!defined (_TTY_SIMU) &&*/ defined (FF_TTY) +#include "tty/tty_api.h" +#endif +#include "audio/audio_api.h" +#endif + +/*==== DEFINE =====================================================*/ + +#define AUDIO_TRC_EVENT(_f_)\ + vsi_o_ttrace(VSI_CALLER TC_EVENT, _f_) +#define AUDIO_TRC_EVENT_P1(_f_, _p_)\ + vsi_o_ttrace(VSI_CALLER TC_EVENT, _f_, _p_) +#define AUDIO_TRC_EVENT_P2(_f_, _p1_, _p2_)\ + vsi_o_ttrace(VSI_CALLER TC_EVENT, _f_, _p1_, _p2_) +#define AUDIO_TRC_FUNC(_f_)\ + vsi_o_ttrace(VSI_CALLER TC_FUNC, _f_) +#define AUDIO_TRC_FUNC_P1(_f_, _p_)\ + vsi_o_ttrace(VSI_CALLER TC_FUNC, _f_, _p_) + +/*==== EXPORT =====================================================*/ + +#if defined (NEW_FRAME) +#define CST_AUDIOTIMER 2 +#endif + +/*==== VARIABLES ==================================================*/ + +#if defined (RIV_AUDIO) +static T_AUDIO_KEYBEEP_PARAMETER beep; +static T_AUDIO_TONES_PARAMETER t; +#endif + +drv_SignalCB_Type audio_signal_callback = NULL; +#if !defined (NEW_FRAME) +T_VSI_THANDLE audio_handle = VSI_ERROR; +#endif +T_ACT_TONE act_tone; +UBYTE act_speakerVolume; +UBYTE act_micVolume; +UBYTE act_buzVolume; +UBYTE act_speakerMute; +UBYTE act_micMute; + +#if defined (NEW_FRAME) +EXTERN T_HANDLE hCommL1; +#else +EXTERN T_VSI_CHANDLE hCommL1; +#endif + +#if defined (RIV_AUDIO) +void audio_riv_audio_cb (void*); + +static T_RV_RETURN_PATH const riv_audio_rp = +{ + 0, audio_riv_audio_cb +}; + +#ifdef FF_TTY +T_AUDIO_TTY_CONFIG_PARAMETER static tty_cfg; +UBYTE static tty_state = FALSE; +UBYTE static tty_cmd = (UBYTE)TTY_OFF; + + +char const * const audio_mode_names_tty[] = { + "default", + "tty_vco", + "tty_hco", + "tty_all" +}; +#endif +#endif + +UBYTE audio_is_free = TRUE; /* variable for disable no muting */ + +/*==== FUNCTIONS ==================================================*/ + +#if defined (_TMS470) + +EXTERN void BZ_Init (void); +EXTERN void BZ_Enable (void); +EXTERN void BZ_Disable (void); +EXTERN void BZ_Tone (int f); +EXTERN void BZ_Volume (int v); + +#ifdef ALR +EXTERN void ABB_DlVolume (UBYTE v); +EXTERN void ABB_DlMute (UBYTE mute); +EXTERN void ABB_UlMute (UBYTE value); +EXTERN void ABB_SideTone (UBYTE v); +/*#include "l1audio_abb.h" does not work: there's no definition of types UWORDx */ +#else +EXTERN void VG_UlVolume (UBYTE v); +EXTERN void VG_DlVolume (UBYTE v); +EXTERN void VG_DlMute (UBYTE mute); +EXTERN void VG_SideTone (UBYTE v); +#endif + +#else + +LOCAL void BZ_Init (void); +LOCAL void BZ_Enable (void); +LOCAL void BZ_Disable (void); +LOCAL void BZ_Tone (int f); +LOCAL void BZ_Volume (int v); + +#ifdef ALR +LOCAL void ABB_DlVolume (UBYTE v); +LOCAL void ABB_DlMute (UBYTE mute); +LOCAL void ABB_UlMute (UBYTE value); +LOCAL void ABB_SideTone (UBYTE v); +#else +LOCAL void VG_UlVolume (UBYTE v); +LOCAL void VG_DlVolume (UBYTE v); +LOCAL void VG_DlMute (UBYTE mute); +LOCAL void VG_SideTone (UBYTE v); +#endif + +#endif +LOCAL void audio_buzzer (void); +LOCAL void audio_audio (void); +LOCAL void audio_UlMute (UBYTE mute); + +#if defined (RIV_AUDIO) AND !defined (_TTY_SIMU) AND defined (FF_TTY) +LOCAL void audio_tty_return (void *tty_result); +LOCAL void audio_save_def_return (void *result); +LOCAL void audio_load_return (void *result); +LOCAL void audio_dyn_load_return (void *result); +#endif + +// xpradipg - GSM-ENH-32494 : 23 June 2005 +#ifdef FF_MMI_AUDIO_PROFILE +typedef struct +{ + int status; +}T_AUDIO_MODE_LOAD_DONE; +EXTERN T_AUDIO_RET audio_mode_load (T_AUDIO_MODE_LOAD *p_parameter, T_RV_RETURN_PATH return_path); +#endif +/*==== CONSTANTS ==================================================*/ + +#define BUZZER 0 +#define AUDIO 1 +// Apr 26, 2005 REF : CRR 30627 xpradipg +#ifdef FF_MMI_SERVICES_MIGRATION +#define AUDIO_SIDE_TONE 175 +#endif + +#if defined (RIV_AUDIO) + +#define TDMA_12 12 +#define TDMA_23 23 +#define TDMA_43 43 +#define TDMA_71 71 +#define TDMA_108 108 +#define TDMA_130 130 +#define TDMA_216 216 +#define TDMA_650 650 +#define TDMA_866 866 + +/* +* with the original table spec (USHORT for Freq. and Ampl.), +* we can go down to -31 dB only. Obviously this is sufficient +* for all currently defined sounds. +*/ +#define F_425 (( 425 << 5) + 7) /* (( 242 << 8 ) + 35) */ +#define F_697 (( 697 << 5) + 7) /* (( 219 << 8 ) + 56) */ +#define F_770 (( 770 << 5) + 7) /* (( 211 << 8 ) + 61) */ +#define F_852 (( 852 << 5) + 7) /* (( 201 << 8 ) + 67) */ +#define F_941 (( 941 << 5) + 7) /* (( 189 << 8 ) + 73) */ +#define F_1209 ((1209 << 5) + 5) /* (( 149 << 8 ) + 111) */ +#define F_1336 ((1336 << 5) + 5) /* (( 128 << 8 ) + 118) */ +#define F_1477 ((1477 << 5) + 5) /* (( 102 << 8 ) + 125) */ +#define F_1633 ((1633 << 5) + 5) /* (( 73 << 8 ) + 130) */ + +#else /* (RIV_AUDIO) */ + +#if defined (_TMS470) + +/* + * unit is TDMA frames + */ +#define TDMA_12 12 +#define TDMA_23 23 +#define TDMA_43 43 +#define TDMA_71 71 +#define TDMA_108 108 +#define TDMA_130 130 +#define TDMA_216 216 +#define TDMA_650 650 +#define TDMA_866 866 + + +#define F_425 (( 242 << 8) + 35) +#define F_697 (( 219 << 8) + 56) +#define F_770 (( 211 << 8) + 61) +#define F_852 (( 201 << 8) + 67) +#define F_941 (( 189 << 8) + 73) +#define F_1209 (( 149 << 8) + 111) +#define F_1336 (( 128 << 8) + 118) +#define F_1477 (( 102 << 8) + 125) +#define F_1633 (( 73 << 8) + 130) + +#else + +/* + * unit is milliseconds + */ +#define TDMA_12 55 +#define TDMA_23 100 +#define TDMA_43 200 +#define TDMA_71 330 +#define TDMA_108 500 +#define TDMA_130 650 +#define TDMA_216 1000 +#define TDMA_650 3000 +#define TDMA_866 4000 + +#define F_425 (( 35 << 8) + 242) +#define F_697 (( 56 << 8) + 219) +#define F_770 (( 61 << 8) + 211) +#define F_852 (( 67 << 8) + 201) +#define F_941 (( 73 << 8) + 189) +#define F_1209 ((111 << 8) + 149) +#define F_1336 ((118 << 8) + 128) +#define F_1477 ((125 << 8) + 102) +#define F_1633 ((130 << 8) + 73) + +#endif + +#endif /* (RIV_AUDIO) */ + + +extern const T_DESCR The_Ale_is_dear[111]; +extern const T_DESCR Danza_de_Astureses[21]; +extern const T_DESCR rising_chromatic[47]; +extern const T_DESCR rising_cscale[27]; +extern const T_DESCR MELODY_ONE[11]; +extern const T_DESCR MELODY_HELLO[23]; +extern const T_DESCR bugle[39]; + + +/* + * Tone generation tables + */ +//Apr 04, 2005 REF: ENH 30063 xdeepadh +#ifndef FF_MMI_NO_BUZZER //If Buzzer is available +//ct_ring will be used for all the ringing tones. +//When the buzzer is not available,midi ringer will be used to play the ringing tones. +static const T_DESCR ct_ring [] = /* command 1 command 2 length */ + { 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 800, 0, TDMA_12, + 900, 0, TDMA_12, + 0, 0, TDMA_866, + 0xFFFF, 0xFFFF, 0 + }; + +#endif +static const T_DESCR ct_auth_num [] = /* command 1 command 2 length */ + { 950, 0, TDMA_71, + 1400, 0, TDMA_71, + 1800, 0, TDMA_71, + 0, 0, TDMA_216, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_busy [] = /* command 1 command 2 length */ + { F_425, 0, TDMA_108, + 0, 0, TDMA_108, + F_425, 0, TDMA_108, + 0, 0, TDMA_108, + F_425, 0, TDMA_108, + 0, 0, TDMA_108, + F_425, 0, TDMA_108, + 0, 0, TDMA_108, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_congest [] = /* command 1 command 2 length */ + { 425, 0, TDMA_43, + 0, 0, TDMA_43, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dropped [] = /* command 1 command 2 length */ + { 425, 0, TDMA_43, + 0, 0, TDMA_43, + 425, 0, TDMA_43, + 0, 0, TDMA_43, + 425, 0, TDMA_43, + 0, 0, TDMA_43, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_ack [] = /* command 1 command 2 length */ + { 425, 0, TDMA_43, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_cw [] = /* command 1 command 2 length */ + { F_425, 0, TDMA_43, + 0, 0, TDMA_130, + F_425, 0, TDMA_43, + 0, 0, TDMA_650, + F_425, 0, TDMA_43, + 0, 0, TDMA_130, + F_425, 0, TDMA_43, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_0 [] = /* command 1 command 2 length */ + { F_941, F_1336, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_1 [] = /* command 1 command 2 length */ + { F_697, F_1209, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_2 [] = /* command 1 command 2 length */ + { F_697, F_1336, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_3 [] = /* command 1 command 2 length */ + { F_697, F_1477, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_4 [] = /* command 1 command 2 length */ + { F_770, F_1209, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_5 [] = /* command 1 command 2 length */ + { F_770, F_1336, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_6 [] = /* command 1 command 2 length */ + { F_770, F_1477, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_7 [] = /* command 1 command 2 length */ + { F_852, F_1209, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_8 [] = /* command 1 command 2 length */ + { F_852, F_1336, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_9 [] = /* command 1 command 2 length */ + { F_852, F_1477, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_a [] = /* command 1 command 2 length */ + { F_697, F_1633, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_b [] = /* command 1 command 2 length */ + { F_770, F_1633, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; +static const T_DESCR ct_dtmf_c [] = /* command 1 command 2 length */ + { F_852, F_1633, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_d [] = /* command 1 command 2 length */ + { F_941, F_1633, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_s [] = /* command 1 command 2 length */ + { F_941, F_1209, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_dtmf_h [] = /* command 1 command 2 length */ + { F_941, F_1477, TDMA_23, + 0xFFFF, 0xFFFF, 0 + }; + +/* keybeep not used at the moment */ +static const T_DESCR ct_keybeep [] = /* command 1 command 2 length */ + { F_697, F_697, TDMA_43, + 0xFFFF, 0xFFFF, 0 + }; + +static const T_DESCR ct_ringing [] = /* command 1 command 2 length */ + { F_425, 0, TDMA_216, + 0, 0, TDMA_866, + 0xFFFF, 0xFFFF, 0 + }; + +/* + * Tone Type Table + */ +//Apr 04, 2005 REF: ENH 30063 xdeepadh + #ifndef FF_MMI_NO_BUZZER //If Buzzer is available + //If Buzzer is available, ringing tones and gsm tones will be played in the buzzer. + //If the buzzer is not availble, the gsm tones will be routed to the speaker and + //the ringing tones will be played with midi ringer +static const UBYTE TONE_TYPE [] = { BUZZER, /* ringing tone 0 */ + BUZZER, /* ringing tone 1 */ + BUZZER, /* ringing tone 2 */ + BUZZER, /* ringing tone 3 */ + BUZZER, /* ringing tone 4 */ + BUZZER, /* ringing tone 5 */ + BUZZER, /* ringing tone 6 */ + BUZZER, /* ringing tone 7 */ + BUZZER, /* ringing tone 8 */ + BUZZER, /* ringing tone 9 */ + BUZZER, /* ringing tone 10 */ + BUZZER, /* ringing tone 11 */ + BUZZER, /* ringing tone 12 */ + BUZZER, /* ringing tone 13 */ + BUZZER, /* ringing tone 14 */ + BUZZER, /* ringing tone 15 */ + BUZZER, /* error/special information */ + AUDIO, /* subscriber busy */ + BUZZER, /* congestion */ + BUZZER, /* call dropped */ + BUZZER, /* radio acknowledge */ + AUDIO, /* call waiting */ + AUDIO, /* DTMF digit 0 */ + AUDIO, /* DTMF digit 1 */ + AUDIO, /* DTMF digit 2 */ + AUDIO, /* DTMF digit 3 */ + AUDIO, /* DTMF digit 4 */ + AUDIO, /* DTMF digit 5 */ + AUDIO, /* DTMF digit 6 */ + AUDIO, /* DTMF digit 7 */ + AUDIO, /* DTMF digit 8 */ + AUDIO, /* DTMF digit 9 */ + AUDIO, /* DTMF digit A */ + AUDIO, /* DTMF digit B */ + AUDIO, /* DTMF digit C */ + AUDIO, /* DTMF digit D */ + AUDIO, /* DTMF digit * */ + AUDIO, /* DTMF digit # */ + AUDIO, /* keybeep */ + AUDIO /* ringing tone if NOIBT */ + }; + +#endif + +//Apr 04, 2005 REF: ENH 30063 xdeepadh +/* + * Tone Description Table + This table will have the ringing tones and the gsm tones. + When the buzzer is not available, the ringing tones will be played with midi ringer + */ +static const T_DESCR * const TONE_DESCR [] = + { +#ifndef FF_MMI_NO_BUZZER + ct_ring, /* ringing tone 0 */ + ct_ring, /* ringing tone 1 */ + ct_ring, /* ringing tone 2 */ + ct_ring, /* ringing tone 3 */ + ct_ring, /* ringing tone 4 */ + ct_ring, /* ringing tone 5 */ + ct_ring, /* ringing tone 6 */ + ct_ring, /* ringing tone 7 */ + ct_ring, /* ringing tone 8 */ + ct_ring, /* ringing tone 9 */ + ct_ring, /* ringing tone 10 */ + ct_ring, /* ringing tone 11 */ + ct_ring, /* ringing tone 12 */ + ct_ring, /* ringing tone 13 */ + ct_ring, /* ringing tone 14 */ + ct_ring, /* ringing tone 15 */ +#endif + ct_auth_num,/* error/special information */ + ct_busy, /* subscriber busy */ + ct_congest, /* congestion */ + ct_dropped, /* call dropped */ + ct_ack, /* radio acknowledge */ + ct_cw, /* call waiting */ + ct_dtmf_0, /* DTMF digit 0 */ + ct_dtmf_1, /* DTMF digit 1 */ + ct_dtmf_2, /* DTMF digit 2 */ + ct_dtmf_3, /* DTMF digit 3 */ + ct_dtmf_4, /* DTMF digit 4 */ + ct_dtmf_5, /* DTMF digit 5 */ + ct_dtmf_6, /* DTMF digit 6 */ + ct_dtmf_7, /* DTMF digit 7 */ + ct_dtmf_8, /* DTMF digit 8 */ + ct_dtmf_9, /* DTMF digit 9 */ + ct_dtmf_a, /* DTMF digit A */ + ct_dtmf_b, /* DTMF digit B */ + ct_dtmf_c, /* DTMF digit C */ + ct_dtmf_d, /* DTMF digit D */ + ct_dtmf_s, /* DTMF digit * */ + ct_dtmf_h, /* DTMF digit # */ + ct_keybeep, /* dummy for keybeep */ + ct_ringing /* ringing tone if NIBT */ + }; + + +/*==== CONSTANTS ==================================================*/ + + + +// xpradipg - GSM-ENH-32494 : 23 June 2005 +#ifdef FF_MMI_AUDIO_PROFILE +/******************************************************************************* + $Function: audio_mode_load_cb + + $Description: callback function for the auido_mode_load() + + $Returns: none + + $Arguments: status of the load operation + +*******************************************************************************/ +void audio_mode_load_cb(void *ret_param) +{ + + //if((T_AUDIO_MODE_LOAD_DONE *)ret_param->status != AUDIO_OK) + AUDIO_TRC_FUNC("ERROR Loading the audio profile"); +} + +/******************************************************************************* + $Function: audio_full_access_write_cb() + + $Description: callback function for the audio_full_access_write() + + $Returns: none + + $Arguments: status of the write operation + +*******************************************************************************/ +void audio_full_access_write_cb(void *ret_param) +{ +// if( (T_AUDIO_FULL_ACCESS_WRITE_DONE *)ret_param->status != AUDIO_OK) + AUDIO_TRC_FUNC ("ERROR setting the value"); +} +#if 0 +/******************************************************************************* + $Function: audio_speaker_volume_cb() + + $Description: callback function for the audio_speaker_volume() + + $Returns: none + + $Arguments: status of the speaker volume setting operation + +*******************************************************************************/ +void audio_speaker_volume_cb(ret_param) +{ + if((T_AUDIO_SPEAKER_VOLUME_DONE)ret_param->status != AUDIO_OK) + AUDIO_TRC_FUNC ("ERROR setting the volume"); +} +#endif +/******************************************************************************* + $Function: audio_set_device() + + $Description: initiates the audio_mode_load() for various devices + + $Returns: none + + $Arguments: successfull execution of the audio_mode_load operation + +*******************************************************************************/ +int audio_set_device(char* mode) +{ + T_RV_RETURN_PATH return_path = {0,audio_mode_load_cb}; + T_AUDIO_RET status; + T_AUDIO_MODE_LOAD p_parameter; + + strcpy((char*)p_parameter.audio_mode_filename,mode); + status = audio_mode_load(& p_parameter,return_path); + return status; + +} + +/******************************************************************************* + $Function: audio_set_path() + + $Description: sets the audio speaker path to the current audio device and also either to voice or + stereo + + $Returns: none + + $Arguments: + audioDevice - Indicates the device to which the path has to be set + stereo - If false the path is for voice + If true the path is for stereo +*******************************************************************************/ + +void audio_set_path(int audioDevice,int stereo) +{ + T_RV_RETURN_PATH return_path = {0,audio_full_access_write_cb}; + T_AUDIO_FULL_ACCESS_WRITE p_parameter; + int status; + if( stereo) + p_parameter.variable_indentifier = AUDIO_STEREO_SPEAKER_MODE; + else + p_parameter.variable_indentifier = AUDIO_SPEAKER_MODE; + p_parameter.data = (void*)&audioDevice; + status = audio_full_access_write(&p_parameter,return_path); + +} +#endif + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_Init | ++--------------------------------------------------------------------+ + + PURPOSE : The function initializes the driverīs internal data. + The function returns DRV_OK in case of a successful + completition. The function returns DRV_INITIALIZED if + the driver has already been initialized and is ready to + be used or is already in use. In case of an initialization + failure, which means the that the driver cannot be used, + the function returns DRV_INITFAILURE. + +*/ +// xpradipg - GSM-ENH-32494 : 23 June 2005 +// the interface for the audio profiles has changed, it accepts an array of +// type T_ACCESSORY_CALLBACK +#ifdef FF_MMI_AUDIO_PROFILE +GLOBAL UBYTE audio_Init(T_ACCESSORY_CALLBACK *audioConfig) +#else +GLOBAL UBYTE audio_Init (drv_SignalCB_Type in_SignalCBPtr) +#endif +{ +// Apr 26, 2005 REF : CRR 30627 xpradipg +// local variable declarations +#ifdef FF_MMI_SERVICES_MIGRATION + T_AUDIO_FULL_ACCESS_WRITE side_tone_cfg; + T_RV_RETURN_PATH return_path = {0, NULL}; + T_AUDIO_RET result; + INT8 side_tone = AUDIO_SIDE_TONE; +#endif +// xpradipg - GSM-ENH-32494 : 23 June 2005 +#ifdef FF_MMI_AUDIO_PROFILE +T_AUDIO_RET status; +T_AUDIO_MODE_LOAD handheld= {"handheld"}; +#endif + +// xpradipg - GSM-ENH-32494 : 23 June 2005 +// the callback functions for the headset and carkit indication are registered +// and the defualt mode handheld is loaded +#ifdef FF_MMI_AUDIO_PROFILE +#if 0 + status = audio_accessory_register_notification(audioConfig[CALLBACK_HEADSET],AUDIO_ACCESSORY_HEADSET); + if( status != AUDIO_OK) + { + AUDIO_TRC_FUNC("Error - registering the callback for headset"); + } + + status = audio_accessory_register_notification(audioConfig[CALLBACK_CARKIT],AUDIO_ACCESSORY_CARKIT); + if(status != AUDIO_OK) + { + AUDIO_TRC_FUNC("Error - registering the callback for carkit"); + } +#endif + return_path.callback_func = audio_mode_load_cb; + status = audio_mode_load(&handheld, return_path); + if (status != AUDIO_OK) + { + AUDIO_TRC_FUNC("Error - loading the handheld profile"); + } +#else + audio_signal_callback = in_SignalCBPtr; /* store call-back function */ +#endif + +#if !defined (NEW_FRAME) + audio_handle = vsi_t_open (VSI_CALLER "AUDIO"); + + if (audio_handle < VSI_OK) + return DRV_INITFAILURE; +#endif +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//For Buzzer init +#ifndef FF_MMI_NO_BUZZER + BZ_Init (); /* initialize buzzer */ +#endif + audio_SetMute ( AUDIO_SPEAKER, AUDIO_MUTING_OFF ); + audio_SetMute ( AUDIO_MICROPHONE, AUDIO_MUTING_OFF ); + + audio_SetAmplf ( AUDIO_SPEAKER, 175 ); + audio_SetAmplf ( AUDIO_MICROPHONE, 75 ); +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//Set volume for Buzzer +#ifndef FF_MMI_NO_BUZZER + audio_SetAmplf ( AUDIO_BUZZER, 175 ); +#endif + +/* Setting the Side Tone has been moved from audio_SetAmplf CQ21055*/ +#ifdef ALR + #ifdef FF_TTY + if (!tty_state) + #endif + { +// Apr 26, 2005 REF : CRR 30627 xpradipg +// set the sidetone value to 175 this is the optimum value +#ifdef FF_MMI_SERVICES_MIGRATION + side_tone_cfg.variable_indentifier = AUDIO_MICROPHONE_SPEAKER_LOOP_SIDETONE; + side_tone_cfg.data = (void*)&side_tone; + result = audio_full_access_write(&side_tone_cfg, return_path); +#else + ABB_SideTone (175); +#endif + } +#else + VG_SideTone (175); +#endif + + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_Exit | ++--------------------------------------------------------------------+ + + PURPOSE : The function is called when the driver functionality is + not longer required. +*/ + +GLOBAL void audio_Exit (void) +{ + audio_signal_callback = NULL; +#if !defined (NEW_FRAME) + vsi_t_close (VSI_CALLER audio_handle); + audio_handle = VSI_ERROR; +#endif +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//Disable Buzzer +#ifndef FF_MMI_NO_BUZZER + BZ_Disable (); +#endif + act_tone.status = NO_TONE; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_SetMute | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to enable or disable muting for + the device identified by the parameter in_Device. If the + mode for the specified device could be changed, the + function returns DRV_OK. If the specified device is + unknown or the device does not support muting, the function + returns DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE audio_SetMute (UBYTE in_DeviceID, UBYTE in_Mode) +{ +// Apr 26, 2005 REF : CRR 30627 xpradipg +// local variable declarations +#ifdef FF_MMI_SERVICES_MIGRATION + T_AUDIO_FULL_ACCESS_WRITE p_parameter; + T_AUDIO_FULL_ACCESS_READ p_parameter1; + T_RV_RETURN_PATH return_path = {0, NULL}; + T_AUDIO_RET result; + static INT8 speaker_volume = 0; + INT8 setvolume = AUDIO_SPEAKER_VOLUME_MUTE; +#endif + + if (in_DeviceID EQ AUDIO_SPEAKER) + { + if (in_Mode AND audio_is_free) + { + TRACE_EVENT ("No speaker muting"); +#ifdef ALR +// Apr 26, 2005 REF : CRR 30627 xpradipg +// the previous volume is restored when we comeout of mute state (unmuting) +// At initialization we do not write the value since the new value is written +#ifdef FF_MMI_SERVICES_MIGRATION + p_parameter.variable_indentifier = AUDIO_SPEAKER_VOLUME_LEVEL; + p_parameter.data = (void*)&speaker_volume; + result = audio_full_access_write(&p_parameter,return_path); + if(result != 0) + TRACE_FUNCTION("error - setting speaker volume"); +#else + ABB_DlMute (0); +#endif +#else + VG_DlMute (0); +#endif + act_speakerMute = AUDIO_MUTING_OFF; + } + else + { + TRACE_EVENT ("Speaker muting"); +#ifdef ALR +// Apr 26, 2005 REF : CRR 30627 xpradipg +// read the current value and store it to before setting it to mute +#ifdef FF_MMI_SERVICES_MIGRATION + p_parameter1.variable_indentifier = AUDIO_SPEAKER_VOLUME_LEVEL; + p_parameter1.data = (void*)&speaker_volume; + result = audio_full_access_read(&p_parameter1); + p_parameter.variable_indentifier = AUDIO_SPEAKER_VOLUME_MUTE; + p_parameter.data = (void*)&setvolume; + result = audio_full_access_write(&p_parameter,return_path); +#else + ABB_DlMute (1); +#endif +#else + VG_DlMute (1); +#endif + act_speakerMute = AUDIO_MUTING_ON; + } + } + else if (in_DeviceID EQ AUDIO_MICROPHONE) + { + if (in_Mode AND audio_is_free) + { + TRACE_EVENT ("No microphone muting"); + audio_UlMute (0); + act_micMute = AUDIO_MUTING_OFF; + } + else + { + TRACE_EVENT ("Microphone muting"); + audio_UlMute (1); + act_micMute = AUDIO_MUTING_ON; + } + } + else + { + return DRV_INVALID_PARAMS; + } + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_GetMute | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to get the status whether muting + is enabled or disabled for the device identified by the + parameter in_Device. If the specified device is unknown + or the device does not support muting, the function + returns DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE audio_GetMute (UBYTE in_DeviceID, UBYTE* out_Mode) +{ + if (in_DeviceID EQ AUDIO_SPEAKER) + { + *out_Mode = act_speakerMute; + } + else if (in_DeviceID EQ AUDIO_MICROPHONE) + { + *out_Mode = act_micMute; + } + else + { + return DRV_INVALID_PARAMS; + } + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_GetStatus | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to retrieve the status of the driver. + In case of a successful completion the driver returns + DRV_OK and the current status of the driver in the buffer + out_StatusPtr points to. + In case the driver is not configured yet, it returns + DRV_NOTCONFIGURED. In this case the contents of the + buffer out_StatusPtr is invalid. + In case out_StatusPtr equals NULL or device is unknown + the driver returns DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE audio_GetStatus (UBYTE in_DeviceID, + audio_Status_Type * out_StatusPtr) +{ + if ( out_StatusPtr EQ NULL ) + { + return DRV_INVALID_PARAMS; + } + else + { + if (in_DeviceID EQ AUDIO_SPEAKER) + { + out_StatusPtr -> min_volume = AUDIO_MIN_VOLUME; + out_StatusPtr -> max_volume = AUDIO_MAX_VOLUME; + } +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//If Buzzer is available, set the minimum and maximum volume +#ifndef FF_MMI_NO_BUZZER + else if (in_DeviceID EQ AUDIO_BUZZER) + { + out_StatusPtr -> min_volume = AUDIO_MIN_BUZ_VOLUME; + out_StatusPtr -> max_volume = AUDIO_MAX_BUZ_VOLUME; + } +#endif + else if (in_DeviceID EQ AUDIO_MICROPHONE) + { + out_StatusPtr -> min_volume = AUDIO_MIN_MIC_VOLUME; + out_StatusPtr -> max_volume = AUDIO_MAX_MIC_VOLUME; + } + else + { + return DRV_INVALID_PARAMS; + } + } + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_GetSoundImage | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to copy the image of a driver + internal sound image into an application specific sound + image buffer. The application may modify the sound. + In case of a successful completion the function returns + DRV_OK. In case the size of the buffer where the sound image + shall be copied to is too small the driver returns + DRV_INVALID_PARAMS. In case a specific driver implementation + does not support this functionality the driver returns + DRV_FCT_NOTSUPPORTED. + +*/ + +GLOBAL UBYTE audio_GetSoundImage (UBYTE in_SoundID, + void * out_SoundImagePtr) +{ + return AUDIO_FCT_NOTSUPPORTED; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_SetAmplf | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to set the amplification for the + device identified by the parameter in_DeviceID. + In the case of a speaker this is the volume, for a + microphone - the pre-amplifier that regulates the + sensitivity of the microphone. The valid range depends on + the hardware used. If the amplification could be changed + for the specified device, the function returns DRV_OK. If + the amplification value (in_Amplf) is out of range or the + specified device is unknown or the specified device does + not support the amplification setting, the function + returns DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE audio_SetAmplf (UBYTE in_DeviceID, UBYTE in_Amplf) +{ +// Apr 26, 2005 REF : CRR 30627 xpradipg +// local variable +#ifdef FF_MMI_SERVICES_MIGRATION + T_AUDIO_FULL_ACCESS_WRITE p_parameter; + T_RV_RETURN_PATH return_path = {0, NULL}; + T_AUDIO_RET result; + INT8 volume; +#endif + if (in_DeviceID EQ AUDIO_MICROPHONE) + { + act_micVolume = 75; /* voice quality is best at this microphone volume */ +#ifdef ALR +#else + VG_UlVolume (act_micVolume); +#endif + } + else if (in_DeviceID EQ AUDIO_SPEAKER) + { + TRACE_EVENT_P1("VOLUME=%d", in_Amplf); + +#ifdef ALR +// Apr 26, 2005 REF : CRR 30627 xpradipg +// The ABB values are converted to the corresponding audio service values +#ifdef FF_MMI_SERVICES_MIGRATION + switch (in_Amplf) + { + case 255: + volume = AUDIO_SPEAKER_VOLUME_0dB; + break; + case 190: + volume = AUDIO_SPEAKER_VOLUME_6dB; + break; + case 125: + volume = AUDIO_SPEAKER_VOLUME_12dB; + break; + case 60: + volume = AUDIO_SPEAKER_VOLUME_18dB; + break; + case 1: + volume = AUDIO_SPEAKER_VOLUME_24dB; + break; + default: + volume = AUDIO_SPEAKER_VOLUME_12dB; + break; + } + p_parameter.variable_indentifier = AUDIO_SPEAKER_VOLUME_LEVEL; + p_parameter.data = (void*)&volume; + result = audio_full_access_write(&p_parameter, return_path); + if( result != 0) + TRACE_FUNCTION("set volume failed"); +#else + ABB_DlVolume (in_Amplf); /* output volume */ +#endif +#ifdef FF_TTY + if (!tty_state) +#endif + { + /* ABB_SideTone (175); */ /* To avoid the side tone reseting */ + } +#else + VG_DlVolume (in_Amplf); /* output volume */ + /* VG_SideTone (175); */ /* To avoid the side tone reseting */ +#endif + act_speakerVolume = in_Amplf; + } +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//If Buzzer is available , set the volume +#ifndef FF_MMI_NO_BUZZER + else if (in_DeviceID EQ AUDIO_BUZZER) + { + act_buzVolume = in_Amplf; + } +#endif + else + { + return DRV_INVALID_PARAMS; + } + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_GetAmplf | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to get the amplification for the + device identified by the parameter in_DeviceID. + In the case of a speaker this is the volume, for a + microphone - the pre-amplifier that regulates the + sensitivity of the microphone. The valid range depends on + the hardware used.If the specified device is unknown the + function returns DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE audio_GetAmplf (UBYTE in_DeviceID, UBYTE* out_Amplf) +{ + if (in_DeviceID EQ AUDIO_MICROPHONE) + { + *out_Amplf = act_micVolume; + } + else if (in_DeviceID EQ AUDIO_SPEAKER) + { + *out_Amplf = act_speakerVolume; + } +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//If Buzzer is available, set the out volume + #ifndef FF_MMI_NO_BUZZER + else if (in_DeviceID EQ AUDIO_BUZZER) + { + *out_Amplf = act_buzVolume; + } + #endif + else + { + return DRV_INVALID_PARAMS; + } + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_PlaySoundID | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to play a sound or melody. The + function returns immediately after the "play process" has + been activated. It is implementation dependent if the + device/driver supports playing multiple sounds simultan- + eously, i.e. accepting multiple calls of audio_PlaySoundID(). + If the calling process should be notified when the sound has + stopped playing automatically, the signal AUDIO_SIGTYPE_ + SOUNDEND must be set using the audio_SetSignal() function. + If the special driver implementation or the device does + not support volume control, the driver ignores the value. + If the sound can be played, the function returns DRV_OK. + If the device is currently playing the sound identified by + the parameter in_SoundID, the function returns DRV_INPROCESS. + If the device/driver is currently playing a sound, but does + not support playing multiple sounds simultaneously, the + driver returns DRV_INPROCESS. + +*/ + +GLOBAL UBYTE audio_PlaySoundID (UBYTE in_DeviceID, + UBYTE in_SoundID, + BYTE in_RelVolume, + UBYTE in_Repeats) +{ + +TRACE_EVENT_P1("audio_PlaySoundID in_SoundID is %d",in_SoundID); + /* + * switch off current tone + */ + switch (act_tone.status) + { + +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//If Buzzer is available, disable the buzzer +#ifndef FF_MMI_NO_BUZZER + case BUZZER_ON: + BZ_Disable (); + case BUZZER_SILENT: +#endif + /* + * No Break + */ + case TONE_ON: + case TONE_SILENT: +#if defined (NEW_FRAME) + vsi_t_stop (VSI_CALLER CST_AUDIOTIMER); +#else + vsi_t_stop (VSI_CALLER audio_handle); +#endif + break; + default: + break; + } + + /* + * configure new tone + */ + if (in_SoundID EQ TONES_KEYBEEP) /* that is keybeep */ + { +#if defined (RIV_AUDIO) + beep.frequency_beep[0] = ((F_697) >> 5) & 0x07ff; + beep.amplitude_beep[0] = -((char) ((F_697) & 0x001f)); + beep.frequency_beep[1] = ((F_697) >> 5) & 0x07ff; + beep.amplitude_beep[1] = -((char) ((F_697) & 0x001f)); + beep.duration = 120; + #ifdef _TARGET_ + /* + * This function seems only to be available on target. (db / 2001-07-16) + */ + return audio_keybeep_start(beep,riv_audio_rp); + #endif +#else + /* MPHC is not present in GTI case */ + #ifndef FF_GTI + PALLOC (keybeep, MMI_KEYBEEP_REQ); + + keybeep->d_k_x1_kt0 = F_697; + keybeep->d_k_x1_kt1 = F_697; + keybeep->d_dur_kb = 6; /* equal 120 ms */ + PSENDX (L1, keybeep); + #endif /* FF_GTI */ +#endif + } + else + { + act_tone.call_tone = in_SoundID; +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//Before playing the tone, set the status and the tone type . +#ifndef FF_MMI_NO_BUZZER //If Buzzer is available + act_tone.status = BUZZER_SILENT; + act_tone.type = (UBYTE)TONE_TYPE[in_SoundID]; +#else //If Buzzer is not available + act_tone.status = TONE_SILENT; + act_tone.type = (UBYTE)AUDIO; +#endif + act_tone.descr = (T_DESCR *)TONE_DESCR[in_SoundID]; + act_tone.style = in_Repeats; + act_tone.descr_index = 0; +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//If Buzzer is available, call the audio_buzzer +#ifndef FF_MMI_NO_BUZZER + if (act_tone.type EQ BUZZER) + { + act_tone.volume = act_buzVolume; + audio_buzzer (); + } + else +#endif + { + act_tone.volume = act_speakerVolume; + audio_audio (); + } + } + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_PlaySoundbyImage | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to play a sound or melody. The + image of the sound/melody is passed to the driver (the + sound image format is implmementation dependent). + +*/ + +GLOBAL UBYTE audio_PlaySoundbyImage (UBYTE in_DeviceID, + void * in_SoundImagePtr, + BYTE in_RelVolume, + UBYTE in_Repeats) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_StopSoundbyID | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to manually stop playing a sound + or melody. When a sound is stopped manually, no signal is + created as to whether or not the signal AUDIO_SIGTYP_SOUNDEND + has been defined. If the function could stop playing the + specified sound, the function returns DRV_OK. If the device + is unknown or does not support this function or the specified + sound ID is invalid, the function returns DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE audio_StopSoundbyID (UBYTE in_DeviceID, + UBYTE in_SoundID) +{ + +TRACE_EVENT_P1("audio_StopSoundbyID in_SoundID is %d",in_SoundID); + /* + * switch off current tone + */ + switch (act_tone.status) + { +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//If Buzzer is available, disable it. +#ifndef FF_MMI_NO_BUZZER + case BUZZER_ON: + BZ_Disable (); + case BUZZER_SILENT: +#endif + /* + * No Break + */ + case TONE_ON: + case TONE_SILENT: + + /* Stop timer for reload */ + +#if defined (NEW_FRAME) + vsi_t_stop (VSI_CALLER CST_AUDIOTIMER); +#else + vsi_t_stop (VSI_CALLER audio_handle); +#endif + + if (act_tone.status EQ TONE_ON) + { + /* + * stop the current playing audio tone immediately + */ +#if defined (RIV_AUDIO) + #ifdef _TARGET_ + /* + * This function seems only to be available on target. (db / 2001-07-16) + */ + audio_tones_stop(riv_audio_rp); + #endif +#else + #ifndef FF_GTI + PALLOC (audio, MMI_TONE_REQ); + + audio->d_k_x1_t0 = 0; + audio->d_k_x1_t1 = 0; + audio->d_k_x1_t2 = 0; + audio->d_pe_rep = 1; + audio->d_pe_off = 0; + audio->d_se_off = 0; + audio->d_bu_off = 0; + audio->d_t0_on = 0; + audio->d_t0_off = 0; + audio->d_t1_on = 0; + audio->d_t1_off = 0; + audio->d_t2_on = 0; + audio->d_t2_off = 0; + + PSENDX (L1, audio); + #endif /* FF_GTI */ +#endif + } + act_tone.status = NO_TONE; + + break; + default: + break; + } + + return DRV_OK; +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_StopSoundbyImage | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to manually stop playing a sound + or melody. When a sound is stopped manually, no signal is + created as to whether or not the signal AUDIO_SIGTYP_SOUNDEND + has been defined. If the function could stop playing the + specified sound image, the function returns DRV_OK. + If the device is unknown or does not support this function + or the specified sound ID is invalid, the function + returns DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE audio_StopSoundbyImage (UBYTE in_DeviceID, + void * in_SoundImagePtr) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_SetSignal | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to defines a single signal or multiple + signals that is/are indicated to the process when the + event identified in the signal information data type as + SignalType occurs. To remove a signal call the function + audio_ResetSignal(). If one of the parameters of the + signal information data is invalid, the function returns + DRV_INVALID_PARAMS. If no signal call-back function has + been defined at the time of initialization, the driver + returns DRV_SIGFCT_NOTAVAILABLE. + +*/ + +GLOBAL UBYTE audio_SetSignal (drv_SignalID_Type * in_SignalIDPtr) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_ResetSignal | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to remove a previously set single + multiple signals. The signals that are removed are identified + by the Signal Information Data element Signal Type. All other + elements of the signal information data must be identical + to the signal(s) that is/are to be removed. + +*/ + +GLOBAL UBYTE audio_ResetSignal (drv_SignalID_Type * in_SignalIDPtr) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_timeout | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used after timeout of the audio timer. + +*/ + +#if defined (NEW_FRAME) +GLOBAL void audio_timeout (USHORT index) +#else +GLOBAL void audio_timeout (T_VSI_THANDLE handle) +#endif +{ +#if defined (NEW_FRAME) + if (index EQ CST_AUDIOTIMER) +#else + if (handle EQ audio_handle) +#endif + { + /*ccc + * only if it is the audio timer + */ +//Apr 04, 2005 REF: ENH 30063 xdeepadh +//For Buzzer +#ifndef FF_MMI_NO_BUZZER + if (act_tone.type EQ BUZZER) + audio_buzzer (); + else +#endif + audio_audio (); + } +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_buzzer | ++--------------------------------------------------------------------+ + + PURPOSE : Process a buzzer tone. + +*/ +//Apr 04, 2005 REF: ENH 30063 xdeepadh +#ifndef FF_MMI_NO_BUZZER //If buzzer is available +LOCAL void audio_buzzer (void) +{ + if (act_tone.status EQ NO_TONE) + return; + + switch (act_tone.descr + [act_tone.descr_index].command_1) + { + case 0: + /* + * switch buzzer off + */ + BZ_Disable (); +#if defined (NEW_FRAME) + vsi_t_start (VSI_CALLER CST_AUDIOTIMER, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#else + vsi_t_start (VSI_CALLER audio_handle, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#endif + act_tone.status = BUZZER_SILENT; + break; + + case 0xFFFE: + /* + * switch buzzer on continously + */ + BZ_Enable (); + BZ_Volume (act_buzVolume); + BZ_Tone (act_tone.descr + [act_tone.descr_index].command_1); + act_tone.status = BUZZER_ON; + break; + + case 0xFFFF: + /* + * end of list + */ + BZ_Disable (); + if (act_tone.style EQ AUDIO_PLAY_INFINITE) + { + act_tone.descr_index = 0; + audio_buzzer (); + } + else + act_tone.status = NO_TONE; + break; + + default: + /* + * switch buzzer on + */ + BZ_Enable (); + BZ_Volume (act_buzVolume); + BZ_Tone (act_tone.descr + [act_tone.descr_index].command_1); +#if defined (NEW_FRAME) + vsi_t_start (VSI_CALLER + CST_AUDIOTIMER, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#else + vsi_t_start (VSI_CALLER + audio_handle, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#endif + act_tone.status = BUZZER_ON; + break; + } +} + +#endif +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_audio | ++--------------------------------------------------------------------+ + + PURPOSE : Process an audio tone. + +*/ + +LOCAL void audio_audio (void) +{ + +TRACE_EVENT("audio_audio"); + if (act_tone.status EQ NO_TONE) + return; + + switch (act_tone.descr + [act_tone.descr_index].command_1) + { + case 0: + /* + * switch audio off + */ +#if defined (NEW_FRAME) + vsi_t_start (VSI_CALLER CST_AUDIOTIMER, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#else + vsi_t_start (VSI_CALLER audio_handle, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#endif + act_tone.status = TONE_SILENT; + break; + + case 0xFFFF: + /* + * end of list + */ + if (act_tone.style EQ AUDIO_PLAY_INFINITE) + { + act_tone.descr_index = 0; + audio_audio (); + } + else + act_tone.status = NO_TONE; + break; + + default: + /* + * switch audio tone on + */ + { +#if defined (RIV_AUDIO) + USHORT fa1 = act_tone.descr[act_tone.descr_index].command_1; + USHORT fa2 = act_tone.descr[act_tone.descr_index].command_2; + ULONG len = act_tone.descr[act_tone.descr_index].length; + t.tones[0].start_tone = 0; + t.tones[0].stop_tone = (USHORT) ((60 * len) / 13); + t.tones[0].frequency_tone = (fa1 >> 5) & 0x07ff; + t.tones[0].amplitude_tone = -((char) (fa1 & 0x001f)); + t.tones[1].start_tone = 0; + t.tones[1].stop_tone = (USHORT) ((60 * len) / 13); + t.tones[1].frequency_tone = (fa2 >> 5) & 0x07ff; + t.tones[1].amplitude_tone = -((char) (fa2 & 0x001f)); + t.tones[2].start_tone = 0; +// t.tones[2].stop_tone = 1; - NDH : Removed as this does not comply with the i/f spec + t.tones[2].stop_tone = (USHORT) ((60 * len) / 13); + t.tones[2].frequency_tone = NO_TONE; + t.tones[2].amplitude_tone = 0; + t.frame_duration = (USHORT) ((60 * len) / 13); + t.sequence_duration = (USHORT) ((60 * len) / 13); /* why 120 ??? -> changed to 60 */ + t.period_duration = (USHORT) ((60 * len) / 13); /* -"- */ + t.repetition = 1; + #ifdef _TARGET_ + /* + * This function seems only to be available on target. (db / 2001-07-16) + */ + audio_tones_start(&t,riv_audio_rp); + #endif +#else + #ifndef FF_GTI + PALLOC (audio, MMI_TONE_REQ); + /* + * Convert TDMA frames to 20 ms -> 3/13 + */ + + audio->d_k_x1_t0 = act_tone.descr[act_tone.descr_index].command_1; + audio->d_k_x1_t1 = act_tone.descr[act_tone.descr_index].command_2; + audio->d_k_x1_t2 = 0; + audio->d_pe_rep = 1; + audio->d_pe_off = (6*act_tone.descr[act_tone.descr_index].length) / 13; + audio->d_se_off = (6*act_tone.descr[act_tone.descr_index].length) / 13; + audio->d_bu_off = (3*act_tone.descr[act_tone.descr_index].length) / 13; + audio->d_t0_on = 0; + audio->d_t0_off = (3*act_tone.descr[act_tone.descr_index].length) / 13; + audio->d_t1_on = 0; + audio->d_t1_off = (3*act_tone.descr[act_tone.descr_index].length) / 13; + audio->d_t2_on = 0; + audio->d_t2_off = 0; + + PSENDX (L1, audio); + #endif /* FF_GTI */ +#endif + +#if defined (NEW_FRAME) + vsi_t_start (VSI_CALLER CST_AUDIOTIMER, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#else + vsi_t_start (VSI_CALLER audio_handle, + act_tone.descr + [act_tone.descr_index++].length*60/13); +#endif + act_tone.status = TONE_ON; + } + break; + } +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_UlMute | ++--------------------------------------------------------------------+ + + PURPOSE : This function mutes the uplink path. + +*/ +LOCAL void audio_UlMute (UBYTE mute) +{ +// Apr 26, 2005 REF : CRR 30627 xpradipg +// local variable definition +#ifdef FF_MMI_SERVICES_MIGRATION + T_AUDIO_FULL_ACCESS_WRITE p_parameter; + T_AUDIO_FULL_ACCESS_READ p_parameter1; + T_RV_RETURN_PATH return_path = {0, NULL}; + T_AUDIO_RET result; +// June 13, 2005 REF : GSM_ENH_32062 - xpradipg +// the default value is assigned to AUDIO_MICROPHONE_OUTPUT_BIAS_2_0V + static INT8 microphone_gain = AUDIO_MICROPHONE_OUTPUT_BIAS_2_0V; + INT8 setgain = AUDIO_MICROPHONE_MUTE; +#endif + if (mute) + { +#ifdef ALR +// June 13, 2005 REF : GSM_ENH_32062 - xpradipg +// the audio is unmuted for the variable "mute" with value greater than "0" +// Apr 26, 2005 REF : CRR 30627 xpradipg +// read the microphone gain, store it and mute the microphone +#ifdef FF_MMI_SERVICES_MIGRATION + p_parameter1.variable_indentifier = AUDIO_MICROPHONE_GAIN; + p_parameter1.data = (void*)µphone_gain; + result = audio_full_access_read(&p_parameter1); + if(result != 0) + { + TRACE_EVENT("error reading the handeld parameters"); + } + p_parameter.variable_indentifier = AUDIO_MICROPHONE_GAIN; + setgain = AUDIO_MICROPHONE_MUTE; + p_parameter.data = (void*)&setgain; + result = audio_full_access_write(&p_parameter, return_path); + if(result != 0) + TRACE_EVENT("ERROR - not written1"); +#else + ABB_UlMute (1); +#endif +#else + VG_UlVolume (0); +#endif + } + else + { +#ifdef ALR +// June 13, 2005 REF : GSM_ENH_32062 - xpradipg +// the audio is muted for the variable "mute" with value <= to "0" +// Apr 26, 2005 REF : CRR 30627 xpradipg +// restore the volume back once the unmuting is done +#ifdef FF_MMI_SERVICES_MIGRATION + p_parameter.variable_indentifier = (UINT8)AUDIO_MICROPHONE_GAIN ; + p_parameter.data = (void*)µphone_gain; + result = audio_full_access_write(&p_parameter, return_path); + if(result != 0) + TRACE_EVENT("ERROR - not written"); +#else + ABB_UlMute (0); +#endif +#else + VG_UlVolume (act_micVolume); +#endif + } +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_AUDIO | +| STATE : code ROUTINE : audio_set_tty | ++--------------------------------------------------------------------+ + + PURPOSE : This function (de)activates the TTY codec. + +*/ + +#if defined (FF_TTY) || defined (_TTY_SIMU) +GLOBAL void audio_set_tty (T_TTY_CMD tty) +{ + if (tty < TTY_OFF OR tty > TTY_ALL) + { + TRACE_EVENT_P1 ("TTY invalid parameter: %d", tty); + return; + } + if (tty NEQ TTY_OFF) + { +#if defined (RIV_AUDIO) && !defined (_TTY_SIMU) + T_AUDIO_MODE_SAVE audio_mode; + T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL}; + T_AUDIO_RET audio_ret; + + if (!tty_state) + { + tty_cfg.Mode = TTY_EXT_START; + tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0; + + ret.callback_func = audio_save_def_return; + strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[0]); + audio_ret = audio_mode_save (&audio_mode, ret); + + if (audio_ret NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE SAVE def: %d", (int)audio_ret); + } + else + { + AUDIO_TRC_FUNC ("AUDIO MODE SAVE def"); + tty_cmd = (UBYTE)tty; + } + } + else + { + AUDIO_TRC_EVENT ("TTY running"); + } +#else + TRACE_EVENT_P1 ("TTY start: %d", tty); +#endif + } + else + { +#if defined (RIV_AUDIO) && !defined (_TTY_SIMU) + T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL}; + T_AUDIO_RET audio_ret; + + if (tty_state) + { + ret.callback_func = audio_tty_return; + tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0; + tty_cfg.Mode = TTY_STOP; + audio_ret = audio_tty_set_config (&tty_cfg, &ret); + + if (audio_ret NEQ AUDIO_OK) + { + tty_state = FALSE; + AUDIO_TRC_EVENT_P1 ("Error TTY stop: %d", (int)audio_ret); + } + else + { + AUDIO_TRC_FUNC ("TTY to be stopped"); + } + } + else + { + AUDIO_TRC_FUNC ("TTY already ended"); + } +#else + TRACE_EVENT ("TTY stop"); +#endif + } +} + +/* This function changes the TTY mode during an active TTY call */ +GLOBAL void audio_dyn_set_tty (T_TTY_CMD tty) +{ + T_AUDIO_MODE_LOAD audio_mode; + T_RV_RETURN_PATH load_ret = {NOT_PRESENT_8BIT, NULL}; + T_AUDIO_RET audio_ret; + UBYTE cmd; + + if (tty < TTY_OFF OR tty > TTY_ALL) + { + TRACE_EVENT_P1 ("TTY invalid parameter: %d", tty); + return; + } + +#if defined (RIV_AUDIO) && !defined (_TTY_SIMU) + + cmd = (UBYTE)tty; + if (tty_state) + { + load_ret.callback_func = audio_dyn_load_return; + } + else + { + /* + * If the TTY mode was default before then need to start + * the TTY driver + */ + tty_cfg.Mode = TTY_EXT_START; + tty_cfg.ThresholdRead = tty_cfg.ThreshHoldWrite = 0; + load_ret.callback_func = audio_load_return; + } + + strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[(int)cmd]); + audio_ret = audio_mode_load (&audio_mode, load_ret); + + if (audio_ret NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD TTY: %d", (int)audio_ret); + } + else + { + AUDIO_TRC_FUNC ("AUDIO MODE LOAD def"); + tty_cmd = (UBYTE)tty; + } +#else + TRACE_EVENT_P1 ("TTY mode change: %d", tty); +#endif + +} + +#if defined (RIV_AUDIO) AND !defined (_TTY_SIMU) +LOCAL void audio_tty_return (void *tty_result) +{ + T_AUDIO_MODE_LOAD audio_mode; + T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL}; + T_AUDIO_RET audio_ret; + + if (((T_AUDIO_TTY_STATUS *)tty_result)->status NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error TTY callback: %d", + (int)((T_AUDIO_TTY_STATUS *)tty_result)->status); + } + tty_state = FALSE; + tty_cfg.Mode = TTY_STOP; + AUDIO_TRC_FUNC ("TTY end"); + + ret.callback_func = audio_load_return; + strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[0]); + audio_ret = audio_mode_load (&audio_mode, ret); + + if (audio_ret NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD def: %d", (int)audio_ret); + } +} + +LOCAL void audio_save_def_return (void *result) +{ + T_AUDIO_MODE_LOAD audio_mode; + T_RV_RETURN_PATH load_ret = {NOT_PRESENT_8BIT, NULL}; + T_AUDIO_RET audio_ret; + + if (((T_AUDIO_SAVE_DONE *)result)->status NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE SAVE def callback: %d", + (int)((T_AUDIO_SAVE_DONE *)result)->status); + } + else + { + AUDIO_TRC_FUNC ("AUDIO def saved"); + + load_ret.callback_func = audio_load_return; + strcpy (audio_mode.audio_mode_filename, audio_mode_names_tty[(int)tty_cmd]); + audio_ret = audio_mode_load (&audio_mode, load_ret); + + if (audio_ret NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD TTY: %d", (int)audio_ret); + } + } +} + +LOCAL void audio_load_return (void *result) +{ + if (((T_AUDIO_LOAD_DONE *)result)->status NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD callback: %d", + (int)((T_AUDIO_LOAD_DONE *)result)->status); + } + else + { + T_RV_RETURN_PATH ret = {NOT_PRESENT_8BIT, NULL}; + T_AUDIO_RET audio_ret; + + if (!tty_state AND tty_cfg.Mode EQ TTY_EXT_START) + { + ret.callback_func = audio_tty_return; + audio_ret = audio_tty_set_config (&tty_cfg, &ret); + + if (audio_ret NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error TTY set: %d", (int)audio_ret); + } + else + { + tty_state = TRUE; + AUDIO_TRC_FUNC ("AUDIO TTY loaded & start"); + } + } + else if (!tty_state AND tty_cfg.Mode EQ TTY_STOP) + { + tty_cmd = (UBYTE)TTY_OFF; + AUDIO_TRC_FUNC ("AUDIO def loaded"); + } + else + { + AUDIO_TRC_EVENT_P2 ("TTY improper state: %d; mode: %d", + (int)tty_state, (int)tty_cfg.Mode); + } + } +} + +LOCAL void audio_dyn_load_return (void *result) +{ + if (((T_AUDIO_LOAD_DONE *)result)->status NEQ AUDIO_OK) + { + AUDIO_TRC_EVENT_P1 ("Error AUDIO MODE LOAD callback: %d", + (int)((T_AUDIO_LOAD_DONE *)result)->status); + } + else + { + AUDIO_TRC_EVENT_P1 ("TTY mode changed: %d", (int)tty_cmd); + } +} +#endif +#endif + +/******************************************************************* + * * + * PART II: Simulation for Windows * + * * + *******************************************************************/ + +#if defined (_SIMULATION_) +/* + * Dummies for driver calls + */ + +LOCAL void BZ_Init (void) +{ +} + +LOCAL void BZ_Enable (void) +{ +} + +LOCAL void BZ_Disable (void) +{ +} + +LOCAL void BZ_Tone (int f) +{ +} + +LOCAL void BZ_Volume (int v) +{ +} + +#ifdef ALR +LOCAL void ABB_DlVolume (UBYTE v) +{ +} + +LOCAL void ABB_DlMute (UBYTE mute) +{ +} + +LOCAL void ABB_UlMute (UBYTE value) +{ +} + +LOCAL void ABB_SideTone (UBYTE v) +{ +} +#else +LOCAL void VG_UlVolume (UBYTE v) +{ +} + +LOCAL void VG_DlVolume (UBYTE v) +{ +} + +LOCAL void VG_DlMute (UBYTE mute) +{ +} + +LOCAL void VG_SideTone (UBYTE v) +{ +} +#endif + +#endif + +#if defined (RIV_AUDIO) +void audio_riv_audio_cb (void *buf) +{ + /* nothing to do for this time */ +} +#endif diff -r 56e3d8560d69 -r 549b7ac60300 gsm-fw/g23m-glue/gdi/ffs_coat.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/gdi/ffs_coat.c Thu Apr 23 06:42:53 2015 +0000 @@ -0,0 +1,847 @@ +/* ++----------------------------------------------------------------------------- +| Modul : ffs_coat ++----------------------------------------------------------------------------- +| 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 : Encapsulate the FFS API. ++----------------------------------------------------------------------------- +*/ + +#ifndef __FFS_COAT_C__ +#define __FFS_COAT_C__ + +/*==== INCLUDES ===================================================*/ +#define SAP_ACI + +#include "typedefs.h" +#include "pconst.cdg" +#include "prim.h" +#include "vsi.h" +#include "ffs/ffs.h" +#include "ffs_coat.h" + + +/*==== CONSTANTS ==================================================*/ + +/*==== TYPES ======================================================*/ + +/*==== CONSTANTS ==================================================*/ +//#define FFS_STATE_CHECK +#define FFS_PAR_CHECK +#define FFS_ERR_CHECK + +/*==== EXTERNALS ==================================================*/ + +/*==== VARIABLES ==================================================*/ + +/*==== MACROS =====================================================*/ +#if defined(FFS_STATE_CHECK) +#define _STATE_CHECK(ffs_ret)\ + {ffs_ret=_FFS_StateCheck (_FFS_FCT_NAME,hMMI,file,line);\ + if (ffs_ret NEQ EFFS_OK)return ffs_ret;} +#else /* FFS_PAR_CHECK */ +#define _STATE_CHECK(ffs_ret) +#endif /* FFS_PAR_CHECK */ + +#if defined(FFS_PAR_CHECK) +#define _PAR_CHECK_NULL(parname,parnumber,ret)\ + if (!parname){\ + _FFS_ParCheck ("NULL", _FFS_FCT_NAME, parnumber, hMMI,file, line);\ + return ret;} + +#define _PAR_CHECK_LESSZERO(parname,parnumber,ret)\ + if (parname < 0){\ + _FFS_ParCheck ("<0", _FFS_FCT_NAME, parnumber, hMMI,file, line);\ + return ret;} +#else /* FFS_PAR_CHECK */ +#define _PAR_CHECK_NULL(parname,parnumber,ret) +#define _PAR_CHECK_LESSZERO(parname,parnumber,ret) +#endif /* FFS_PAR_CHECK */ + + +#if defined(FFS_ERR_CHECK) +#define _ERROR_CHECK(ffs_ret)\ + if (ffs_ret < 0)_FFS_ErrorMsg(NULL, _FFS_FCT_NAME, ffs_ret, hMMI,file, line) +#else /* FFS_ERR_CHECK */ +#define _ERROR_CHECK(ffs_ret) +#endif /* FFS_ERR_CHECK */ + +/*==== FUNCTIONS ==================================================*/ +#if defined(FFS_COAT_ENABLED) +static void _FFS_ParCheck (const char * const errmsg, const char * const fct, + int parameter, + T_HANDLE hMMI, const char * const file, int line); + +static void _FFS_ErrorMsg (const char * const errmsg, const char * const fct, + int ffs_ret, + T_HANDLE hMMI, const char * const file, int line); + +/* FFS functions whose positive return value has a meaning */ +T_FFS_FD _FFS_open(const char *name, T_FFS_OPEN_FLAGS option, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_open" +T_FFS_FD ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + + ffs_ret = ffs_open (name, option); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + +T_FFS_SIZE _FFS_write(T_FFS_FD fdi, void *src, T_FFS_SIZE amount, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_write" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (src, 2, EFFS_BADOP); + + ffs_ret = ffs_write (fdi, src, amount); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_SIZE _FFS_read(T_FFS_FD fdi, void *src, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_read" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (src, 2, EFFS_BADOP); + + ffs_ret = ffs_read (fdi, src, size); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_SIZE _FFS_seek(T_FFS_FD fdi, T_FFS_SIZE offset, T_FFS_WHENCE whence, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_seek" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_LESSZERO (offset, 2, EFFS_BADOP); + + ffs_ret = ffs_seek (fdi, offset, whence); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_SIZE _FFS_opendir(const char *name, T_FFS_DIR *dir, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_opendir" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTADIR); + _PAR_CHECK_NULL (dir, 2, EFFS_NOTADIR); + + ffs_ret = ffs_opendir (name, dir); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_SIZE _FFS_readdir (T_FFS_DIR *dir, char *name, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_readdir" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (dir, 1, EFFS_NOTADIR); + _PAR_CHECK_NULL (name, 2, EFFS_NOTADIR); + _PAR_CHECK_LESSZERO (size, 3, EFFS_NOTADIR); + + ffs_ret = ffs_readdir (dir, name, size); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_SIZE _FFS_readlink(const char *name, char *addr, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_readlink" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTAFILE); + _PAR_CHECK_NULL (addr, 2, EFFS_NOTAFILE); + _PAR_CHECK_LESSZERO (size, 3, EFFS_FILETOOBIG); + + ffs_ret = ffs_readlink (name, addr, size); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_SIZE _FFS_file_read(const char *name, void *addr, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_file_read" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTAFILE); + _PAR_CHECK_NULL (addr, 2, EFFS_NOTAFILE); + _PAR_CHECK_LESSZERO (size, 3, EFFS_FILETOOBIG); + + ffs_ret = ffs_file_read (name, addr, size); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_SIZE _FFS_fread(const char *name, void *addr, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_fread" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTAFILE); + _PAR_CHECK_NULL (addr, 2, EFFS_NOTAFILE); + _PAR_CHECK_LESSZERO (size, 3, EFFS_FILETOOBIG); + + /* ffs_fread is deprecated, use ffs_file_read instead */ + ffs_ret = ffs_file_read (name, addr, size); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + + +/* FFS functions which return a value EFFS_OK if OK */ +T_FFS_RET _FFS_preformat(UINT16 magic, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_preformat" +T_FFS_SIZE ffs_ret; + + ffs_ret = ffs_preformat (magic); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_format(const char *name, UINT16 magic, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_format" +T_FFS_SIZE ffs_ret; + + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + + ffs_ret = ffs_format (name, magic); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_close(T_FFS_FD fdi, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_close" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + + ffs_ret = ffs_close (fdi); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_truncate(const char *path, T_FFS_OFFSET length, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_truncate" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (path, 1, EFFS_NOTFOUND); + _PAR_CHECK_LESSZERO (length, 2, EFFS_NOTFOUND); + + ffs_ret = ffs_truncate (path, length); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_ftruncate(T_FFS_FD fdi, T_FFS_OFFSET length, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_ftruncate" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (fdi, 1, EFFS_BADFD); + _PAR_CHECK_LESSZERO (length, 2, EFFS_NOTFOUND); + + ffs_ret = ffs_ftruncate (fdi, length); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_fdatasync(T_FFS_FD fdi, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_fdatasync" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (fdi, 1, EFFS_BADFD); + + ffs_ret = ffs_fdatasync (fdi); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_stat(const char *name, T_FFS_STAT *stat, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_stat" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTFOUND); + _PAR_CHECK_NULL (stat, 2, EFFS_NOTFOUND); + + ffs_ret = ffs_stat (name, stat); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_fstat(T_FFS_FD fdi, T_FFS_STAT *stat, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_fstat" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (fdi, 1, EFFS_BADFD); + _PAR_CHECK_NULL (stat, 2, EFFS_NOTFOUND); + + ffs_ret = ffs_fstat (fdi, stat); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_lstat(const char *name, T_FFS_STAT *stat, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_lstat" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTFOUND); + _PAR_CHECK_NULL (stat, 2, EFFS_NOTFOUND); + + ffs_ret = ffs_lstat (name, stat); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_xlstat(const char *name, T_FFS_XSTAT *stat, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_xlstat" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTFOUND); + _PAR_CHECK_NULL (stat, 2, EFFS_NOTFOUND); + + ffs_ret = ffs_xlstat (name, stat); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_linkstat(const char *name, T_FFS_STAT *stat, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_linkstat" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTFOUND); + _PAR_CHECK_NULL (stat, 2, EFFS_NOTFOUND); + + /* ffs_linkstat is deprecated, use ffs_lstat instead */ + ffs_ret = ffs_lstat (name, stat); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_remove(const char *name, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_remove" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_NOTFOUND); + + ffs_ret = ffs_remove (name); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_mkdir(const char *name, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_mkdir" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + + ffs_ret = ffs_mkdir (name); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_symlink(const char *name, const char *actualpath, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_symlink" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + _PAR_CHECK_NULL (actualpath, 2, EFFS_BADNAME); + + ffs_ret = ffs_symlink (name, actualpath); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_rename(const char *oldname, const char *newname, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_rename" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (oldname, 1, EFFS_BADNAME); + _PAR_CHECK_NULL (newname, 2, EFFS_BADNAME); + + ffs_ret = ffs_rename (oldname, newname); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_file_write(const char *name, void *addr, T_FFS_SIZE size, + T_FFS_OPEN_FLAGS flags, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_file_write" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + _PAR_CHECK_NULL (addr, 2, EFFS_NOTAFILE); + _PAR_CHECK_LESSZERO (size, 2, EFFS_FILETOOBIG); + + ffs_ret = ffs_file_write (name, addr, size, flags); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_fcreate(const char *name, void *addr, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_fcreate" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + _PAR_CHECK_NULL (addr, 2, EFFS_NOTAFILE); + _PAR_CHECK_LESSZERO (size, 2, EFFS_FILETOOBIG); + + /* ffs_fcreate is deprecated, use ffs_file_write instead */ + ffs_ret = ffs_file_write (name, addr, size, FFS_O_CREATE|FFS_O_EXCL); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_fupdate(const char *name, void *addr, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_fupdate" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + _PAR_CHECK_NULL (addr, 2, EFFS_NOTAFILE); + _PAR_CHECK_LESSZERO (size, 2, EFFS_FILETOOBIG); + + /* ffs_fupdate is deprecated, use ffs_file_write instead */ + ffs_ret = ffs_file_write (name, addr, size, FFS_O_TRUNC); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_fwrite(const char *name, void *addr, T_FFS_SIZE size, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_fwrite" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (name, 1, EFFS_BADNAME); + _PAR_CHECK_NULL (addr, 2, EFFS_NOTAFILE); + _PAR_CHECK_LESSZERO (size, 2, EFFS_FILETOOBIG); + + /* ffs_fwrite is deprecated, use ffs_file_write instead */ + ffs_ret = ffs_file_write (name, addr, size, FFS_O_CREATE|FFS_O_TRUNC); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_fcontrol(const char *pathname, INT8 action, int param, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_fcontrol" +T_FFS_SIZE ffs_ret; + + _STATE_CHECK (ffs_ret); + _PAR_CHECK_NULL (pathname, 1, EFFS_BADNAME); + + ffs_ret = ffs_fcontrol (pathname, action, param); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + + +T_FFS_RET _FFS_query(INT8 query, void *p, + T_HANDLE hMMI, const char * const file, int line) +{ +#define _FFS_FCT_NAME "ffs_query" +T_FFS_SIZE ffs_ret; + + _PAR_CHECK_NULL (p, 2, EFFS_BADNAME); + + ffs_ret = ffs_query (query, p); + _ERROR_CHECK (ffs_ret); + + return ffs_ret; +#undef _FFS_FCT_NAME +} + +#if defined(FFS_PAR_CHECK) +static void _FFS_ParCheck (const char * const errmsg, const char * const fct, + int parameter, + T_HANDLE hMMI, const char * const file, int line) +{ + char *f; + int l; + + l = strlen (file); + if (l <= 20) + f = (char *)file; + else + f = (char *)file + l - 20; + + TRACE_EVENT_P5 ("FFS PAR ERR:par %u of %s is %s (%s#%u)", + parameter, + fct ? fct : "", + errmsg ? errmsg : "", + f, + line); +} +#endif /* FFS_PAR_CHECK */ + +char *ffs_strerror(effs_t error) +{ + switch (error) { + case EFFS_OK: return "ok"; /* 0 */ + case EFFS_NODEVICE: return "flash device unknown"; /* -1 */ + case EFFS_CORRUPTED: return "filesystem corrupted!?"; /* -2 */ + case EFFS_NOPREFORMAT: return "ffs not preformatted"; /* -3 */ + case EFFS_NOFORMAT: return "ffs not formatted"; /* -4 */ + case EFFS_BADFORMAT: return "incompatible ffs version"; /* -5 */ + case EFFS_MAGIC: return "bad magic"; /* -6 */ + case EFFS_AGAIN: return "not ready, try again later"; /* -7 */ + case EFFS_NOSYS: return "function not implemented"; /* -8 */ + case EFFS_DRIVER: return "ffs device driver error"; /* -9 */ + case EFFS_NOSPACE: return "out of data space"; /* -10 */ + case EFFS_FSFULL: return "file system full, no free inodes"; /* -11 */ + case EFFS_BADNAME: return "bad filename"; /* -12 */ + case EFFS_NOTFOUND: return "object not found"; /* -13 */ + case EFFS_EXISTS: return "object exists"; /* -14 */ + case EFFS_ACCESS: return "access permission violation"; /* -15 */ + case EFFS_NAMETOOLONG: return "filename too long"; /* -16 */ + case EFFS_INVALID: return "invalid argument"; /* -17 */ + case EFFS_DIRNOTEMPTY: return "directory not empty"; /* -18 */ + case EFFS_NOTADIR: return "object is not a directory"; /* -19 */ + case EFFS_SPARE: return "SPARE"; /* -20 */ + case EFFS_FILETOOBIG: return "file too big"; /* -21 */ + case EFFS_NOTAFILE: return "object is not a file"; /* -22 */ + case EFFS_PATHTOODEEP: return "path too deep"; /* -23 */ + case EFFS_NUMFD: return "Max number of open files reached"; /* -24 */ + case EFFS_BADFD: return "Bad file descriptor"; /* -25 */ + case EFFS_BADOP: return "Bad operation"; /* -26 */ + case EFFS_LOCKED: return "The file is locked"; /* -27 */ + case EFFS_TOOBIG: return "too big (tmffs buffer overflow)"; /* -30 */ + case EFFS_MEMORY: return "out of memory"; /* -31 */ + case EFFS_MSGSEND: return "message send failed"; /* -32 */ + case EFFS_SIBLINGLOOP: return "directory sibling loop"; /* -40 */ + case EFFS_NOBLOCKS: return "No more blocks!?"; /* -41 */ + default: return "unknown ffs error code!"; + } +} + +static void _FFS_ErrorMsg (const char * const errmsg, const char * const fct, + int ffs_ret, + T_HANDLE hMMI, const char * const file, int line) +{ + char *f; + int l; + + l = strlen (file); + if (l <= 20) + f = (char *)file; + else + f = (char *)file + l - 20; + + TRACE_EVENT_P5 ("FFS ERR on %s: %d %s (%s#%u)", + fct ? fct : "", + ffs_ret, + ffs_strerror (ffs_ret), + f, + line); +} + +#endif /* FFS_COAT_ENABLED */ + +#if 1 +GLOBAL T_FFS_RET _FFS_StateCheck (const char * const fct, + T_HANDLE hMMI, const char * const file, int line) +{ + int query_result; + int bytes_free, bytes_used, bytes_max, bytes_lost; + T_FFS_RET ffs_ret; + + SYST_TRACE ("_FFS_StateCheck()"); + + bytes_free = bytes_used = bytes_max = bytes_lost = 0; + + ffs_ret = ffs_query (Q_BYTES_FREE, &query_result); + if (ffs_ret EQ EFFS_OK) + { + bytes_free = query_result; + ffs_ret = ffs_query (Q_BYTES_USED, &query_result); + if (ffs_ret EQ EFFS_OK) + { + bytes_used = query_result; + ffs_ret = ffs_query (Q_BYTES_LOST, &query_result); + if (ffs_ret EQ EFFS_OK) + { + bytes_lost = query_result; + ffs_ret = ffs_query (Q_BYTES_MAX, &query_result); + if (ffs_ret EQ EFFS_OK) + { + bytes_max = query_result; + } + } + } + } + + #if 0 + { + char *f; + int l; + + PALLOC (trc_ind, ACI_TRC_IND); /* T_ACI_TRC_IND */ + trc_ind->cmd_src = 1; /* CMD_SRC_ATI_1 */ + + l = strlen (file); + if (l <= 20) + f = (char *)file; + else + f = (char *)file + l - 20; + + sprintf (trc_ind->trc_buf, "STATE before %s (%s#%u)", fct?fct:"", f, line); + trc_ind->trc_len = strlen (trc_ind->trc_buf); + + PSEND (hMMI, trc_ind); + } + #endif /* 0|1 */ + { + TRACE_EVENT_P4 ("FFS free=%5u used=%5u lost=%5u max=%6u", + bytes_free, + bytes_used, + bytes_lost, + bytes_max); + } + + return EFFS_OK; +} +#else /* 1|0 */ +GLOBAL T_FFS_RET _FFS_StateCheck (const char * const fct, + T_HANDLE hMMI, const char * const file, int line) +{ + USHORT query_result; + int objects_free, objects_used, objects_max, objects_lost; + T_FFS_RET ffs_ret; + + SYST_TRACE ("_FFS_StateCheck()"); + + ffs_ret = ffs_query (Q_OBJECTS_FREE, &query_result); + if (ffs_ret NEQ EFFS_OK) + return ffs_ret; + else + objects_free = query_result; + + ffs_ret = ffs_query (Q_INODES_USED, &query_result); + if (ffs_ret NEQ EFFS_OK) + return ffs_ret; + else + objects_used = query_result; + + ffs_ret = ffs_query (Q_INODES_LOST, &query_result); + if (ffs_ret NEQ EFFS_OK) + return ffs_ret; + else + objects_lost = query_result; + + ffs_ret = ffs_query (Q_OBJECTS_MAX, &query_result); + if (ffs_ret NEQ EFFS_OK) + return ffs_ret; + else + objects_max = query_result; + + #if 0 + { + char *f; + int l; + + PALLOC (trc_ind, ACI_TRC_IND); /* T_ACI_TRC_IND */ + trc_ind->cmd_src = 1; /* CMD_SRC_ATI_1 */ + + l = strlen (file); + if (l <= 20) + f = (char *)file; + else + f = (char *)file + l - 20; + + sprintf (trc_ind->trc_buf, "STATE before %s (%s#%u)", fct?fct:"", f, line); + trc_ind->trc_len = strlen (trc_ind->trc_buf); + + PSEND (hMMI, trc_ind); + } + #endif /* 0|1 */ + { + PALLOC (trc_ind, ACI_TRC_IND); /* T_ACI_TRC_IND */ + trc_ind->cmd_src = 1; /* CMD_SRC_ATI_1 */ + + sprintf (trc_ind->trc_buf, "FFS objs: free=%3u used=%3u lost=%3u max=%3u", + objects_free, objects_used, objects_lost, objects_max); + trc_ind->trc_len = strlen (trc_ind->trc_buf); + + SYST_TRACE ((char *)trc_ind->trc_buf); + + PSEND (hMMI, trc_ind); + } + + return EFFS_OK; +} +#endif /* 1|0 */ + +#endif + diff -r 56e3d8560d69 -r 549b7ac60300 gsm-fw/g23m-glue/gdi/power.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/gdi/power.c Thu Apr 23 06:42:53 2015 +0000 @@ -0,0 +1,359 @@ +/* ++----------------------------------------------------------------------------- +| Project : GSM-PS +| Modul : DRV_PWR ++----------------------------------------------------------------------------- +| 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 defines the power management device driver +| for the G23 protocol stack. +| +| This driver is used to control all power related functions +| such as charger and battery control. The driver does support +| multiple devices and therefore no open and close functionality +| is supported. The driver can be configured to signal different +| state transitions, for example battery level has reached the +| "battery low" level. This is done by setting an OS signal or +| calling a specified call-back function. ++----------------------------------------------------------------------------- +*/ + +#ifndef DRV_PWR_C +#define DRV_PWR_C +#endif + +/*==== INCLUDES ===================================================*/ +#if defined (NEW_FRAME) + +#include +#include "typedefs.h" +#include "gdi.h" +#include "pwr.h" + +#else + +#include +#include "stddefs.h" +#include "gdi.h" +#include "pwr.h" + +#endif +/*==== EXPORT =====================================================*/ +#if defined (_TMS470_NOT_YET) +EXTERN void BAT_Init (void (*pwr_batlevel)(UBYTE level), + void (*pwr_batstatus)(UBYTE status)); +#else +LOCAL void BAT_Init (void (*pwr_batlevel)(UBYTE level), + void (*pwr_batstatus)(UBYTE status)); +#endif + +LOCAL void pwr_batlevel (UBYTE level); +LOCAL void pwr_batstatus (UBYTE status); + +/*==== VARIABLES ==================================================*/ +drv_SignalCB_Type pwr_signal_callback = NULL; +UBYTE pwr_act_level; +UBYTE pwr_act_status; +pwr_DCB_Type pwr_DCB; +pwr_Status_Type pwr_Status; +/*==== VARIABLES ==================================================*/ + +/*==== FUNCTIONS ==================================================*/ + +/*==== CONSTANTS ==================================================*/ +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_Init | ++--------------------------------------------------------------------+ + + PURPOSE : The function initializes the driverīs internal data. + The function returns DRV_OK in case of a successful + completition. The function returns DRV_INITIALIZED if + the driver has already been initialized and is ready to + be used or is already in use. In case of an initialization + failure, which means the that the driver cannot be used, + the function returns DRV_INITFAILURE. + +*/ + +GLOBAL UBYTE pwr_Init (drv_SignalCB_Type in_SignalCBPtr) +{ + pwr_signal_callback = in_SignalCBPtr; /* store call-back function */ + pwr_DCB.RangeMin = 10; /* 10 Percent */ + pwr_DCB.RangeMax = 100; /* 100 Percent */ + pwr_DCB.Steps = 4; /* 4 Steps */ + + pwr_Status.Status = 0; + pwr_Status.BatteryLevel = 0; + pwr_Status.ChargeLevel = 0; + + /* + * Initialise TI driver with internal callback functions + * + * pwr_batlevel is called after change of battery level + * pwr_batstatus is called after change of external or charger + * unit + * + */ + BAT_Init (pwr_batlevel, pwr_batstatus); + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_Exit | ++--------------------------------------------------------------------+ + + PURPOSE : The function is used to indicate PWR that the driver + and its functionality isnīt needed anymore. + +*/ + +GLOBAL void pwr_Exit (void) +{ + pwr_signal_callback = NULL; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_SetSignal | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to define a single signal or multiple + signals that is/are indicated to the process when the event + identified in the signal information data type as SignalType + occurs. + To remove a signal, call the function pwr_ResetSignal(). + If one of the parameters of the signal information data is + invalid, the function returns DRV_INVALID_PARAMS. + If no signal call-back function has been defined at the + time of initilization the driver returns DRV_SIGFCT_NOTAVAILABLE. + +*/ + +GLOBAL UBYTE pwr_SetSignal (drv_SignalID_Type * in_SignalIDPtr) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_ResetSignal | ++--------------------------------------------------------------------+ + + PURPOSE : The function is used to remove a single or multiple signals + that has previously been set. The signals that are removed + are identified by the Signal Information Data element called + SignalType. All other elements of the Signal Information Data + must be identical to the signal(s) that is/are to be + removed. If the SignalID provided can not be found, the + function returns DRV_INVALID_PARAMS. + If no signal call-back function has beed defined at the + time of initialization, the driver returns DRV_SIGFCT_NOTAVAILABLE. + +*/ + +GLOBAL UBYTE pwr_ResetSignal (drv_SignalID_Type * in_SignalIDPtr) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_SetConfig | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to configure the driver. + If any value of this configuration is out of range or + invalid in combination with any other value of the + configuration, the function returns DRV_INVALID_PARAMS. + Call the pwr_GetConfig() function to retrieve the drivers + configuration. + +*/ + +GLOBAL UBYTE pwr_SetConfig (pwr_DCB_Type * in_DCBPtr) +{ + memcpy (&pwr_DCB, in_DCBPtr, sizeof (pwr_DCB_Type)); + pwr_Status.BatteryLevel = 0; + pwr_Status.ChargeLevel = 0; + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_GetConfig | ++--------------------------------------------------------------------+ + + PURPOSE : The function is used to retrieve the configuration of + the driver. The configuration is returned in the driver + control block to which the pointer out_DCBPtr points. + If the driver is not configured, the function returns + DRV_NOTCONFIGURED. + Call the pwr_SetConfig() function to configure the driver. + +*/ + +GLOBAL UBYTE pwr_GetConfig (pwr_DCB_Type * out_DCBPtr) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_GetStatus | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to retrieve the status of the driver + respectively the power unit. + In case of a successful completion the driver returns + DRV_OK and the current status of the driver in the buffer + out_StatusPtr points to. + In case the driver is not configured yet, it returns + DRV_NOTCONFIGURED. In this case the contents of the + buffer out_StatusPtr is invalid. + In case out_StatusPtr equals NULL the driver returns + DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE pwr_GetStatus (pwr_Status_Type * out_StatusPtr) +{ + if ( out_StatusPtr EQ NULL ) + { + return DRV_INVALID_PARAMS; + } + else + { + out_StatusPtr->Status = pwr_Status.Status; + out_StatusPtr->BatteryLevel = pwr_Status.BatteryLevel; + out_StatusPtr->ChargeLevel = pwr_Status.ChargeLevel; + } + + return DRV_OK; +} + + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_BatLevel | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called by the low level driver after + change of battery level. +*/ + +LOCAL void pwr_batlevel (UBYTE level) +{ + UBYTE calculated_level; + drv_SignalID_Type signal_params; + + pwr_Status.ChargeLevel = level; + + if (level <= pwr_DCB.RangeMin) + calculated_level = 0; + if (level >= pwr_DCB.RangeMax) + calculated_level = pwr_DCB.Steps +1; + if (level > pwr_DCB.RangeMin AND + level < pwr_DCB.RangeMax) + { + level -= pwr_DCB.RangeMin; + calculated_level = ((level * pwr_DCB.Steps) / + (pwr_DCB.RangeMax - pwr_DCB.RangeMin))+1; + } + + if (calculated_level EQ pwr_Status.BatteryLevel) + return; + + signal_params.SignalType = PWR_SIGTYPE_BATLEVEL; +#if defined (NEW_FRAME) + signal_params.UserData = (void*)&pwr_Status; +#else + signal_params.SignalValue = 0; + signal_params.UserData = (ULONG)&pwr_Status; +#endif + pwr_Status.BatteryLevel = calculated_level; + + if (pwr_signal_callback NEQ NULL) + (*pwr_signal_callback)(&signal_params); +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_batstatus | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called by the low level driver after + detecting a status change. +*/ + +LOCAL void pwr_batstatus (UBYTE status) +{ +} + +/******************************************************************* + * * + * PART II: Simulation for Windows * + * * + *******************************************************************/ + +/*#if defined (WIN32)*/ +/* + * Dummies for driver calls + */ +LOCAL void BAT_Init (void (*pwr_batlevel)(UBYTE), + void (*pwr_batstatus)(UBYTE)) +{ +} + +/*#endif*/ + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_PWR | +| STATE : code ROUTINE : pwr_PowerOffMobile | ++--------------------------------------------------------------------+ + + PURPOSE : This function is switching off the mobile +*/ + +GLOBAL UBYTE pwr_PowerOffMobile (void) +{ + +/* power off HW is not applicable in simulation */ + + +#if !defined (WIN32) + + /* power-off the board / HW */ + AI_Power(0); + +//#endif /* _TARGET_ */ +#endif /* _TMS470 */ + + return 1; +} + + + diff -r 56e3d8560d69 -r 549b7ac60300 gsm-fw/g23m-glue/gdi/rtc.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/gdi/rtc.c Thu Apr 23 06:42:53 2015 +0000 @@ -0,0 +1,298 @@ +/* ++----------------------------------------------------------------------------- +| Project : GSM-PS +| Modul : DRV_RTC ++----------------------------------------------------------------------------- +| 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 defines the real time clock +| driver interface for the G23 protocol stack. + MC SPR 1725, re-wrote for new driver ++----------------------------------------------------------------------------- +*/ + +#ifndef DRV_RTC_C +#define DRV_RTC_C + +#define ENTITY_CST +/*==== INCLUDES ===================================================*/ + +#include +#include "typedefs.h" +#include "vsi.h" +#include "custom.h" +#include "prim.h" +#include "gsm.h" +#include "tok.h" +#include "cst/cst.h" +#include "gdi.h" +#include "rtc.h" + +#ifdef _SIMULATION_ +#define _WINDOWS +#endif + +#include "rvf/rvf_api.h" + +#ifndef _SIMULATION_ +#include "rtc/rtc_api.h" +#endif +#include "rtcdrv.h" +/*==== EXPORT =====================================================*/ +/*==== VARIABLES ==================================================*/ + + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : rtc_clock_cleared | ++--------------------------------------------------------------------+ + + PURPOSE : returns true if clcok has been reset + + +*/ +BOOL rtc_clock_cleared() +{ +#ifndef _SIMULATION_ + return RTC_RtcReset(); +#endif /* _SIMULATION_ */ +} +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : rtc_set_time_date | ++--------------------------------------------------------------------+ + + PURPOSE : set the time and date + + +*/ +UBYTE rtc_set_time_date(T_RTC_DATE* date, T_RTC_TIME* time ) +{ +#ifndef _SIMULATION_ + T_RTC_DATE_TIME time_and_date; + + time_and_date.second = 0; + time_and_date.minute = time->minute; + if (time->format== RTC_TIME_FORMAT_12HOUR) + time_and_date.hour = (time->hour)% 12; + else + time_and_date.hour = time->hour; + time_and_date.second= time->second; + time_and_date.day = date->day; + time_and_date.month = date->month; + time_and_date.wday = 3; + time_and_date.year = (date->year - 2000) %100; + if (time->format== RTC_TIME_FORMAT_12HOUR) + time_and_date.mode_12_hour = TRUE; + else + time_and_date.mode_12_hour = FALSE; + + time_and_date.PM_flag = time->PM_flag % 2; + + + return RTC_SetDateTime(time_and_date); +#endif /* _SIMULATION_ */ + +} +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : rtc_get_time_date | ++--------------------------------------------------------------------+ + + PURPOSE : get the time and date + + +*/ +UBYTE rtc_get_time_date(T_RTC_DATE* date , T_RTC_TIME* time) +{ +#ifndef _SIMULATION_ + T_RTC_DATE_TIME time_and_date; + + if (RTC_GetDateTime(&time_and_date) != RVF_OK) + DRV_INTERNAL_ERROR; /*error*/ + date->year = 2000+ time_and_date.year; + date->month = time_and_date.month; + date->day = time_and_date.day; + + time->minute = time_and_date.minute; + time->hour = time_and_date.hour; + time->second = time_and_date.second; + if ( time_and_date.mode_12_hour == TRUE) + time->format = RTC_TIME_FORMAT_12HOUR; + else + time->format = RTC_TIME_FORMAT_24HOUR; + time->PM_flag = time_and_date.PM_flag; + return DRV_OK; +#endif /* _SIMULATION_ */ +} + +void empty_callback_func(void* data) +{ + TRACE_EVENT("empty_callback_func"); + +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : rtc_set_alarm | ++--------------------------------------------------------------------+ + + PURPOSE : set the alarm + + +*/ +UBYTE rtc_set_alarm(T_RTC_DATE* date , T_RTC_TIME* time, RtcCallback callback_func ) +{ +#ifndef _SIMULATION_ + T_RTC_DATE_TIME time_and_date; + T_RV_RETURN return_path; + + memset(&return_path, 0, sizeof(T_RV_RETURN)); + + + time_and_date.second = time->second; + time_and_date.minute = time->minute; + if (time->format== RTC_TIME_FORMAT_12HOUR) + time_and_date.hour = (time->hour)% 12; + else + time_and_date.hour = time->hour; + time_and_date.day = date->day; + time_and_date.month = date->month; + time_and_date.wday = 3; + time_and_date.year = (date->year - 2000) %100; + if (time->format== RTC_TIME_FORMAT_12HOUR) + time_and_date.mode_12_hour = TRUE; + else + time_and_date.mode_12_hour = FALSE; + + time_and_date.PM_flag = time->PM_flag % 2; + return_path.addr_id = RVF_INVALID_ADDR_ID; + return_path.callback_func = (RtcCallback)callback_func; + return RTC_SetAlarm(time_and_date, return_path); +#endif /* _SIMULATION_ */ +} +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : rtc_get_alarm | ++--------------------------------------------------------------------+ + + PURPOSE : retrieve alarm setting + + +*/ +UBYTE rtc_get_alarm(T_RTC_DATE* date, T_RTC_TIME* time ) +{ +#ifndef _SIMULATION_ + T_RTC_DATE_TIME time_and_date; + + if (RTC_GetAlarm(&time_and_date) != RVF_OK) + DRV_INTERNAL_ERROR; /*ERROR*/ + date->year = 2000+ time_and_date.year; + date->month = time_and_date.month; + date->day = time_and_date.day; + + time->second = time_and_date.second; + time->minute = time_and_date.minute; + time->hour = time_and_date.hour; + if ( time_and_date.PM_flag == TRUE) + time->format = RTC_TIME_FORMAT_12HOUR; + else + time->format = RTC_TIME_FORMAT_24HOUR; + time->PM_flag = time_and_date.PM_flag; + return DRV_OK; +#endif /* _SIMULATION_ */ +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : rtc_unset_alarm | ++--------------------------------------------------------------------+ + + PURPOSE : unset alarm + + +*/ +UBYTE rtc_unset_alarm() +{ +#ifndef _SIMULATION_ + return RTC_UnsetAlarm(); +#endif /* _SIMULATION_ */ +} +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : rtc_set_time_format | ++--------------------------------------------------------------------+ + + PURPOSE : unset alarm + + +*/ +UBYTE rtc_set_time_format(T_RTC_TIME_FORMAT format) +{ BOOL twelve_hour; + +#ifndef _SIMULATION_ + if (format == RTC_TIME_FORMAT_12HOUR) + twelve_hour = TRUE; + else + twelve_hour = FALSE; + + RTC_Set12HourMode(twelve_hour); +#endif /* _SIMULATION_ */ + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RTC | +| STATE : code ROUTINE : vmd_primitive | ++--------------------------------------------------------------------+ + + PURPOSE : This function get the date and time. + and is backawrd compatible + if year >= 70 then 19year + if year < 70 then 20year +*/ + +GLOBAL UBYTE rtc_read_time ( rtc_time_type *rtc_time ) +{ +#ifndef _SIMULATION_ + T_RTC_DATE_TIME time_and_date; + if ( rtc_time EQ NULL ) + return ( FALSE ); + + + + if (RTC_GetDateTime(&time_and_date) != RVF_OK) + return FALSE; + rtc_time->year = time_and_date.year; + rtc_time->month = time_and_date.month; + rtc_time->day = time_and_date.day; + + rtc_time->minute = time_and_date.minute; + rtc_time->hour = time_and_date.hour; + rtc_time->second = time_and_date.second; + +#endif /* _SIMULATION_ */ + + return ( TRUE ); +} + +#endif /* #ifndef DRV_RTC_C */ diff -r 56e3d8560d69 -r 549b7ac60300 gsm-fw/g23m-glue/gdi/rx.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/g23m-glue/gdi/rx.c Thu Apr 23 06:42:53 2015 +0000 @@ -0,0 +1,330 @@ +/* ++----------------------------------------------------------------------------- +| Project : GSM-PS +| Modul : DRV_RX ++----------------------------------------------------------------------------- +| 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 defines the fieldstrength management +| device driver for the G23 protocol stack. +| +| This driver is used to control all fieldstrength related +| functions. The driver does support multiple devices and +| therefore no open and close functionality is supported. +| The driver can be configured to signal different state +| transitions. This is done by setting an OS signal or +| calling a specified call-back function. ++----------------------------------------------------------------------------- +*/ + +#ifndef DRV_RX_C +#define DRV_RX_C +#endif +#define ENTITY_CST +/*==== INCLUDES ===================================================*/ + +#if defined (NEW_FRAME) + +#include +#include "typedefs.h" +#include "vsi.h" +#include "custom.h" +#include "gsm.h" +#include "prim.h" +#include "gdi.h" +#include "rx.h" + +#else + +#include +#include "stddefs.h" +#include "custom.h" +#include "gsm.h" +#include "prim.h" +#include "vsi.h" +#include "gdi.h" +#include "rx.h" + +#endif +/*==== EXPORT =====================================================*/ +EXTERN USHORT RX_GetValue ( void ); +EXTERN UBYTE RX_GetRxQual ( void ); +EXTERN void RX_Enable (T_VOID_FUNC rx_indication); + +#if defined (NEW_FRAME) +EXTERN USHORT cst_handle; +#endif /* NEW_FRAME */ + +/*==== CONSTANTS ==================================================*/ +#define RX_INDICATION_WITHOUT_TIMER +#if defined (NEW_FRAME) +#define CST_RXTIMER 1 +#endif /* NEW_FRAME */ + +/*==== VARIABLES ==================================================*/ +drv_SignalCB_Type rx_signal_callback = NULL; +rx_DCB_Type rx_DCB; +rx_Status_Type rx_Status; +#if !defined (NEW_FRAME) +T_VSI_THANDLE rx_handle = VSI_ERROR; +#endif /* !NEW_FRAME */ + +/*==== FUNCTIONS ==================================================*/ +#if 0 + #if defined(NEW_FRAME) + #define SYST_TRACE(a) vsi_o_ttrace(0, 0xFFFF,a) + #define SYST 0, 0xffff + #define SYST_TRACE_P(a) vsi_o_ttrace a + #else /* NEW_FRAME */ + #define SYST_TRACE(a) vsi_o_trace("", 0xFFFF,a) + #define SYST "", 0xffff + #define SYST_TRACE_P(a) vsi_o_trace a + #endif /* NEW_FRAME */ + /* + * use it as showed next line... + * SYST_TRACE_P((SYST, "e.g. two parameter: %d %d", p1, p2)); + */ +#else /* 0|1 */ + #define SYST_TRACE(a) + #define SYST_TRACE_P(a) +#endif /* 0|1 */ + + +LOCAL void RX_Indication (void) +{ + if (rx_signal_callback) + { + USHORT new_rx_value; + UBYTE calculated_level; + drv_SignalID_Type signal_params; + + new_rx_value = RX_GetValue (); + rx_Status.gsmLevel = ( UBYTE ) new_rx_value; + + calculated_level = (new_rx_value * rx_DCB.Steps) / 64; + + SYST_TRACE_P ((SYST, "RX_Indication(): rx=%u new, %u old", + calculated_level, rx_Status.actLevel)); + + if (calculated_level NEQ rx_Status.actLevel) + { + signal_params.SignalType = RX_SIGTYPE_RXLEVEL; + #if defined (NEW_FRAME) + signal_params.UserData = (void*)&rx_Status; + #else + signal_params.SignalValue = 0; + signal_params.UserData = (ULONG)&rx_Status; + #endif /* NEW_FRAME */ + rx_Status.actLevel = calculated_level; + rx_Status.rxQuality = RX_GetRxQual (); + + #if !defined (WIN32) + /* + * suppress for windows to avoid disturb of regression tests + */ + (*rx_signal_callback)(&signal_params); + #endif /* !WIN32 */ + } + } +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RX | +| STATE : code ROUTINE : rx_Init | ++--------------------------------------------------------------------+ + + PURPOSE : The function initializes the driverīs internal data. + The function returns DRV_OK in case of a successful + completition. The function returns DRV_INITIALIZED if + the driver has already been initialized and is ready to + be used or is already in use. In case of an initialization + failure, which means the that the driver cannot be used, + the function returns DRV_INITFAILURE. + +*/ + +GLOBAL UBYTE rx_Init (drv_SignalCB_Type in_SignalCBPtr) +{ + rx_signal_callback = in_SignalCBPtr; /* store call-back function */ + rx_DCB.Steps = 4; /* 4 Steps */ + rx_Status.actLevel = 255; + rx_Status.gsmLevel = 255; + +#if defined (RX_INDICATION_WITHOUT_TIMER) + if (in_SignalCBPtr) + { + SYST_TRACE_P ((SYST, "rx_Init(): enable RX_Indication (%p)", in_SignalCBPtr)); + RX_Enable (RX_Indication); + } + else + { + SYST_TRACE ("rx_Init() without in_SignalCBPtr"); + } +#else /* RX_INDICATION_WITHOUT_TIMER */ + #if !defined (NEW_FRAME) + rx_handle = vsi_t_open (VSI_CALLER "RX"); + + if (rx_handle < VSI_OK) + return DRV_INITFAILURE; + + vsi_t_start (VSI_CALLER rx_handle, T_RX_VALUE); + #else /* !NEW_FRAME */ + vsi_t_start (VSI_CALLER CST_RXTIMER, T_RX_VALUE); + #endif /* !NEW_FRAME */ +#endif /* RX_INDICATION_WITHOUT_TIMER */ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RX | +| STATE : code ROUTINE : rx_Exit | ++--------------------------------------------------------------------+ + + PURPOSE : The function is used to indicate RX that the driver + and its functionality isnīt needed anymore. + +*/ + +GLOBAL void rx_Exit (void) +{ + rx_signal_callback = NULL; + +#if !defined (RX_INDICATION_WITHOUT_TIMER) + #if !defined (NEW_FRAME) + vsi_t_close (VSI_CALLER rx_handle); + rx_handle = VSI_ERROR; + #else /* !NEW_FRAME */ + vsi_t_stop (VSI_CALLER CST_RXTIME); + #endif /* !NEW_FRAME */ +#endif /* RX_INDICATION_WITHOUT_TIMER */ +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RX | +| STATE : code ROUTINE : rx_SetConfig | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to configure the driver. + If any value of this configuration is out of range or + invalid in combination with any other value of the + configuration, the function returns DRV_INVALID_PARAMS. + Call the rx_GetConfig() function to retrieve the drivers + configuration. + +*/ + +GLOBAL UBYTE rx_SetConfig (rx_DCB_Type * in_DCBPtr) +{ + memcpy (&rx_DCB, in_DCBPtr, sizeof (rx_DCB_Type)); + rx_Status.actLevel = 255; + rx_Status.gsmLevel = 255; + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RX | +| STATE : code ROUTINE : rx_GetConfig | ++--------------------------------------------------------------------+ + + PURPOSE : The function is used to retrieve the configuration of + the driver. The configuration is returned in the driver + control block to which the pointer out_DCBPtr points. + If the driver is not configured, the function returns + DRV_NOTCONFIGURED. + Call the rx_SetConfig() function to configure the driver. + +*/ + +GLOBAL UBYTE rx_GetConfig (rx_DCB_Type * out_DCBPtr) +{ + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RX | +| STATE : code ROUTINE : rx_GetStatus | ++--------------------------------------------------------------------+ + + PURPOSE : This function is used to retrieve the status of the driver. + In case of a successful completion the driver returns + DRV_OK and the current status of the driver in the buffer + out_StatusPtr points to. + In case the driver is not configured yet, it returns + DRV_NOTCONFIGURED. In this case the contents of the + buffer out_StatusPtr is invalid. + In case out_StatusPtr equals NULL the driver returns + DRV_INVALID_PARAMS. + +*/ + +GLOBAL UBYTE rx_GetStatus (rx_Status_Type * out_StatusPtr) +{ + USHORT new_rx_value = RX_GetValue (); + + rx_Status.gsmLevel = ( UBYTE ) new_rx_value; + rx_Status.actLevel = (new_rx_value * rx_DCB.Steps) / 64; + rx_Status.rxQuality = RX_GetRxQual (); + + out_StatusPtr->actLevel = rx_Status.actLevel; + out_StatusPtr->gsmLevel = rx_Status.gsmLevel; + out_StatusPtr->rxQuality = rx_Status.rxQuality; + + return DRV_OK; +} + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-PS (6103) MODULE : DRV_RX | +| STATE : code ROUTINE : rx_timeout | ++--------------------------------------------------------------------+ + + PURPOSE : This function calculates a new rxlevel after timeout. + If a change has occured, the new level is forwarded to + MMI using the callback function. The timer is started + again. + +*/ +#if defined (NEW_FRAME) +GLOBAL void rx_timeout (USHORT index) +#else +GLOBAL void rx_timeout (T_VSI_THANDLE handle) +#endif +{ +#if !defined (RX_INDICATION_WITHOUT_TIMER) + #if defined (NEW_FRAME) + if (index EQ CST_RXTIMER) + #else + if (handle EQ rx_handle) + #endif + { + /* + * only if it is the fieldstrength timer + */ + SYST_TRACE ("rx_timeout()"); + + RX_Indication (); + + #if defined (NEW_FRAME) + vsi_t_start (VSI_CALLER CST_RXTIMER, T_RX_VALUE); + #else + vsi_t_start (VSI_CALLER rx_handle, T_RX_VALUE); + #endif + } +#endif /* !RX_INDICATION_WITHOUT_TIMER */ +} +