⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 am_hw_string_primitive.cc

📁 Motorola synergy audio component
💻 CC
字号:
/* (c) Copyright Motorola 1997-2006 All rights reserved.   Motorola Confidential Proprietary   Contains confidential proprietary information of Motorola, Inc.   Reverse engineering is prohibited.   The copyright notice does not imply publication.   DESCRIPTION:      Holds the string primitive source code *************** REVISION HISTORY *********************************************   Date       Author      Reference   ========   ========    ==========================   2005-12-13 w16355      CR - LIBhh59411              AUL stereo DAC can take up to 160ms to fully power up.   02-04-07   boz008      LIBbb41380              - Log data upon failure when sending primitive to the MDI Queue.      02-01-09   ppoppert    LIBbb15301              Update MDI to handle different size Audio queues based on the               patriot.              - changed the data_word_size constant to a variable because                the size changes based on the dsp version.   00-12-21   mtaraba     CSGce82934              main_comp_hardware.h within engine_audio vob should be removed   00-08-09   mtaraba     CR - CSGce55882              Eliminate file gsm.h from audio manager   00-05-15   cfarrel     CR - CSGce58264              Update Audio Manager to call l1_modem_api queue functions instead              of HAPI_mdi_queue functions (for CDMA only)   00-04-05   hchuang     CR - CSGce53807              Update Audio Manager to use HAPI MDI functions and header files			  - replace all api #define in l1_modem_api_queue.h with one in			    hapi_mdi_queue.h              - replace l1_modem_api functions with hapi mdi functions   99-09-01   mkloza      CSGce34326              GRiEF   99-91-25   blamers     CR - CSGce27265              AM-DSP Queue Loses Commands              - Fixed the flush_buffer method   97-11-20   gdrumma     PR - CSGce14786              Fix word alignment prob in AM/DSP              - Updated flush buffer to convert UINT16 length into UINT8 length   97-09-09   gdrumma     PR - CSGce12941              Clean up of Modulus2 Audio updates              - Removed global string buffers, as they are now part of                 AM_HW_Primitive_Builder.   97-08-14   gdrumma     PR - CSGce11316              Audio Manager Support for Modulus2              - Added 2 new parameters to constructor of AM_HW_String_Primitive,                 'string_type' and 'buffer'.  String_type is used to set new member                'queue_type' to the proper type (DATA or COMMANDS), and the pointer                to a buffer specifies what buffer to use for messages.              - Defined the 2 buffers used at file scope here.              - Updated 'send()' to choose which API queue to write to based on the                member that was set during the construction of the object.              - Added 'stamp_time' function to maintain the strings counter.              - Removed set_confirm() (DSP sends replies when needed)              - Updated to coding standard.   97-03-19   gdrumma     PR - CSGce09178              Add Warm Plug Codec support              - Added method 'set_disable_codec' which will set the bit in                the status register of the HW string primitive to the BOOL                value supplied with the call.*//************** INCLUDES ******************************************************/#include <string.h>#include <ENGINE_AUDIO/audio_conditional_compile_def.h>#include <ENGINE_AUDIO/am_util_bits.h>#include <ENGINE_AUDIO/am_hw_string_primitive.h>#include <ENGINE_HAPI/hapi_mdi_queue_map.h>#include <ENGINE_HAPI/hapi_mdi_queue.h>#include <audio/am_globals.h>#include <audio/AM_SendMessage.h>#include <ENGINE_AUDIO/aud_prim_ids.h>#include <audio/AM_HW_String_Primitive.H>#if(AUDIO_RAINBOW == TRUE)#include <audio/AM_Tone_Sequence_Handler.H>#include <audio/AM_HW_Primitive_Builder.H>#endif/************** GLOBAL VARIABLES **********************************************///UINT16 index = 0;//UINT16 current_index = 0;//UINT16 temp_log_buffer[250];/************** LOCAL CONSTANTS ***********************************************//************** LOCAL STRUCTURES, ENUMS, AND TYPEDEFS *************************//************** LOCAL FUNCTION PROTOTYPES *************************************//************** LOCAL MACROS **************************************************//************** LOCAL VARIABLES ***********************************************/UINT8 AM_HW_String_Primitive :: timestamp = 0;#if (AUDIO_RAINBOW == TRUE)extern BOOL dsp_awake;#endif/************** FUNCTION DEFINITIONS ******************************************//* DESCRIPTION: *     The constructor for string primitive. *  INPUTS: *     AM_HW_STRING_TYPE string_type - determines what type of queue to use. *     UINT8 *buffer - pointer to buffer to use in the AM. *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     If a new queue is to be implemented, a new global buffer would need to be created. */  AM_HW_String_Primitive :: AM_HW_String_Primitive (AM_HW_STRING_TYPE string_type, UINT8 *buffer){    if (string_type == AM_HW_CMD_STRING_PRIMITIVE)    {        queue_type = (MDI_QUEUE_SELECT) MCU_DSP_AUDIO_COMMAND;        queue_size = (UINT8) MCU_DSP_AUDIO_COMMAND_WORD_SIZE;    }        else if (string_type == AM_HW_DATA_STRING_PRIMITIVE)    {        queue_type = (MDI_QUEUE_SELECT) MCU_DSP_AUDIO_DATA;#if (AUDIO_RAINBOW == TRUE)        queue_size = (UINT8) MCU_DSP_AUDIO_DATA_WORD_SIZE;#else        queue_size = (UINT8) hapi_mcu_dsp_audio_data_word_size;#endif    }         am_hw_string_primitive_buffer = buffer;    am_hw_string_primitive_buffer_pos_ptr = am_hw_string_primitive_buffer;}/* DESCRIPTION: *     Function to send the contents of local buffer to proper MDI Queue *  INPUTS: *     None. *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     Based on the member queue_type, the send routes the buffer to the respective queue. *     The TRUE parameter on HAPI_MDI_QUEUE_write means to generate an interrupt. */  voidAM_HW_String_Primitive :: send (){    /* Since the  AM hw buffers for DSP messages are in UINT8S (because some fields are        byte aligned) we subtract the pos_ptr from the start pointer and divide by       the sizeof a word (2).  This essentially converts the length of the buffer in       bytes into the length in words to be used with the l1_modem write function. */    UINT16 length = (am_hw_string_primitive_buffer_pos_ptr - am_hw_string_primitive_buffer)         / sizeof(UINT16);    if ( length > 0)    {        BOOL success =  HAPI_MDI_QUEUE_write (queue_type, (UINT16 *)am_hw_string_primitive_buffer, length, TRUE);#if (MAKE_NEPTUNE_CHIPSET == FALSE)	/*Datalog the MDI data */	am_send_log_data(AUD_MDI_Q_WRITE, (char *)am_hw_string_primitive_buffer, length * 2);#endif /* MAKE_NEPTUNE_CHIPSET */    #if (MAKE_NEPTUNE_CHIPSET == TRUE)        if (!success)        {            am_send_log_data(AUD_MDI_Q_WRITE_FAIL, (char *)am_hw_string_primitive_buffer, length * 2);        }        else        {            am_send_log_data(AUD_MDI_Q_WRITE, (char *)am_hw_string_primitive_buffer, length * 2);        }#endif /* MAKE_NEPTUNE_CHIPSET */         am_hw_string_primitive_buffer_pos_ptr =  am_hw_string_primitive_buffer;     }   }/* DESCRIPTION: *     Operator to reserve memory in string buffer *  INPUTS: *     UINT8 length - length requested in the buffer in UINT16S!! *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     Use '<<' to ensure ENTIRE message can fit in buffer! *//* operator to reserve memory in buffer */AM_HW_String_Primitive&AM_HW_String_Primitive :: operator << ( UINT8 length){    flush_buffer ( length );    return *this;   }/* DESCRIPTION: *     Operator to append a UINT8 to string primitive *  INPUTS: *     UINT8 data - Byte to be added to buffer. *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     Use '<<' to ensure ENTIRE message can fit in buffer! */AM_HW_String_Primitive&AM_HW_String_Primitive :: operator + ( UINT8 data){    *am_hw_string_primitive_buffer_pos_ptr++ = data;    return *this;   }/* DESCRIPTION: *     Operator to append a UINT16 to string primitive *  INPUTS: *     UINT16 data - Word to be added to buffer. *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     Use '<<' to ensure ENTIRE message can fit in buffer! */AM_HW_String_Primitive&AM_HW_String_Primitive :: operator + (UINT16 data){        *(UINT16 *) am_hw_string_primitive_buffer_pos_ptr = data;    am_hw_string_primitive_buffer_pos_ptr += sizeof (UINT16);      return *this;   }/* DESCRIPTION: *     Operator to append a INT16 to string primitive *  INPUTS: *     INT16 data - Word to be added to buffer. *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     Use '<<' to ensure ENTIRE message can fit in buffer! */AM_HW_String_Primitive&AM_HW_String_Primitive :: operator + (INT16 data){        *(INT16 *) am_hw_string_primitive_buffer_pos_ptr = data;    am_hw_string_primitive_buffer_pos_ptr += sizeof (INT16);      return *this;   }/* DESCRIPTION: *     Operator to append an AM_HW_TONE_DEF to string primitive *  INPUTS: *     AM_HW_TONE_DEF *data_ptr - tone definition structure. *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     Use '<<' to ensure ENTIRE message can fit in buffer! */AM_HW_String_Primitive&AM_HW_String_Primitive :: operator + (AM_HW_TONE_DEF  *data_ptr){    memcpy (am_hw_string_primitive_buffer_pos_ptr, data_ptr, sizeof (AM_HW_TONE_DEF));    am_hw_string_primitive_buffer_pos_ptr +=  sizeof (AM_HW_TONE_DEF);    return *this;   }/* DESCRIPTION: *     This function will determine if desired data can fit (specified by 'length') can fit *     in the string buffer.  If not, a 'send()' function is exectued freeing up the buffer. *  INPUTS: *     UINT8 - length in UINT16S!!! *  OUTPUTS: *     None. *  IMPORTANT NOTES: *     None. */voidAM_HW_String_Primitive :: flush_buffer (UINT8 length){    if ((( am_hw_string_primitive_buffer_pos_ptr - am_hw_string_primitive_buffer) +          (length * sizeof(UINT16))) >= (queue_size * sizeof(UINT16)))    {        send ();            }}/* DESCRIPTION: *     This function maintains the time stamp counter (first used in the whitecap platform)  It *     currently is a modulo 256 counter (0 - 255).  Each message being sent to the API will have *     a time stamp associated with it. *  INPUTS: *     None. *  OUTPUTS: *     Return value is a UINT8, the timestamp value (0-255) *  IMPORTANT NOTES: *     - Each instance of this object will maintain it's own timestamps.  (Commands and Data) */UINT8 AM_HW_String_Primitive :: stamp_time (void){    /* set local variable to current timestamp value */    UINT8 current_time = timestamp;        /* update the timestamp value for next message */    timestamp = ((timestamp + 1) % AM_HW_STRING_PRIMITIVE_TIMESTAMP_MAX);    /* return value of time */    return (current_time);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -