Home | History | Annotate | Download | only in linux
      1 /* include/linux/a1026.h - a1026 voice processor driver
      2  *
      3  * Copyright (C) 2009 HTC Corporation.
      4  *
      5  * This software is licensed under the terms of the GNU General Public
      6  * License version 2, as published by the Free Software Foundation, and
      7  * may be copied, distributed, and modified under those terms.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU General Public License for more details.
     13  *
     14  */
     15 
     16 #ifndef __LINUX_A1026_H
     17 #define __LINUX_A1026_H
     18 
     19 #include <linux/ioctl.h>
     20 
     21 #define A1026_MAX_FW_SIZE	(32*1024)
     22 struct a1026img {
     23 	unsigned char *buf;
     24 	unsigned img_size;
     25 };
     26 
     27 enum A1026_PathID {
     28 	A1026_PATH_SUSPEND,
     29 	A1026_PATH_INCALL_RECEIVER,
     30 	A1026_PATH_INCALL_HEADSET,
     31 	A1026_PATH_INCALL_SPEAKER,
     32 	A1026_PATH_INCALL_BT,
     33 	A1026_PATH_VR_NO_NS_RECEIVER,
     34 	A1026_PATH_VR_NO_NS_HEADSET,
     35 	A1026_PATH_VR_NO_NS_SPEAKER,
     36 	A1026_PATH_VR_NO_NS_BT,
     37 	A1026_PATH_VR_NS_RECEIVER,
     38 	A1026_PATH_VR_NS_HEADSET,
     39 	A1026_PATH_VR_NS_SPEAKER,
     40 	A1026_PATH_VR_NS_BT,
     41 	A1026_PATH_RECORD_RECEIVER,
     42 	A1026_PATH_RECORD_HEADSET,
     43 	A1026_PATH_RECORD_SPEAKER,
     44 	A1026_PATH_RECORD_BT,
     45 	A1026_PATH_CAMCORDER,
     46 	A1026_PATH_INCALL_TTY
     47 };
     48 
     49 /* noise suppression states */
     50 enum A1026_NS_states {
     51 	A1026_NS_STATE_AUTO,	/* leave mode as selected by driver  */
     52 	A1026_NS_STATE_OFF,	/* disable noise suppression */
     53 	A1026_NS_STATE_CT,	/* force close talk mode */
     54 	A1026_NS_STATE_FT,	/* force far talk mode */
     55 	A1026_NS_NUM_STATES
     56 };
     57 
     58 /* indicates if a1026_set_config() performs a full configuration or only
     59  * a voice processing algorithm configuration */
     60 /* IOCTLs for Audience A1026 */
     61 #define A1026_IOCTL_MAGIC 'u'
     62 
     63 #define A1026_BOOTUP_INIT  _IOW(A1026_IOCTL_MAGIC, 0x01, struct a1026img *)
     64 #define A1026_SET_CONFIG   _IOW(A1026_IOCTL_MAGIC, 0x02, enum A1026_PathID)
     65 #define A1026_SET_NS_STATE _IOW(A1026_IOCTL_MAGIC, 0x03, enum A1026_NS_states)
     66 
     67 /* For Diag */
     68 #define A1026_SET_MIC_ONOFF	_IOW(A1026_IOCTL_MAGIC, 0x50, unsigned)
     69 #define A1026_SET_MICSEL_ONOFF	_IOW(A1026_IOCTL_MAGIC, 0x51, unsigned)
     70 #define A1026_READ_DATA		_IOR(A1026_IOCTL_MAGIC, 0x52, unsigned)
     71 #define A1026_WRITE_MSG		_IOW(A1026_IOCTL_MAGIC, 0x53, unsigned)
     72 #define A1026_SYNC_CMD		_IO(A1026_IOCTL_MAGIC, 0x54)
     73 #define A1026_SET_CMD_FILE	_IOW(A1026_IOCTL_MAGIC, 0x55, unsigned)
     74 
     75 #ifdef __KERNEL__
     76 
     77 /* A1026 Command codes */
     78 #define CtrlMode_LAL		0x0001 /* Level Active Low  */
     79 #define CtrlMode_LAH		0x0002 /* Level Active High */
     80 #define CtrlMode_FE		0x0003 /* Falling Edge */
     81 #define CtrlMode_RE		0x0004 /* Rising  Edge */
     82 #define A100_msg_Sync		0x80000000
     83 #define A100_msg_Sync_Ack	0x80000000
     84 
     85 #define A100_msg_Reset		0x8002
     86 #define RESET_IMMEDIATE		0x0000
     87 #define RESET_DELAYED		0x0001
     88 
     89 #define A100_msg_BootloadInitiate	0x8003
     90 #define A100_msg_GetDeviceParm		0x800B
     91 #define A100_msg_SetDeviceParmID	0x800C
     92 #define A100_msg_SetDeviceParm		0x800D
     93 
     94 /* Get/Set PCM Device Parameter ID List */
     95 /* PCM-0 */
     96 #define PCM0WordLength		0x0100
     97 #define PCM0DelFromFsTx		0x0101
     98 #define PCM0DelFromFsRx		0x0102
     99 #define PCM0LatchEdge		0x0103
    100 #define PCM0Endianness		0x0105
    101 #define PCM0TristateEnable	0x0107
    102 
    103 /* PCM-1 */
    104 #define PCM1WordLength		0x0200
    105 #define PCM1DelFromFsTx		0x0201
    106 #define PCM1DelFromFsRx		0x0202
    107 #define PCM1LatchEdge		0x0203
    108 #define PCM1Endianness		0x0205
    109 #define PCM1TristateEnable	0x0207
    110 
    111 /* Possible setting values for PCM I/F */
    112 #define PCMWordLength_16bit	0x10 /* Default */
    113 #define PCMWordLength_24bit	0x18
    114 #define PCMWordLength_32bit	0x20
    115 #define PCMLatchEdge_Tx_F_Rx_R	0x00 /* Tx/Rx on falling/rising edge */
    116 #define PCMLatchEdge_Tx_R_Rx_F	0x03 /* Tx/Rx on falling/rising edge */
    117 #define PCMEndianness_Little	0x00
    118 #define PCMEndianness_Big	0x01 /* Default */
    119 #define PCMTristate_Disable	0x00 /* Default */
    120 #define PCMTristate_Enable	0x01
    121 
    122 /* Get/Set ADC Device Parameter ID List */
    123 /* ADC-0 */
    124 #define ADC0Gain	0x0300
    125 #define ADC0Rate	0x0301
    126 #define ADC0CutoffFreq	0x0302
    127 
    128 /* ADC-1 */
    129 #define ADC1Gain	0x0400
    130 #define ADC1Rate	0x0401
    131 #define ADC1CutoffFreq	0x0402
    132 
    133 /* Possible setting values for ADC I/F */
    134 #define ADC_Gain_0db			0x00
    135 #define ADC_Gain_6db			0x01
    136 #define ADC_Gain_12db			0x02
    137 #define ADC_Gain_18db			0x03
    138 #define ADC_Gain_24db			0x04 /* Default */
    139 #define ADC_Gain_30db			0x05
    140 #define ADC_Rate_8kHz			0x00 /* Default */
    141 #define ADC_Rate_16kHz			0x01
    142 #define ADC_CutoffFreq_NO_DC_Filter	0x00
    143 #define ADC_CutoffFreq_59p68Hz		0x01 /* Default */
    144 #define ADC_CutoffFreq_7p46Hz		0x02
    145 #define ADC_CutoffFreq_3p73Hz		0x03
    146 
    147 /* Set Power State */
    148 #define A100_msg_Sleep		0x80100001
    149 
    150 /* Get/Set Algorithm Parameter command codes list */
    151 #define A100_msg_GetAlgorithmParm	0x8016
    152 #define A100_msg_SetAlgorithmParmID	0x8017
    153 #define A100_msg_SetAlgorithmParm	0x8018
    154 
    155 /* Get/Set Algorithm Parameter ID List (Transmit Feature) */
    156 #define AIS_Global_Supression_Level	0x0000
    157 #define Mic_Config			0x0002
    158 #define AEC_Mode			0x0003
    159 #define AEC_CNG				0x0023
    160 #define Output_AGC			0x0004
    161 #define Output_AGC_Target_Level		0x0005
    162 #define Output_AGC_Noise_Floor		0x0006
    163 #define Output_AGC_SNR_Improvement	0x0007
    164 #define Comfort_Noise			0x001A
    165 #define Comfort_Noise_Level		0x001B
    166 
    167 /* Get/Set Algorithm Parameter ID List (Receive Feature) */
    168 #define Speaker_Volume			0x0012
    169 #define VEQ_Mode			0x0009
    170 #define VEQ_Max_FarEnd_Limiter_Level	0x000D
    171 #define VEQ_Noise_Estimation_Adj	0x0025
    172 #define Receive_NS			0x000E
    173 #define Receive_NS_Level		0x000F
    174 #define SideTone			0x0015
    175 #define SideTone_Gain			0x0016
    176 
    177 /* Audio Path Commands */
    178 /* Get/Set Transmit Digital Input Gain */
    179 #define A100_msg_GetTxDigitalInputGain  0x801A
    180 #define A100_msg_SetTxDigitalInputGain  0x801B
    181 
    182 /* Get/Set Receive Digital Input Gain */
    183 #define A100_msg_GetRcvDigitalInputGain 0x8022
    184 #define A100_msg_SetRcvDigitalInputGain 0x8023
    185 
    186 /* Get/Set Transmit Digital Output Gain */
    187 #define A100_msg_GetTxDigitalOutputGain 0x801D
    188 #define A100_msg_SetTxDigitalOutputGain 0x8015
    189 
    190 /* Bypass */
    191 #define A100_msg_Bypass		0x801C /* 0ff = 0x0000; on = 0x0001 (Default) */
    192 #define A1026_msg_VP_ON		0x801C0001
    193 #define A1026_msg_VP_OFF	0x801C0000
    194 
    195 /* Diagnostic API Commands */
    196 #define A100_msg_GetMicRMS	0x8013
    197 #define A100_msg_GetMicPeak	0x8014
    198 #define DiagPath_Pri_Input_Mic	0x0000
    199 #define DiagPath_Sec_Input_Mic	0x0001
    200 #define DiagPath_Output_Mic	0x0002
    201 #define DiagPath_Far_End_Input	0x0003
    202 #define DiagPath_Far_End_Output	0x0004
    203 #define A100_msg_SwapInputCh	0x8019
    204 #define A100_msg_OutputKnownSig	0x801E
    205 
    206 #define A1026_msg_BOOT		0x0001
    207 #define A1026_msg_BOOT_ACK	0x01
    208 
    209 /* general definitions */
    210 #define TIMEOUT			20 /* ms */
    211 #define RETRY_CNT		5
    212 #define POLLING_RETRY_CNT	3
    213 #define A1026_ERROR_CODE	0xffff
    214 #define A1026_SLEEP		0
    215 #define A1026_ACTIVE		1
    216 #define A1026_CMD_FIFO_DEPTH	64
    217 #define ERROR			0xffffffff
    218 
    219 enum A1026_config_mode {
    220 	A1026_CONFIG_FULL,
    221 	A1026_CONFIG_VP
    222 };
    223 
    224 struct a1026_platform_data {
    225 	uint32_t gpio_a1026_micsel;
    226 	uint32_t gpio_a1026_wakeup;
    227 	uint32_t gpio_a1026_reset;
    228 	uint32_t gpio_a1026_int;
    229 	uint32_t gpio_a1026_clk;
    230 };
    231 
    232 
    233 #endif /* __KERNEL__ */
    234 #endif /* __LINUX_A1026_H */
    235