lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /***********************************************************************
|
| 2 | * Copyright (C) 2008, ZTE Corporation.
|
| 3 | *
|
| 4 | * File Name: audio_api.h
|
| 5 | * File Mark:
|
| 6 | * Description: Provide audio module function prototype declaration and type declaration.
|
| 7 | * For no multimedia processor platform.
|
| 8 | * Others:
|
| 9 | * Version: v0.5
|
| 10 | * Author: DangMaochang
|
| 11 | * Date: 2008-06-30
|
| 12 | *
|
| 13 | * History 1:
|
| 14 | * Date:
|
| 15 | * Version:
|
| 16 | * Author:
|
| 17 | * Modification:
|
| 18 | * History 2:
|
| 19 | **********************************************************************/
|
| 20 |
|
| 21 | #ifndef _AUDIO_API_H
|
| 22 | #define _AUDIO_API_H
|
| 23 |
|
| 24 | #include "drvs_io.h"
|
| 25 | #include "drvs_io_voice.h"
|
| 26 |
|
| 27 | /**************************************************************************
|
| 28 | * Include files *
|
| 29 | **************************************************************************/
|
| 30 |
|
| 31 |
|
| 32 | /**************************************************************************
|
| 33 | * Macro *
|
| 34 | **************************************************************************/
|
| 35 | #define ZDRV_DEV_AUDIO "audio" /*The device name of audio driver.*/
|
| 36 |
|
| 37 | /**************************************************************************
|
| 38 | * Types *
|
| 39 | **************************************************************************/
|
| 40 |
|
| 41 | /*Information from driver to upper application.*/
|
| 42 | typedef enum {
|
| 43 | AUDIO_INFO_FILE_INVALID = 0,
|
| 44 | AUDIO_INFO_PLAY_END ,
|
| 45 | AUDIO_INFO_PLAY_ERR ,
|
| 46 | AUDIO_INFO_REC_END ,
|
| 47 | AUDIO_INFO_REC_ERR ,
|
| 48 |
|
| 49 | MAX_AUDIO_INFO
|
| 50 | } T_ZDrvAudio_Info;
|
| 51 |
|
| 52 | /* Audio input channel volum level selection. */
|
| 53 | typedef enum{
|
| 54 | AUDIO_INPUT_VOL_LEVEL_0 = 0,
|
| 55 | AUDIO_INPUT_VOL_LEVEL_1,
|
| 56 | AUDIO_INPUT_VOL_LEVEL_2,
|
| 57 | AUDIO_INPUT_VOL_LEVEL_3,
|
| 58 | AUDIO_INPUT_VOL_LEVEL_4,
|
| 59 | AUDIO_INPUT_VOL_LEVEL_5,
|
| 60 | AUDIO_INPUT_VOL_LEVEL_6,
|
| 61 | AUDIO_INPUT_VOL_LEVEL_7,
|
| 62 | AUDIO_INPUT_VOL_LEVEL_8,
|
| 63 | AUDIO_INPUT_VOL_LEVEL_9,
|
| 64 | AUDIO_INPUT_VOL_LEVEL_10,
|
| 65 | AUDIO_INPUT_VOL_LEVEL_11,
|
| 66 | MAX_AUDIO_INPUT_VOL_LEVEL
|
| 67 | } T_ZDrvAudio_InputVolLevel;
|
| 68 |
|
| 69 | /* Audio output channel volum level selection. */
|
| 70 | typedef enum{
|
| 71 | AUDIO_OUTPUT_VOL_LEVEL_0 = 0,
|
| 72 | AUDIO_OUTPUT_VOL_LEVEL_1,
|
| 73 | AUDIO_OUTPUT_VOL_LEVEL_2,
|
| 74 | AUDIO_OUTPUT_VOL_LEVEL_3,
|
| 75 | AUDIO_OUTPUT_VOL_LEVEL_4,
|
| 76 | AUDIO_OUTPUT_VOL_LEVEL_5,
|
| 77 | AUDIO_OUTPUT_VOL_LEVEL_6,
|
| 78 | AUDIO_OUTPUT_VOL_LEVEL_7,
|
| 79 | AUDIO_OUTPUT_VOL_LEVEL_8,
|
| 80 | AUDIO_OUTPUT_VOL_LEVEL_9,
|
| 81 | AUDIO_OUTPUT_VOL_LEVEL_10,
|
| 82 | AUDIO_OUTPUT_VOL_LEVEL_11,
|
| 83 |
|
| 84 | MAX_AUDIO_OUTPUT_VOL_LEVEL
|
| 85 | } T_ZDrvAudio_OutputVolLevel;
|
| 86 |
|
| 87 | /* brief Select the audio data sampling rate for the Stereo DAC.
|
| 88 | * note: This enumeration defines all of the possible sampling rates currently
|
| 89 | * supported by the Stereo DAC. One of these sampling rates must be selected
|
| 90 | * and it must match that of the audio stream or else signal distortion will
|
| 91 | * occur.
|
| 92 | */
|
| 93 | typedef enum
|
| 94 | {
|
| 95 | AUDIO_RATE_8_KHZ, /* Use 8 kHz sampling rate. */
|
| 96 | AUDIO_RATE_11_025_KHZ, /* Use 11.025 kHz sampling rate. */
|
| 97 | AUDIO_RATE_12_KHZ, /* Use 12 kHz sampling rate. */
|
| 98 | AUDIO_RATE_16_KHZ, /* Use 16 kHz sampling rate. */
|
| 99 | AUDIO_RATE_22_050_KHZ, /* Use 22.050 kHz sampling rate. */
|
| 100 | AUDIO_RATE_24_KHZ, /* Use 24 kHz sampling rate. */
|
| 101 | AUDIO_RATE_32_KHZ, /* Use 32 kHz sampling rate. */
|
| 102 | AUDIO_RATE_44_1_KHZ, /* Use 44.1 kHz sampling rate. */
|
| 103 | AUDIO_RATE_48_KHZ, /* Use 48 kHz sampling rate. */
|
| 104 | AUDIO_RATE_64_KHZ, /* Use 64 kHz sampling rate */
|
| 105 | AUDIO_RATE_96_KHZ, /* Use 96 kHz sampling rate. */
|
| 106 | MAX_AUDIO_RATE
|
| 107 | } T_ZDrvAudio_SampleRate;
|
| 108 |
|
| 109 | /* Audio stereoDAC balance left level selection. */
|
| 110 | typedef enum{
|
| 111 | AUDIO_STEREO_BALANCE_LEVEL_0 = 0,
|
| 112 | AUDIO_STEREO_BALANCE_LEVEL_1,
|
| 113 | AUDIO_STEREO_BALANCE_LEVEL_2,
|
| 114 | AUDIO_STEREO_BALANCE_LEVEL_3,
|
| 115 | AUDIO_STEREO_BALANCE_LEVEL_4,
|
| 116 | AUDIO_STEREO_BALANCE_LEVEL_5,
|
| 117 | AUDIO_STEREO_BALANCE_LEVEL_6,
|
| 118 | AUDIO_STEREO_BALANCE_LEVEL_7,
|
| 119 | MAX_AUDIO_STEREO_BALANCE_LEVEL
|
| 120 | } T_ZDrvAudio_BalanceLevel;
|
| 121 |
|
| 122 | /* Audio stereoDAC BANLANCE */
|
| 123 | typedef struct
|
| 124 | {
|
| 125 | T_ZDrvAudio_BalanceLevel balanceLeft; /* left */
|
| 126 | T_ZDrvAudio_BalanceLevel balanceright; /* right */
|
| 127 | } T_ZDrvAudio_Banlance;
|
| 128 |
|
| 129 | /* Audio 3DEFFECT */
|
| 130 | typedef struct
|
| 131 | {
|
| 132 | UINT16 setbass; /*set bass effect*/
|
| 133 | UINT16 setsurr; /*set surround effect*/
|
| 134 | }T_ZDrvAudio_3DEFFECT;
|
| 135 |
|
| 136 | /* Audio eq mode */
|
| 137 | typedef enum
|
| 138 | {
|
| 139 | AUDIO_EQMODE_NORMAL=0,
|
| 140 | AUDIO_EQMODE_CLASSIC,
|
| 141 | AUDIO_EQMODE_POP,
|
| 142 | AUDIO_EQMODE_JAZZ,
|
| 143 | AUDIO_EQMODE_ROCK,
|
| 144 | MAX_AUDIO_EQMODE
|
| 145 | }T_ZDrvAUDIO_EQMODE;
|
| 146 |
|
| 147 | /* Audio play info */
|
| 148 | typedef struct
|
| 149 | {
|
| 150 | UINT32 DataLenth; /*Total play datalenth(byte).*/
|
| 151 |
|
| 152 | } T_ZDrvAudio_PlayInfo;
|
| 153 |
|
| 154 | /* Audio buffer info */
|
| 155 | typedef struct
|
| 156 | {
|
| 157 | VOID *buf; /* Audio buffer pointer */
|
| 158 | UINT32 buffersize; /* Audio buffer size */
|
| 159 | }T_ZDrvAudio_BufInfo;
|
| 160 |
|
| 161 | #if 0
|
| 162 | typedef enum
|
| 163 | {
|
| 164 | AUDIO_MONO_CHANNEL,
|
| 165 | AUDIO_DUAL_CHANNEL
|
| 166 | }T_ZDrvAudio_Channel;
|
| 167 | #endif
|
| 168 |
|
| 169 | /* Audio buffer size */
|
| 170 | typedef struct
|
| 171 | {
|
| 172 | T_ZDrvAudio_Channel channel;
|
| 173 | UINT32 buffersize;
|
| 174 | }T_ZDrvAudio_PlayParam;
|
| 175 |
|
| 176 | /**************************************************************************
|
| 177 | * Global Variable *
|
| 178 | **************************************************************************/
|
| 179 |
|
| 180 |
|
| 181 | /**************************************************************************
|
| 182 | * Function Prototypes *
|
| 183 | **************************************************************************/
|
| 184 | typedef void (*T_ZDrvAudio_CallbackFunc) (T_ZDrvAudio_Info);
|
| 185 |
|
| 186 | /**************************************************************************
|
| 187 | * Function: zDrv_Open
|
| 188 | * Description: This function is used to open device according to device name.
|
| 189 | * Parameters:
|
| 190 | * Input:
|
| 191 | pathname:device name, ZDRV_DEV_AUDIO in audio
|
| 192 | * flags: no use
|
| 193 | * Output: None
|
| 194 | * Returns:
|
| 195 | * device file descriptor if successed. [1, ZDRV_MAX_DEV_FILE_NUM), please refer to dal_api.h
|
| 196 | * DRV_ERR_NO_THIS_DEVICE: this device hasn't been installed yet
|
| 197 | * DRV_ERR_FD_OVERFLOW: no free fd entry
|
| 198 | * DRV_ERR_NOT_SUPPORTED: this device don't support open operation.
|
| 199 | * DRV_ERR_OPEN_TIMES: has been opened already.
|
| 200 | * others: others error code. for detailed information, please refer to the header file of hal layer
|
| 201 | * Others: None
|
| 202 | **************************************************************************/
|
| 203 | /*SINT32 zDrv_Open (const CHAR *pathname, SINT32 flags)*/
|
| 204 |
|
| 205 |
|
| 206 | /**************************************************************************
|
| 207 | * Function: zDrv_Close
|
| 208 | * Description: This function is used to close a device according to device file descriptor.
|
| 209 | * Parameters:
|
| 210 | * Input:
|
| 211 | * fd :device file descriptor
|
| 212 | * Output:None
|
| 213 | * Returns:
|
| 214 | * DRV_SUCCESS: successed.
|
| 215 | * DRV_ERR_NOT_OPENED: has not been opend yet.
|
| 216 | * DRV_ERR_FD_TABLE: device driver table has been invalid.
|
| 217 | * DRV_ERR_NOT_SUPPORTED: this device don't support close operation.
|
| 218 | * others: others error code. for detailed information, please refer to the header file of hal layer
|
| 219 | * Others: None
|
| 220 | **************************************************************************/
|
| 221 | /*SINT32 zDrv_Close(UINT32 fd)*/
|
| 222 |
|
| 223 | /**************************************************************************
|
| 224 | * Function: zDrv_Write
|
| 225 | * Description: This function is used to write data to a device according to the device file descriptor.
|
| 226 | * Parameters:
|
| 227 | * (IN)
|
| 228 | * fd: device file descriptor
|
| 229 | * buf_len: buffer length
|
| 230 | * buf: pointer to the data to be written
|
| 231 | * (OUT)
|
| 232 | * None
|
| 233 | * Returns:
|
| 234 | * the write byte number of read data if successed
|
| 235 | * DRV_ERR_INVALID_PARAM: the input parameters are invalid
|
| 236 | * DRV_ERR_DEV_CLOSED: has not been opend yet.
|
| 237 | * DRV_ERR_NOT_SUPPORTED: this device don't support read operation.
|
| 238 | * others: for detailed information, please refer to the header file of hal layer
|
| 239 | * Others:
|
| 240 | * None.
|
| 241 |
|
| 242 | **************************************************************************/
|
| 243 | /* SINT32 zDrv_Write(UINT32 fd, VOID *buf, UINT32 buf_len) */
|
| 244 |
|
| 245 | /**************************************************************************
|
| 246 | * Function: zDrv_Ioctl
|
| 247 | * Description: This function is used to control audio device.
|
| 248 | * Parameters:
|
| 249 | * Input:
|
| 250 | * private:device private data
|
| 251 | * cmd:command code
|
| 252 | * param:command parameters
|
| 253 | * Output:None
|
| 254 | * Returns:
|
| 255 | * T_ZDrv_ErrCode
|
| 256 | * others: if errcode<-100 ,please refer to the hal layer errcode file
|
| 257 |
|
| 258 | * Others: cmd-arg
|
| 259 | 1 CMD:IOCTL_AUDIO_RECORD_START:
|
| 260 | arg: T_ZDrvRcd_InfoParam*
|
| 261 | return:
|
| 262 |
|
| 263 | 2 CMD:IOCTL_AUDIO_RECORD_STOP:
|
| 264 | arg: void
|
| 265 | return:
|
| 266 |
|
| 267 | 3 CMD:IOCTL_AUDIO_SET_RECORD_PATH:
|
| 268 | arg: T_HalAudio_Block*
|
| 269 | return:
|
| 270 |
|
| 271 | 4 CMD:IOCTL_AUDIO_SET_RECORD_VOL:
|
| 272 | arg: T_HalAudio_Block*
|
| 273 | return:
|
| 274 |
|
| 275 | 5 CMD:IOCTL_AUDIO_RECORD_GETDATA:
|
| 276 | arg: T_ZDrvAudio_BufInfo*
|
| 277 | return:
|
| 278 |
|
| 279 | 6 CMD:IOCTL_AUDIO_RCD_FREE_BUFF:
|
| 280 | arg: VOID
|
| 281 | return:
|
| 282 |
|
| 283 | 7 CMD:IOCTL_AUDIO_SET_SAMPLE:
|
| 284 | arg: T_ZDrvAudio_SampleRate*
|
| 285 | return:
|
| 286 |
|
| 287 | 8 CMD:IOCTL_AUDIO_SET_BANLANCE:
|
| 288 | arg: T_ZDrvAudio_Banlance*
|
| 289 | return:
|
| 290 |
|
| 291 | 9 CMD:IOCTL_AUDIO_SET_OUTPUT_PATH:
|
| 292 | arg: T_ZDrv_AudioOutputPath*
|
| 293 | return:
|
| 294 |
|
| 295 | 10 CMD:IOCTL_AUDIO_SET_OUTPUT_VOL:
|
| 296 | arg: T_ZDrvAudio_OutputVolLevel*
|
| 297 | return:
|
| 298 |
|
| 299 | 11 CMD:IOCTL_AUDIO_SET_EQMODE:
|
| 300 | arg: T_ZDrvAUDIO_EQMODE*
|
| 301 | return:
|
| 302 |
|
| 303 | 12 CMD:IOCTL_AUDIO_ENABLE_3DEFFECT:
|
| 304 | arg: T_ZDrvAudio_3DEFFECT*
|
| 305 | return:
|
| 306 |
|
| 307 | 13 CMD:IOCTL_AUDIO_SET_MUTE:
|
| 308 | arg: BOOL*
|
| 309 | return:
|
| 310 |
|
| 311 | 14 CMD:IOCTL_AUDIO_PLAY_START:
|
| 312 | arg: VOID*;
|
| 313 | return:
|
| 314 |
|
| 315 | 15 CMD:IOCTL_AUDIO_PLAY_STOP:
|
| 316 | arg: VOID*;
|
| 317 | return:
|
| 318 |
|
| 319 | 16 CMD:IOCTL_AUDIO_PLAY_PAUSE:
|
| 320 | arg: VOID*;
|
| 321 | return:
|
| 322 |
|
| 323 | 17 CMD:IOCTL_AUDIO_PLAY_RESUME:
|
| 324 | arg: VOID*;
|
| 325 | return:
|
| 326 |
|
| 327 | 18 CMD:IOCTL_AUDIO_GET_PLAY_INFO:
|
| 328 | arg: T_ZDrvAudio_PlayInfo*
|
| 329 | return:
|
| 330 |
|
| 331 | 19 CMD:IOCTL_AUDIO_GET_BUFFER:
|
| 332 | arg: T_ZDrvAudio_BufInfo*
|
| 333 | return:
|
| 334 | 20. CMD :IOCTL_AUDIO_SET_RECORD_SAMPLE:
|
| 335 | arg: T_ZDrvAudio_SampleRate*
|
| 336 | return:
|
| 337 |
|
| 338 | 21 CMD:MAX_IOCTL_AUDIO
|
| 339 | ERROR CMD INPUT
|
| 340 |
|
| 341 | **************************************************************************/
|
| 342 | /* SINT32 zDrv_Ioctl(UINT32 fd, UINT32 cmd, VOID* arg); */
|
| 343 |
|
| 344 | /**************************************************************************
|
| 345 | * Function: zDrv_Read
|
| 346 | * Description: This function is used to read data from a device according to device file descriptor.
|
| 347 | * Parameters:
|
| 348 | * Input:
|
| 349 | * fd:device file descriptor
|
| 350 | * buf: user buffer pointer
|
| 351 | * buf_len:buffer length
|
| 352 | * Output:
|
| 353 | * buf:pointer to the read data buffer
|
| 354 | * Returns:
|
| 355 | * DRV_SUCCESS:success to read data
|
| 356 | * DRV_ERR_NOT_OPENED:device is not openned before
|
| 357 | * DRV_ERROR:fail to read data
|
| 358 | * DRV_ERR_INVALID_PARAM: invalid paraments.
|
| 359 | * Others: None
|
| 360 |
|
| 361 | **************************************************************************/
|
| 362 | /*SINT32 zDrv_Read(UINT32 fd, VOID *buf, UINT32 buf_len)*/
|
| 363 |
|
| 364 |
|
| 365 | #endif /* _AUDIO_API_H */
|