| /* |
| * All Rights Reserved |
| * |
| * MARVELL CONFIDENTIAL |
| * Copyright 2012 Marvell International Ltd All Rights Reserved. |
| * The source code contained or described herein and all documents related to |
| * the source code ("Material") are owned by Marvell International Ltd or its |
| * suppliers or licensors. Title to the Material remains with Marvell International Ltd |
| * or its suppliers and licensors. The Material contains trade secrets and |
| * proprietary and confidential information of Marvell or its suppliers and |
| * licensors. The Material is protected by worldwide copyright and trade secret |
| * laws and treaty provisions. No part of the Material may be used, copied, |
| * reproduced, modified, published, uploaded, posted, transmitted, distributed, |
| * or disclosed in any way without Marvell's prior express written permission. |
| * |
| * No license under any patent, copyright, trade secret or other intellectual |
| * property right is granted to or conferred upon you by disclosure or delivery |
| * of the Materials, either expressly, by implication, inducement, estoppel or |
| * otherwise. Any license under such intellectual property rights must be |
| * express and approved by Marvell in writing. |
| * |
| */ |
| |
| #ifndef __H_ACM_APH__ |
| #define __H_ACM_APH__ |
| |
| #include "acm_debug.h" |
| #include "acm_ach.h" |
| #include "acm_api.h" |
| #include "audio_protocol.h" |
| #include "audio_profile.h" |
| |
| #define MAX_STRING_LEN 60 |
| #define MAX_VOLUME_INDEX 100 |
| #define INVALID_CTL_UNIT_ID 0 |
| #define INVALID_PATH_ID 0xFF |
| #define INVALID_ORDER_INDEX 0xFF |
| |
| #define XML_NAME_LEN 128 |
| #define DIGITAL_GAIN_OFFSET 37 |
| #define GENERATE_XML_NAME(BUF, SIZE, PREFIX, APPENDIX) \ |
| do{\ |
| (BUF) = (char *)malloc((SIZE)); \ |
| if ((BUF)) {\ |
| memset((BUF), 0, (SIZE)); \ |
| snprintf((BUF), (SIZE), "%s%s.xml", (PREFIX), (APPENDIX));\ |
| } \ |
| }while(0) |
| |
| #define PATHSTATUS_MAX 2048 |
| //-------------------------------------------------------------- |
| //-------- Basic Elements Definition |
| //-------------------------------------------------------------- |
| typedef enum { |
| APH_PATH_ID_HIFIPLAYTOEARPHONE = 0, |
| APH_PATH_ID_HIFIPLAYTOSPKR, |
| APH_PATH_ID_HIFIPLAYTOHP, |
| APH_PATH_ID_HIFIRECORDFROMMIC1, |
| APH_PATH_ID_HIFIRECORDFROMHSMIC, |
| APH_PATH_ID_VOICEPLAYTOEARPHONE, |
| APH_PATH_ID_VOICEPLAYTOSPKR, |
| APH_PATH_ID_VOICEPLAYTOHP, |
| APH_PATH_ID_VOICERECORDFROMMIC1, |
| APH_PATH_ID_VOICERECORDFROMHSMIC, |
| |
| APH_PATH_ID_CNT |
| } APH_PATH_ID; |
| |
| #define APH_PATH_OUT_CNT 6 |
| #define APH_PATH_IN_CNT 4 |
| |
| typedef enum { |
| APH_GAIN_ID_NB = 0, |
| APH_GAIN_ID_WB, |
| APH_GAIN_ID_NB_EXTRA, |
| APH_GAIN_ID_WB_EXTRA, |
| |
| APH_GAIN_ID_CNT |
| } APH_GAIN_ID; |
| |
| typedef enum { |
| ELBA, |
| USTICA, |
| DELAY, |
| NAU8810, |
| ALC5616, |
| |
| AUDIO_COMPONENT_CNT |
| } APH_AudioComponent; |
| |
| |
| typedef enum { |
| ENABLE, |
| DISABLE, |
| MUTE, |
| SETVOLUME, |
| SWITCH, |
| |
| PATH_OPERATION_CNT |
| } APH_PathOperation; |
| |
| /* Force type is added for GELATO, as some registers are used as trigger/update signal, will repeatedly write a same value. For bit value with Force field type, just write to codec ignore ref_count/bind-writing/cache check features */ |
| typedef enum { |
| REG_FIELD_TYPE_INVALID = 0, |
| REG_FIELD_TYPE_NORMAL = 1, |
| REG_FIELD_TYPE_GAIN = 2, |
| REG_FIELD_TYPE_COEFF = 4, |
| REG_FIELD_TYPE_FORCE = 8 |
| } APH_RegisterFieldType; |
| |
| typedef enum { |
| REG_MISC_NONE, |
| REG_MISC_MIC1, |
| REG_MISC_MIC2, |
| REG_MISC_DUAL_MIC, |
| REG_MISC_SLAVE, |
| REG_MISC_MASTER, |
| REG_MISC_NB_RATE, |
| REG_MISC_WB_RATE, |
| REG_MISC_VOIP_RATE, |
| REG_MISC_DEFAULT_RATE, |
| REG_MISC_FORCE_DELAY |
| } APH_RegisterMisc; |
| |
| typedef enum { |
| PATH_DIRECTION_IN, |
| PATH_DIRECTION_OUT, |
| } APH_PathDirection; |
| |
| typedef enum { |
| HIFI_PATH, |
| FM_PATH, |
| VOICE_PATH, |
| UNKNOW_PATH, |
| }APH_PathType; |
| |
| |
| //-------------------------------------------------------------- |
| //-------- ACM_APH Related Data Structures |
| //-------------------------------------------------------------- |
| typedef struct { |
| APH_AudioComponent Component; |
| unsigned char Address; |
| unsigned short Value; |
| } ACMAPH_Register; |
| |
| typedef struct { |
| APH_PATH_ID PathID; |
| ACMAPH_Register *RegisterList; |
| unsigned char RegisterNum; |
| } ACMAPH_Component; |
| |
| typedef struct { |
| int PathID; |
| char PathName[32]; |
| } ACMAPH_AudioPathID; |
| |
| typedef struct { |
| unsigned char Volume; |
| APH_AudioComponent Component; |
| unsigned char Address; |
| unsigned short Value; |
| } ACMAPH_VolumeRegister; |
| |
| typedef struct { |
| APH_PATH_ID PathID; |
| ACMAPH_VolumeRegister *RegisterList; |
| unsigned char RegisterNum; |
| } ACMAPH_VolumeComponent; |
| |
| |
| typedef struct { |
| APH_GAIN_ID id; |
| unsigned char volume; |
| signed char gain; |
| } ACMAPH_MSAGain; |
| |
| typedef struct { |
| APH_PATH_ID PathID; |
| ACMAPH_MSAGain *GainList; |
| unsigned char GainNum; |
| } ACMAPH_MSAComponent; |
| |
| |
| //-------------------------------------------------------------- |
| //-------- Path Configuration Related Data Structures |
| //-------------------------------------------------------------- |
| typedef struct tag_APH_ControlUnitConfiguration { |
| union { |
| struct { |
| unsigned char reg_index; |
| unsigned char reg_mask; |
| unsigned char reg_shift; |
| unsigned char reg_type; |
| unsigned char reg_misc; |
| unsigned short length; |
| unsigned char *reg_value; |
| } i2c; |
| struct { |
| unsigned char gpio_port; |
| unsigned char gpio_value; |
| } gpio; |
| struct { |
| unsigned char hci_ocf; |
| unsigned char hci_ogf; |
| unsigned short length; |
| unsigned char *hci_parameters; |
| } hci; |
| struct { |
| unsigned int delay_value; |
| unsigned char delay_misc; |
| } delay; |
| } ctl_unit; |
| unsigned short control_unit_id; |
| struct tag_APH_ControlUnitConfiguration *next; |
| } APH_ControlUnitConfiguration; |
| |
| |
| //-------------------------------------------------------------- |
| //-------- APH Related Data Structures |
| //-------------------------------------------------------------- |
| typedef struct { |
| APH_AudioComponent component_id; |
| ACH_ComponentHandler *component_handler; |
| } APH_ACHComponent; |
| |
| typedef struct { |
| unsigned short enabled; |
| unsigned int value; |
| unsigned char mute; |
| } APH_PathStatus; |
| |
| typedef enum |
| { |
| AUDIOHAL_SPK_MUTE = 0, |
| AUDIOHAL_SPK_VOL_1, |
| AUDIOHAL_SPK_VOL_2, |
| AUDIOHAL_SPK_VOL_3, |
| AUDIOHAL_SPK_VOL_4, |
| AUDIOHAL_SPK_VOL_5, |
| AUDIOHAL_SPK_VOL_6, |
| AUDIOHAL_SPK_VOL_7, |
| AUDIOHAL_SPK_VOL_8, |
| AUDIOHAL_SPK_VOL_9, |
| AUDIOHAL_SPK_VOL_10, |
| AUDIOHAL_SPK_VOL_QTY //11 |
| } AUDIOHAL_SPK_LEVEL_T; |
| |
| typedef enum { |
| APH_CODEC_ID_NONE=0, |
| APH_CODEC_ID_PM805, |
| APH_CODEC_ID_PM812, |
| APH_CODEC_ID_NAU8810, |
| APH_CODEC_ID_ALC5616, |
| |
| APH_CODEC_CNT |
| } APH_CODEC_ID; |
| |
| typedef struct |
| { |
| APH_AudioComponent Component_1; |
| unsigned short RegAddr_1; |
| unsigned short RegVal_1; |
| |
| APH_AudioComponent Component_2; |
| unsigned short RegAddr_2; |
| unsigned short RegVal_2; |
| |
| APH_AudioComponent Component_3; |
| unsigned short RegAddr_3; |
| unsigned short RegVal_3; |
| |
| APH_AudioComponent Component_4; |
| unsigned short RegAddr_4; |
| unsigned short RegVal_4; |
| } ACMCodec_GainInT; |
| |
| typedef struct |
| { |
| APH_AudioComponent Component_1; |
| unsigned short RegAddr_1; |
| unsigned short RegVal_1; |
| |
| APH_AudioComponent Component_2; |
| unsigned short RegAddr_2; |
| unsigned short RegVal_2; |
| |
| APH_AudioComponent Component_3; |
| unsigned short RegAddr_3; |
| unsigned short RegVal_3; |
| |
| APH_AudioComponent Component_4; |
| unsigned short RegAddr_4; |
| unsigned short RegVal_4; |
| } ACMCodec_GainOutT; |
| |
| typedef struct |
| { |
| AUDIO_PROFILE_ID Profile_id; |
| unsigned short CodecControl; |
| ACMCodec_GainInT Tx_CodecGain; //TX has the same gain for every volume |
| short Tx_DSPGain; //TX has the same gain for every volume, High 8bits: WB gain, Low 8bits: NB gain |
| ACMCodec_GainOutT Rx_CodecGain[AUDIOHAL_SPK_VOL_QTY]; |
| short Rx_DSPGain[AUDIOHAL_SPK_VOL_QTY]; //High 8bits: WB gain, Low 8bits: NB gain |
| short Rx_DSPSideToneGain; //High 8bits: WB gain, Low 8bits: NB gain |
| } ACMCodec_GainT; |
| |
| //-------------------------------------------------------------- |
| //-------- External APH APIs |
| //-------------------------------------------------------------- |
| const ACMAPH_AudioPathID *ACM_GetPathConfigTable(); |
| |
| void ACM_Init_Property(void); |
| void ACM_APHInit(void); |
| void ACM_APHDeInit(void); |
| char * ACM_GetPathName(int PathID); |
| ACM_ReturnCode APHAudioPathEnable(const char *path, unsigned int value); |
| ACM_ReturnCode APHAudioPathDisable(const char *path); |
| ACM_ReturnCode APHAudioPathCheck (const char * path_Rx, const char * path_Tx) ; |
| void APHDisableAllPath(void); |
| ACM_ReturnCode APHAudioPathSwitch (const char *path_Rx, const char *path_Tx, unsigned int value); |
| ACM_ReturnCode APHAudioPathMute(const char *path, unsigned int value); |
| ACM_ReturnCode APHAudioPathVolumeSet(const char *path, unsigned int value); |
| ACM_ReturnCode ACM_ReloadCalibrationData(void); |
| ACM_ReturnCode APHReloadNvm(void); |
| ACM_ReturnCode APHAudioPathCheckPathId (int path_id_Rx, int path_id_Tx); |
| ACM_ReturnCode ACM_GetEnabledPathId(int *path_id_Rx, int *path_id_Tx, int *volume_Rx, int *mute_Tx); |
| ACM_ReturnCode APHGetMSAGain(const char *out_path, const char *path, unsigned char *volume, unsigned short id, signed short *gain, signed short *sidetone_gain); |
| unsigned int ACM_GetEnabledPathVolume(void); |
| ACM_ReturnCode ACM_GetPathStatus(char *buff, unsigned int maxsize); |
| ACM_ReturnCode ACM_GetPathDirection(const char *path, unsigned char *path_direction); |
| |
| #endif |