ql_audio.h 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582
  1. 
  2. /*================================================================
  3. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  4. Quectel Wireless Solutions Proprietary and Confidential.
  5. =================================================================*/
  6. #ifndef _QL_AUDIO_H_
  7. #define _QL_AUDIO_H_
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #include "ql_api_osi.h"
  12. #include "ql_api_common.h"
  13. #include "ql_codec_config.h"
  14. #ifdef CONFIG_QUEC_PROJECT_FEATURE_USB_AUDIO
  15. #include "ql_usb.h"
  16. #endif
  17. #define QL_PCM_BLOCK_FLAG (0x01)
  18. #define QL_PCM_NONBLOCK_FLAG (0x02)
  19. #define QL_PCM_READ_FLAG (0x04)
  20. #define QL_PCM_WRITE_FLAG (0x08)
  21. #define PACKET_WRITE_MAX_SIZE 16*1024//avoid mp3 head information too long cause play fail, mp3 head information no more than 16K
  22. //ALC5616E not support now
  23. //#define QL_CODEC_5616E_SUPPORT
  24. typedef enum
  25. {
  26. AUDIOHAL_SPK_MUTE = 0,
  27. AUDIOHAL_SPK_VOL_1,
  28. AUDIOHAL_SPK_VOL_2,
  29. AUDIOHAL_SPK_VOL_3,
  30. AUDIOHAL_SPK_VOL_4,
  31. AUDIOHAL_SPK_VOL_5,
  32. AUDIOHAL_SPK_VOL_6,
  33. AUDIOHAL_SPK_VOL_7,
  34. AUDIOHAL_SPK_VOL_8,
  35. AUDIOHAL_SPK_VOL_9,
  36. AUDIOHAL_SPK_VOL_10,
  37. AUDIOHAL_SPK_VOL_11, // 11
  38. AUDIOHAL_SPK_VOL_QTY // 12
  39. } AUDIOHAL_SPK_LEVEL_T;
  40. /**
  41. * \brief tone sample rate
  42. */
  43. typedef enum
  44. {
  45. QL_TONESAMPLE_RATE_NONE = 0,
  46. QL_TONESAMPLE_RATE_16000 = 16000, ///< tone sample rate 16000
  47. } QL_TONESAMPLE_RATE_E;
  48. typedef enum
  49. {
  50. QL_AUDIO_SUCCESS = 0,
  51. QL_AUDIO_UNKNOWN_ERROR = (QL_COMPONENT_AUDIO << 16) | 901,
  52. QL_AUDIO_INVALID_PARAM = (QL_COMPONENT_AUDIO << 16) | 902,
  53. QL_AUDIO_OPER_NOT_SUPPORTED = (QL_COMPONENT_AUDIO << 16) | 903,
  54. QL_AUDIO_DEVICE_BUSY = (QL_COMPONENT_AUDIO << 16) | 904,
  55. QL_AUDIO_FILE_NOT_EXIST = (QL_COMPONENT_AUDIO << 16) | 905,
  56. QL_AUDIO_FREE_SIZE_NOT_ENOUGH = (QL_COMPONENT_AUDIO << 16) | 906,
  57. QL_AUDIO_NO_MEMORY = (QL_COMPONENT_AUDIO << 16) | 907,
  58. QL_AUDIO_SET_PATH_FAIL = (QL_COMPONENT_AUDIO << 16) | 908,
  59. QL_AUDIO_FILE_IN_OPERATION = (QL_COMPONENT_AUDIO << 16) | 909,
  60. QL_AUDIO_ERROR_AUDIO_PATH = (QL_COMPONENT_AUDIO << 16) | 910,
  61. QL_AUDIO_FILE_TYPE_NOT_SUPPORT = (QL_COMPONENT_AUDIO << 16) | 911,
  62. QL_AUDIO_DEVICE_NOT_EXIST = (QL_COMPONENT_AUDIO << 16) | 912,
  63. QL_AUDIO_PLAY_FAIL = (QL_COMPONENT_AUDIO << 16) | 913,
  64. QL_AUDIO_PARAM_SET_FAIL = (QL_COMPONENT_AUDIO << 16) | 914,
  65. QL_AUDIO_OPEN_FILE_FAIL = (QL_COMPONENT_AUDIO << 16) | 915,
  66. QL_AUDIO_RECORD_SYS_FAIL = (QL_COMPONENT_AUDIO << 16) | 916,
  67. QL_AUDIO_PLAYER_SYS_FAIL = (QL_COMPONENT_AUDIO << 16) | 917,
  68. QL_AUDIO_END_FAIL = (QL_COMPONENT_AUDIO << 16) | 918,
  69. QL_AUDIO_NOT_INIT = (QL_COMPONENT_AUDIO << 16) | 919,
  70. QL_AUDIO_FILE_ERROR = (QL_COMPONENT_AUDIO << 16) | 920,
  71. QL_AUDIO_ACTION_FAIL = (QL_COMPONENT_AUDIO << 16) | 921,
  72. //codec
  73. QL_AUDIO_CODEC_WR_FAIL = (QL_COMPONENT_AUDIO << 16) | 2000,
  74. QL_AUDIO_CODEC_RD_FAIL = (QL_COMPONENT_AUDIO << 16) | 2001,
  75. QL_AUDIO_CODEC_INIT_FAIL = (QL_COMPONENT_AUDIO << 16) | 2002,
  76. }ql_audio_errcode_e;
  77. typedef enum
  78. {
  79. QL_AUDIO_RINGTONE_PLAY = (QL_COMPONENT_AUDIO << 16) | 4000,
  80. }ql_audio_event_e;
  81. typedef enum
  82. {
  83. AUD_RECORD_ERROR = -1,
  84. AUD_RECORD_START = 0, //audio recorder start record
  85. AUD_RECORD_DATA, //record data comming
  86. AUD_RECORD_PAUSE, //record has been paused by call or pause api
  87. AUD_RECORD_CLOSE, //record closed
  88. AUD_RECORD_RESUME, //resume from pause
  89. AUD_RECORD_CALL_INT, //record interrupt from ring/call
  90. }enum_aud_record_state;
  91. typedef enum
  92. {
  93. AUD_PLAYER_ERROR = -1,
  94. AUD_PLAYER_START = 0, //audio player start play
  95. AUD_PLAYER_PAUSE, //audio player has been paused by call or pause api
  96. AUD_PLAYER_FINISHED, //audio player finish current playing
  97. AUD_PLAYER_CLOSE, //audio player closed
  98. AUD_PLAYER_RESUME, //resume player from pause
  99. }enum_aud_player_state;
  100. typedef enum
  101. {
  102. QL_AUDIO_PLAY_TYPE_NONE = 0,
  103. QL_AUDIO_PLAY_TYPE_LOCAL,
  104. QL_AUDIO_PLAY_TYPE_VOICE,
  105. QL_AUDIO_PLAY_TYPE_POC,
  106. QL_AUDIO_PLAY_TYPE_MAX
  107. } AudPlayType_e;
  108. typedef enum
  109. {
  110. QL_OUTPUT_RECEIVER = 0, ///< receiver
  111. QL_OUTPUT_HEADPHONE = 1, ///< headphone
  112. QL_OUTPUT_SPEAKER = 2, ///< speaker
  113. QL_OUTPUT_MAX,
  114. } AudOutputType_e;
  115. typedef enum
  116. {
  117. QL_INPUT_MAINMIC = 0, ///< main mic
  118. QL_INPUT_AUXMIC = 1, ///< auxilary mic
  119. QL_INPUT_DUALMIC = 2, ///< dual mic
  120. QL_INPUT_HPMIC_L = 3, ///< headphone mic left
  121. QL_INPUT_HPMIC_R = 4, ///< headphone mic right
  122. } AudInputType_e;
  123. typedef enum
  124. {
  125. QL_AUDIO_FORMAT_UNKNOWN, ///< placeholder for unknown format
  126. QL_AUDIO_FORMAT_PCM, ///< raw PCM data
  127. QL_AUDIO_FORMAT_WAVPCM, ///< WAV, PCM inside
  128. QL_AUDIO_FORMAT_MP3, ///< MP3
  129. QL_AUDIO_FORMAT_AMRNB, ///< AMR-NB
  130. QL_AUDIO_FORMAT_AMRWB, ///< AMR_WB
  131. QL_AUDIO_FORMAT_MAX
  132. } AudStreamFormat_e;
  133. typedef enum
  134. {
  135. AMRNB_MODE_NONE = 0,
  136. AMRNB_MODE_475, ///< 4.75 kbps
  137. AMRNB_MODE_515, ///< 5.15 kbps
  138. AMRNB_MODE_590, ///< 5.90 kbps
  139. AMRNB_MODE_670, ///< 6.70 kbps
  140. AMRNB_MODE_740, ///< 7.40 kbps
  141. AMRNB_MODE_795, ///< 7.95 kbps
  142. AMRNB_MODE_1020, ///< 10.2 kbps
  143. AMRNB_MODE_1220, ///< 12.2 kbps
  144. AMRNB_MODE_MAX,
  145. } amrnb_mode_e;
  146. /**
  147. * \brief AMR-WB modes
  148. */
  149. typedef enum
  150. {
  151. AMRWB_MODE_NONE = 0,
  152. AMRWB_MODE_660, ///< 6.60 kbps
  153. AMRWB_MODE_885, ///< 8.85 kbps
  154. AMRWB_MODE_1265, ///< 12.65 kbps
  155. AMRWB_MODE_1425, ///< 14.25 kbps
  156. AMRWB_MODE_1585, ///< 15.85 kbps
  157. AMRWB_MODE_1825, ///< 18.25 kbps
  158. AMRWB_MODE_1985, ///< 19.85 kbps
  159. AMRWB_MODE_2305, ///< 23.05 kbps
  160. AMRWB_MODE_2385, ///< 23.85 kbps
  161. AMRWB_MODE_MAX,
  162. } amrwb_mode_e;
  163. typedef enum
  164. {
  165. QL_AUD_VOICECALL_NB = 0, //not volte mode
  166. QL_AUD_VOICECALL_WB = 5 //volte mode
  167. }QL_AUD_CALLMODE_E;
  168. typedef enum
  169. {
  170. QL_AUDIO_STATUS_IDLE, ///< playback not started
  171. QL_AUDIO_STATUS_RUNNING, ///< playback is started
  172. QL_AUDIO_STATUS_PAUSE, ///< playback is paused
  173. QL_AUDIO_STATUS_FINISHED, ///< playback is finished
  174. } AudioStatus_e;
  175. typedef enum
  176. {
  177. QL_ADC_GAIN_LEVEL_1 = -1, // ==> mute
  178. QL_ADC_GAIN_LEVEL_2 = 0, // ==> 0db
  179. QL_ADC_GAIN_LEVEL_3, // ==> 3db
  180. QL_ADC_GAIN_LEVEL_4, // ==> 6db
  181. QL_ADC_GAIN_LEVEL_5, // ==> 9db
  182. QL_ADC_GAIN_LEVEL_6, // ==> 12db
  183. QL_ADC_GAIN_LEVEL_7, // ==> 15db
  184. QL_ADC_GAIN_LEVEL_8, // ==> 18db
  185. QL_ADC_GAIN_LEVEL_9, // ==> 21db
  186. QL_ADC_GAIN_LEVEL_10, // ==> 24db
  187. QL_ADC_GAIN_LEVEL_11, // ==> 27db
  188. QL_ADC_GAIN_LEVEL_12, // ==> 30db
  189. QL_ADC_GAIN_LEVEL_MAX,
  190. }QL_ADC_GAIN_E;
  191. typedef struct
  192. {
  193. QL_ADC_GAIN_E adc_gain;
  194. }ql_aud_adc_cfg;
  195. typedef struct
  196. {
  197. uint8 dac_gain;// value: 0-0xff, 0:-95.5db 1:-95db.....0xff:32db 0.5dB/step
  198. }ql_aud_dac_cfg;
  199. typedef enum
  200. {
  201. QL_AUDIO_PLAYER_IDLE, //audio player is in idle state
  202. /*
  203. audio is playing file now, started
  204. by ql_aud_play_file_start, ql_aud_play_file_start_ex, ql_play_file_start
  205. */
  206. QL_AUDIO_IS_PLAYING_FILE,
  207. /*
  208. audio is playing stream now, started
  209. by ql_aud_play_stream_start
  210. */
  211. QL_AUDIO_IS_PLAYING_STREAM,
  212. /*
  213. audio is playing stream now, started
  214. by ql_pcm_open, ql_aud_pcm_open, and flag is write, include tts
  215. */
  216. QL_AUDIO_IS_PLAYING_PCM,
  217. /*
  218. audio is playing DTMF, or tone
  219. */
  220. QL_AUDIO_IS_PLAYING_DTMF,
  221. }QL_PLAYING_FUNCTION_E;
  222. typedef enum
  223. {
  224. QL_AUDIO_RECORDER_IDLE, //audio recorder is in idle state
  225. /*
  226. audio is recording file now, started
  227. by ql_aud_record_file_start
  228. */
  229. QL_AUDIO_IS_RECORDING_FILE,
  230. /*
  231. audio is recording stream now, started
  232. by ql_aud_record_stream_start
  233. */
  234. QL_AUDIO_IS_RECORDING_STREAM,
  235. /*
  236. audio is recording pcm now, started
  237. by ql_pcm_open, ql_aud_pcm_open, and flag is read
  238. */
  239. QL_AUDIO_IS_RECORDING_PCM,
  240. }QL_RECORDING_FUNCTION_E;
  241. typedef enum
  242. {
  243. QL_REC_TYPE_NONE = 0,
  244. QL_REC_TYPE_MIC, //uplink
  245. QL_REC_TYPE_VOICE, //downlink
  246. QL_REC_TYPE_VOICE_DUAL, //DUAL uplink and downlink
  247. QL_REC_TYPE_DEBUG_DUMP, //invalid now
  248. QL_REC_TYPE_POC, //used in POC mode
  249. QL_REC_TYPE_MAX,
  250. } AudRecType_e;
  251. typedef enum
  252. {
  253. QL_PCM_NONE = 0,
  254. QL_PCM_LOCAL,
  255. QL_PCM_VOICE_CALL,
  256. QL_PCM_POC,
  257. QL_PCM_MAX,
  258. }pcm_path_e;
  259. typedef enum
  260. {
  261. QL_POC_TYPE_MIN = -1,
  262. QL_POC_TYPE_HALF_DUPLEX,
  263. QL_POC_TYPE_FULL_DUPLEX,
  264. QL_POC_TYPE_MAX,
  265. }QL_POC_TYPE_E;
  266. typedef enum
  267. {
  268. QL_POC_MODE_MIN = 0,
  269. QL_POC_MODE_REC,
  270. QL_POC_MODE_PLAY,
  271. QL_POC_MODE_MAX,
  272. }QL_POC_MODE_E;
  273. typedef enum
  274. {
  275. QL_CODEC_CLK_FREQ_12M = 12,
  276. QL_CODEC_CLK_FREQ_13M = 13,
  277. QL_CODEC_CLK_FREQ_24M = 24,
  278. QL_CODEC_CLK_FREQ_26M = 26,
  279. QL_CODEC_CLK_FREQ_MAX
  280. } QL_CODEC_CLK_FREQ_E;
  281. typedef enum
  282. {
  283. QL_AUD_RING_NONE = 0, //no ring tone
  284. QL_AUD_RING_NOKIA, //invalid now
  285. QL_AUD_RING_DIAL_TONE,
  286. QL_AUD_RING_CUSTOMER_DEF,
  287. QL_AUD_RING_MAX,
  288. }QL_AUD_RING_TYPE_E;
  289. typedef enum
  290. {
  291. AUDIOHAL_DTMF_0 = 0,
  292. AUDIOHAL_DTMF_1,
  293. AUDIOHAL_DTMF_2,
  294. AUDIOHAL_DTMF_3,
  295. AUDIOHAL_DTMF_4,
  296. AUDIOHAL_DTMF_5,
  297. AUDIOHAL_DTMF_6,
  298. AUDIOHAL_DTMF_7,
  299. AUDIOHAL_DTMF_8,
  300. AUDIOHAL_DTMF_9,
  301. AUDIOHAL_DTMF_A,
  302. AUDIOHAL_DTMF_B,
  303. AUDIOHAL_DTMF_C,
  304. AUDIOHAL_DTMF_D,
  305. AUDIOHAL_DTMF_S, //* key
  306. AUDIOHAL_DTMF_P, //# key
  307. } AUDIO_TONE_TYPE_E;
  308. typedef enum
  309. {
  310. QL_EXT_CODEC_INIT = 0, //内核通知应用配置与初始化相关的codec寄存器
  311. QL_EXT_CODEC_REC, //内核通知应用配置与录音相关的codec寄存器
  312. QL_EXT_CODEC_PLAY, //内核通知应用配置与播放相关的codec寄存器
  313. QL_EXT_CODEC_DEINIT, //内核通知应用播放/录音完成,可在此处配置寄存器关闭codec,降低功耗
  314. QL_EXT_CODEC_SET_VOLUME, //调用设置ql_aud_set_volume/ql_set_volume接口后,会触发回调函数;用户可自行决定是否要去配置寄存器
  315. } QL_EXT_CODEC_STAGE_E;
  316. typedef enum
  317. {
  318. QL_AUD_DATA_BIT_32, //iis/pcm数据帧长度为32bit(默认32bit传输,其中16bit有效,另外16bit为0)
  319. QL_AUD_DATA_BIT_16, //iis/pcm数据帧长度为16bit(TM8211等老式DAC适用)
  320. } ql_aud_data_bit_e;
  321. typedef enum
  322. {
  323. QL_AUD_TXDELAY_DEFAULT, //IIS_LRCK或PCM_SYNC的边缘延迟1个时钟周期后,模块开始向DOUT输出数据(默认)
  324. QL_AUD_TXDELAY_0, //IIS_LRCK或PCM_SYNC信号产生后,模块即开始向DOUT输出数据
  325. QL_AUD_TXDELAY_1, //IIS_LRCK或PCM_SYNC的边缘延迟1个时钟周期后,模块开始DOUT输出数据
  326. }ql_aud_txdelay_e;
  327. typedef enum
  328. {
  329. QL_AUD_RXDELAY_DEFAULT, //IIS_LRCK或PCM_SYNC的边缘延迟1个BCLK周期后,模块开始采样收到的数据(默认)
  330. QL_AUD_RXDELAY_0, //IIS_LRCK或PCM_SYNC信号产生后,模块即开始从DIN上采集数据
  331. QL_AUD_RXDELAY_1, //IIS_LRCK或PCM_SYNC的边缘延迟1个时钟周期后,模块开始从DIN上采集数据
  332. QL_AUD_RXDELAY_2, //IIS_LRCK或PCM_SYNC的边缘延迟2个时钟周期后,模块开始从DIN上采集数据
  333. QL_AUD_RXDELAY_3, //IIS_LRCK或PCM_SYNC的边缘延迟3个时钟周期后,模块开始从DIN上采集数据
  334. }ql_aud_rxdelay_e;
  335. typedef enum
  336. {
  337. QL_DATA_PROROCOL_IIS, //默认用IIS协议
  338. QL_DATA_PROROCOL_PCM //PCM协议
  339. }ql_aud_protocal_e;
  340. typedef struct
  341. {
  342. QL_EXT_CODEC_STAGE_E stage;//详见QL_EXT_CODEC_STAGE_E枚举
  343. } ql_codec_cb_param_t;
  344. /**********************************************************************************************
  345. Typedef
  346. **********************************************************************************************/
  347. typedef int(*cb_on_player)(char *p_data, int len, enum_aud_player_state state);
  348. typedef int(*cb_on_record)(char *p_data, int len, enum_aud_record_state state);
  349. typedef int(*cb_on_ring_tone)(bool start, void *ctx);
  350. typedef void(*cb_on_tone_detect)(char tone);
  351. typedef int(*cb_on_codec)(ql_codec_cb_param_t *param);
  352. typedef struct
  353. {
  354. bool extcodec_enable; //0:使用内置codec 1:使用外置codec
  355. cb_on_codec callback; //外置codec回调函数,用户初始化时注册,在播放/初始化时会调用用户注册的回调函数
  356. ql_aud_protocal_e protocal; //配置用IIS或PCM协议进行音频数据收发(默认用IIS协议)
  357. ql_aud_data_bit_e data_bits; //IIS/PCM传输的数据位个数
  358. ql_aud_txdelay_e tx_delay; //配置是否延迟一个或多个时钟周期后,才开始发数据
  359. ql_aud_rxdelay_e rx_delay; //配置是否延迟一个或多个时钟周期后,才开始收数据
  360. }ql_extcodec_info_t;
  361. typedef struct
  362. {
  363. amrwb_mode_e amrwb_mode;
  364. int reserve[2];
  365. }amrwb_param_t;
  366. typedef struct
  367. {
  368. amrnb_mode_e amrnb_mode;
  369. int reserve[2];
  370. }amrnb_param_t;
  371. typedef struct
  372. {
  373. int channels;
  374. int samplerate;
  375. int len_size;
  376. amrwb_param_t amrwb_param;
  377. amrnb_param_t amrnb_param;
  378. }ql_aud_config;
  379. typedef void *PCM_HANDLE_T ;
  380. typedef struct {
  381. unsigned int channels;
  382. unsigned int samplerate;
  383. unsigned int periodcnt; // 20ms buffersize/per period, value:2~8
  384. amrwb_param_t amrwb_param;
  385. amrnb_param_t amrnb_param;
  386. } QL_PCM_CONFIG_T;
  387. //EXT PA
  388. typedef void (*cb_on_speakerpa) (uint8 on);
  389. typedef void (*cb_on_receiverpa) (uint8 on);
  390. typedef struct
  391. {
  392. bool spk_pa_start;
  393. bool rcv_pa_start;
  394. cb_on_speakerpa spk_pa_cb;
  395. cb_on_receiverpa rcv_pa_cb;
  396. }ext_pa_info_t;
  397. typedef struct
  398. {
  399. char *file_name;
  400. AudPlayType_e type;
  401. cb_on_player cb;
  402. uint8 reserve[1];
  403. }ql_player_t;
  404. /**********************************************************************************************
  405. API (support local and voice call play, record)
  406. **********************************************************************************************/
  407. /*****************************************************************
  408. * Function: ql_get_audio_state
  409. *
  410. * Description: get audio initial state
  411. *
  412. * Parameters:
  413. *
  414. * Return:
  415. * 1: initial ok
  416. * 0: have not initialed ok, or initial failed
  417. *****************************************************************/
  418. int ql_get_audio_state(void);
  419. /*****************************************************************
  420. * Function: ql_get_file_format
  421. *
  422. * Description: get format of file
  423. *
  424. * Parameters:
  425. * file_name [in] file name
  426. *
  427. * Return:
  428. * AUSTREAM_FORMAT_UNKNOWN : unknown format
  429. * others : file format
  430. *****************************************************************/
  431. AudStreamFormat_e ql_get_file_format(char *file_name);
  432. #ifdef CONFIG_QUEC_PROJECT_FEATURE_DTMF
  433. /*****************************************************************
  434. * Function: ql_aud_dtmf_tone_init
  435. *
  436. * Description: play dtmf/tone init
  437. *
  438. * Parameters:
  439. *
  440. *
  441. * Return:
  442. *
  443. *****************************************************************/
  444. ql_audio_errcode_e ql_aud_dtmf_tone_init(void);
  445. /*****************************************************************
  446. * Function: ql_aud_dtmf_play
  447. *
  448. * Description: play dtmf
  449. *
  450. * Parameters:
  451. * tone: 0-9,*,#,A-D
  452. * duration: play time (ms)
  453. * silence: mute time (ms)
  454. * Return:
  455. *
  456. *****************************************************************/
  457. ql_audio_errcode_e ql_aud_dtmf_play(AUDIO_TONE_TYPE_E tone,unsigned duration,unsigned silence);
  458. /*****************************************************************
  459. * Function: ql_aud_tone_play
  460. *
  461. * Description: play tone
  462. *
  463. * Parameters:
  464. * f1: 1- 15999
  465. * f2: 1- 15999
  466. * duration: play time (ms)
  467. * silence: mute time (ms)
  468. * Return:
  469. *
  470. *****************************************************************/
  471. ql_audio_errcode_e ql_aud_tone_play(int f1, int f2,unsigned duration,unsigned silence);
  472. /*****************************************************************
  473. * Function: ql_aud_tonedtmf_stop
  474. *
  475. * Description: stop play dtmf/tone
  476. *
  477. * Return:
  478. *
  479. *****************************************************************/
  480. ql_audio_errcode_e ql_aud_tone_stop(void);
  481. /*****************************************************************
  482. * Function: ql_aud_tone_detect_set_cb
  483. *
  484. * Description:
  485. *
  486. * Return:
  487. *
  488. *****************************************************************/
  489. ql_audio_errcode_e ql_aud_tone_detect_set_cb(cb_on_tone_detect func);
  490. /*****************************************************************
  491. * Function: ql_aud_tone_detect
  492. *
  493. * Description:
  494. *
  495. * Return:
  496. *
  497. *****************************************************************/
  498. ql_audio_errcode_e ql_aud_tone_detect(bool en);
  499. #endif
  500. /*****************************************************************
  501. * Function: ql_aud_set_volume
  502. *
  503. * Description: set the play volume
  504. *
  505. * Parameters:
  506. * type [in] play type: QL_AUDIO_PLAY_TYPE_LOCAL, QL_AUDIO_PLAY_TYPE_VOICE
  507. * volume [in] play volume, range is 0~AUDIOHAL_SPK_VOL_11
  508. *
  509. * Return:
  510. * 0: successful
  511. * others ql_audio_errcode_e
  512. *****************************************************************/
  513. ql_audio_errcode_e ql_aud_set_volume(AudPlayType_e type, AUDIOHAL_SPK_LEVEL_T volume);
  514. /*****************************************************************
  515. * Function: ql_aud_get_volume
  516. *
  517. * Description: get the play volume
  518. *
  519. * Parameters:
  520. * type [in] play type: QL_AUDIO_PLAY_TYPE_LOCAL, QL_AUDIO_PLAY_TYPE_VOICE
  521. *
  522. * Return:
  523. * volume: play volume(0~AUDIOHAL_SPK_VOL_11)
  524. * others: ql_audio_errcode_e
  525. *****************************************************************/
  526. AUDIOHAL_SPK_LEVEL_T ql_aud_get_volume(AudPlayType_e type);
  527. /*****************************************************************
  528. * Function: ql_aud_enable_pop_delay
  529. *
  530. * Description: enable de-pop function for internal codec. It takes about
  531. 80ms from calling the playback function like ql_aud_play_stream_start
  532. to making a sound, which is used to eliminate pop sound
  533. *
  534. * Parameters:
  535. * enable [in] TRUE for enable, FALSE for disable; default enabled
  536. *
  537. *****************************************************************/
  538. void ql_aud_enable_pop_delay(bool enable);
  539. /*****************************************************************
  540. * Function: ql_aud_play_file_start
  541. *
  542. * Description: play file
  543. *
  544. * Parameters:
  545. * type [in] play type: QL_AUDIO_PLAY_TYPE_LOCAL, QL_AUDIO_PLAY_TYPE_VOICE is valid
  546. * file_name [in] file name, full path required
  547. * play_cb [in] The callback function, will be called at the beginning and end of the play
  548. *
  549. * Return:
  550. * 0: successful
  551. * others: ql_audio_errcode_e
  552. *****************************************************************/
  553. ql_audio_errcode_e ql_aud_play_file_start(char *file_name, AudPlayType_e type, cb_on_player play_cb);
  554. /*****************************************************************
  555. * Function: ql_aud_play_file_start_ex
  556. *
  557. * Description: play file, consumes at least 50K ram more than using ql_aud_play_file_start; it will read more data
  558. from the file each time, and it can avoid jamming when using file system in high-frequency
  559. *
  560. * Parameters:
  561. * config->type [in] play type: QL_AUDIO_PLAY_TYPE_LOCAL, QL_AUDIO_PLAY_TYPE_VOICE is valid
  562. * config->file_name [in] file name, full path required
  563. * config->play_cb [in] The callback function, will be called at the beginning and end of the play
  564. * config->reserve [in] reserved for futher using
  565. *
  566. * Return:
  567. * 0: successful
  568. * others: ql_audio_errcode_e
  569. *****************************************************************/
  570. ql_audio_errcode_e ql_aud_play_file_start_ex(ql_player_t *config);
  571. /*****************************************************************
  572. * Function: ql_aud_play_stream_start
  573. *
  574. * Description: play audio stream data, no more than PACKET_WRITE_MAX_SIZE at a time
  575. *
  576. * Parameters:
  577. * type [in] play type: QL_AUDIO_PLAY_TYPE_LOCAL, QL_AUDIO_PLAY_TYPE_VOICE is valid
  578. * format [in] stream format: wav/mp3/amr/pcm
  579. * play_cb [in] The callback function, will be called at the beginning and end of the play
  580. * buf [in] Audio data address, cannot be released until the end of playback
  581. * size [in] stream size, no more than PACKET_WRITE_MAX_SIZE at a time
  582. *
  583. * Return:
  584. * 0: successful
  585. * others: ql_audio_errcode_e
  586. *****************************************************************/
  587. ql_audio_errcode_e ql_aud_play_stream_start(AudStreamFormat_e format, const void *buf, unsigned size, AudPlayType_e type, cb_on_player play_cb);
  588. /*****************************************************************
  589. * Function: ql_aud_data_done
  590. *
  591. * Description: to tell module that no data need to be write, player will stop after cache empty,
  592. used for stream media, include ql_aud_play_file_start, ql_pcm_write. after use this
  593. api, new data cannot be write to kernel
  594. *
  595. * Parameters:
  596. *
  597. * Return: none
  598. *****************************************************************/
  599. void ql_aud_data_done(void);
  600. /*****************************************************************
  601. * Function: ql_aud_player_pause
  602. *
  603. * Description: play pause, used for all play function
  604. *
  605. * Parameters:
  606. *
  607. * Return:
  608. * 0: successful
  609. * others: ql_audio_errcode_e
  610. *****************************************************************/
  611. ql_audio_errcode_e ql_aud_player_pause(void);
  612. /*****************************************************************
  613. * Function: ql_aud_player_resume
  614. *
  615. * Description: play resume, play pause, used for all play function
  616. *
  617. * Parameters:
  618. *
  619. * Return:
  620. * 0: successful
  621. * others: ql_audio_errcode_e
  622. *****************************************************************/
  623. ql_audio_errcode_e ql_aud_player_resume(void);
  624. /*****************************************************************
  625. * Function: ql_aud_player_stop
  626. *
  627. * Description: Stop playing, this function will release the playing
  628. resource (due to the need to communicate with CP ,It will takes
  629. 50~70ms to execute this function), cannot use it when in interrupt,
  630. and in critiacl
  631. * Attention: this function can stop playing started by "ql_pcm_open", "ql_aud_pcm_open"
  632. * Parameters:
  633. *
  634. * Return:
  635. * 0: successful
  636. * others: ql_audio_errcode_e
  637. *****************************************************************/
  638. ql_audio_errcode_e ql_aud_player_stop(void);
  639. /*****************************************************************
  640. * Function: ql_aud_get_play_state
  641. *
  642. * Description: get current play state, if player has started, can
  643. call ql_aud_get_playing_func for detail
  644. *
  645. * Parameters:
  646. *
  647. * Return:
  648. * AudioStatus_e: play state
  649. * others: ql_audio_errcode_e
  650. *****************************************************************/
  651. AudioStatus_e ql_aud_get_play_state(void);
  652. /*****************************************************************
  653. * Function: ql_aud_get_playing_func
  654. *
  655. * Description: get which function has called player
  656. if called ql_aud_play_file_start and has not called ql_aud_player_stop,
  657. it will return QL_AUDIO_IS_PLAYING_FILE;
  658. if called ql_aud_play_stream_start and has not called ql_aud_player_stop,
  659. it will return QL_AUDIO_IS_PLAYING_STREAM;
  660. if called ql_aud_pcm_open or ql_pcm_open, flag is write, and has not called ql_pcm_close,
  661. it will return QL_AUDIO_IS_PLAYING_PCM
  662. if no audio playing functions has been called, it will return QL_AUDIO_PLAYER_IDLE
  663. *
  664. * Parameters:
  665. *
  666. * Return:
  667. * QL_PLAYING_FUNCTION_E
  668. *****************************************************************/
  669. QL_PLAYING_FUNCTION_E ql_aud_get_playing_func(void);
  670. #ifdef CONFIG_QUEC_PROJECT_FEATURE_AUDIO_RECORD
  671. /*****************************************************************
  672. * Function: ql_set_record_packet_size
  673. *
  674. * Description: Set the packet size read by the recording callback function each time
  675. *
  676. * Parameters:
  677. * packet_size [in] packet size; for amrwb, one packet is 41 bytes; for amrnb, one packet is 21 bytes; for PCM,
  678. * one packet is 320bytes in 8000HZ samprate, is 640 bytes in 16000HZ, is 1280bytes
  679. * in 16000HZ, 2 channels. No more than 1280
  680. *
  681. * Return:
  682. * 0: successful
  683. * others: ql_audio_errcode_e
  684. *****************************************************************/
  685. ql_audio_errcode_e ql_set_record_packet_size(int packet_size);
  686. /*****************************************************************
  687. * Function: ql_aud_record_file_start
  688. *
  689. * Description: record to file
  690. *
  691. * Parameters:
  692. * type [in] record type: QL_REC_TYPE_MIC , QL_REC_TYPE_VOICE
  693. * file_name [in] file name, full path required
  694. * play_cb [in] The callback function, will be called at the beginning and end of the record
  695. * config [in] Recording configuration, default 8K sampling rate, single channel
  696. *
  697. * Return:
  698. * 0: successful
  699. * others: ql_audio_errcode_e
  700. *****************************************************************/
  701. ql_audio_errcode_e ql_aud_record_file_start(char *file_name, ql_aud_config *config, AudRecType_e type, cb_on_record record_cb);
  702. /*****************************************************************
  703. * Function: ql_aud_record_stream_start
  704. *
  705. * Description: record to memory,format is PCM
  706. *
  707. * Parameters:
  708. * type [in] record type: QL_REC_TYPE_MIC , QL_REC_TYPE_VOICE
  709. * play_cb [in] The callback function, will be called at the beginning, end of the record, and data comming
  710. * config [in] Recording configuration, default 8K sampling rate, single channel
  711. *
  712. * Return:
  713. * 0: successful
  714. * others: ql_audio_errcode_e
  715. *****************************************************************/
  716. ql_audio_errcode_e ql_aud_record_stream_start(ql_aud_config *config, AudRecType_e type, cb_on_record record_cb);
  717. /*****************************************************************
  718. * Function: ql_aud_record_stream_start_ex
  719. *
  720. * Description: record to memory, and format need be pointed
  721. *
  722. * Parameters:
  723. * type [in] record type: QL_REC_TYPE_MIC , QL_REC_TYPE_VOICE
  724. * play_cb [in] The callback function, will be called at the beginning, end of the record, and data comming
  725. * config [in] Recording configuration, default 8K sampling rate, single channel
  726. * format [in] record format
  727. *
  728. * Return:
  729. * 0: successful
  730. * others: ql_audio_errcode_e
  731. *****************************************************************/
  732. ql_audio_errcode_e ql_aud_record_stream_start_ex(ql_aud_config *config, AudRecType_e type, AudStreamFormat_e format, cb_on_record record_cb);
  733. /*****************************************************************
  734. * Function: ql_aud_get_record_state
  735. *
  736. * Description: get current record state, can call ql_aud_get_recording_func for detail
  737. *
  738. *
  739. * Return:
  740. AudioStatus_e: state
  741. others: ql_audio_errcode_e
  742. *****************************************************************/
  743. AudioStatus_e ql_aud_get_record_state(void);
  744. /*****************************************************************
  745. * Function: ql_aud_get_recording_func
  746. *
  747. * Description: get which function has called recorder
  748. if called ql_aud_record_file_start and has not called ql_aud_record_stop,
  749. it will return QL_AUDIO_IS_RECORDING_FILE;
  750. if called ql_aud_record_stream_start and has not called ql_aud_player_stop,
  751. it will return QL_AUDIO_IS_RECORDING_STREAM;
  752. if called ql_aud_pcm_open or ql_pcm_open, flag is read, and has not called ql_pcm_close,
  753. it will return QL_AUDIO_IS_RECORDING_PCM
  754. if no audio playing functions has been called, it will return QL_AUDIO_RECORDER_IDLE
  755. *
  756. * Parameters:
  757. *
  758. * Return:
  759. * QL_RECORDING_FUNCTION_E
  760. *****************************************************************/
  761. QL_RECORDING_FUNCTION_E ql_aud_get_recording_func(void);
  762. /*****************************************************************
  763. * Function: ql_aud_recorder_pause
  764. *
  765. * Description: record pause, used for all record function
  766. *
  767. * Parameters:
  768. *
  769. * Return:
  770. * 0: successful
  771. * others: ql_audio_errcode_e
  772. *****************************************************************/
  773. ql_audio_errcode_e ql_aud_recorder_pause(void);
  774. /*****************************************************************
  775. * Function: ql_aud_recorder_resume
  776. *
  777. * Description: resume record, used for all record function
  778. *
  779. * Parameters:
  780. *
  781. * Return:
  782. * 0: successful
  783. * others: ql_audio_errcode_e
  784. *****************************************************************/
  785. ql_audio_errcode_e ql_aud_recorder_resume(void);
  786. /*****************************************************************
  787. * Function: ql_aud_record_stop
  788. *
  789. * Description: Stop recording, this function will release the recording
  790. resource (due to the need to communicate with CP ,It will takes
  791. 50~70ms to execute this function)
  792. *
  793. * Attention: this function cannot stop recording started by "ql_pcm_open", "ql_aud_pcm_open"
  794. *
  795. * Parameters:
  796. *
  797. * Return:
  798. * 0: successful
  799. * others: ql_audio_errcode_e
  800. *****************************************************************/
  801. ql_audio_errcode_e ql_aud_record_stop(void);
  802. /*****************************************************************
  803. * Function: ql_aud_loop_back_start
  804. *
  805. * Description: loop test input device and output device
  806. *
  807. * Parameters:
  808. * out_type [in] output device
  809. * in_type [in] input device
  810. * volume [in] test volume
  811. *
  812. * Return:
  813. * 0: successful
  814. * others: ql_audio_errcode_e
  815. *****************************************************************/
  816. ql_audio_errcode_e ql_aud_loop_back_start(AudOutputType_e out_type, AudInputType_e in_type, AUDIOHAL_SPK_LEVEL_T volume);
  817. /*****************************************************************
  818. * Function: ql_aud_loop_back_stop
  819. *
  820. * Description: stop test loopback
  821. *
  822. * Return:
  823. * 0: successful
  824. * others: ql_audio_errcode_e
  825. *****************************************************************/
  826. ql_audio_errcode_e ql_aud_loop_back_stop(void);
  827. /*****************************************************************
  828. * Function: ql_aud_start_poc_mode
  829. *
  830. * Description: start POC , this mode use the audio param of voice call, like EQ, AGC, volume.
  831. * this function can be used only after recorder and player created together
  832. *
  833. *Parameters:
  834. * poc_type: half-duplex or full-duplex
  835. *
  836. * Return:
  837. * 0: successful
  838. * others: ql_audio_errcode_e
  839. *****************************************************************/
  840. ql_audio_errcode_e ql_aud_start_poc_mode(QL_POC_TYPE_E poc_type);
  841. /*****************************************************************
  842. * Function: ql_aud_poc_switch
  843. *
  844. * Description: switch POC function when in half_duplex mode;
  845. * QL_POC_MODE_REC means only record, and QL_POC_MODE_PLAY
  846. means only play
  847. *
  848. *Parameters:
  849. * mode: QL_POC_MODE_REC or QL_POC_MODE_PLAY
  850. *
  851. * Return:
  852. * 0: successful
  853. * others: ql_audio_errcode_e
  854. *****************************************************************/
  855. ql_audio_errcode_e ql_aud_poc_switch(QL_POC_MODE_E mode);
  856. /*****************************************************************
  857. * Function: ql_aud_stop_poc_mode
  858. *
  859. * Description: stop poc mode
  860. *
  861. * Atttention: users must call "ql_aud_stop_poc_mode" then call "ql_pcm_close", otherwise may leed to some errors
  862. *
  863. * Return:
  864. * 0: successful
  865. * others: ql_audio_errcode_e
  866. *****************************************************************/
  867. ql_audio_errcode_e ql_aud_stop_poc_mode(void);
  868. #endif
  869. /*****************************************************************
  870. * Function: ql_aud_wait_play_finish
  871. *
  872. * Description: Wait for the playback to complete (blocks the current task until the playback is complete)
  873. *
  874. * Parameters:
  875. * timeout [in] waiting timeout
  876. *
  877. * Return:
  878. * 0: successful
  879. * others: ql_audio_errcode_e
  880. *****************************************************************/
  881. ql_audio_errcode_e ql_aud_wait_play_finish(int timeout);
  882. /*****************************************************************
  883. * Function: ql_play_file_start
  884. *
  885. * Description: play file locally
  886. *
  887. * Parameters:
  888. * file_name [in] file name, full path required
  889. *
  890. * Return:
  891. * 0: successful
  892. * others: ql_audio_errcode_e
  893. *****************************************************************/
  894. ql_audio_errcode_e ql_play_file_start(char *file_name);
  895. /*****************************************************************
  896. * Function: ql_play_mp3_stream_start
  897. *
  898. * Description: play audio stream data locally, no more than 3K at a time
  899. *
  900. * Parameters:
  901. * mp3_buff [in] Audio data address, cannot be released until the end of playback
  902. * mp3_size [in] stream size, no more than 3K at a time
  903. *
  904. * Return:
  905. * 0: successful
  906. * others: ql_audio_errcode_e
  907. *****************************************************************/
  908. ql_audio_errcode_e ql_play_mp3_stream_start(unsigned char *mp3_buff, int mp3_size );
  909. /*****************************************************************
  910. * Function: ql_set_volume
  911. *
  912. * Description: set the volume level of local play
  913. *
  914. * Parameters:
  915. * vol [in] volume level
  916. *
  917. * Return:
  918. * 0: successful
  919. * others: ql_audio_errcode_e
  920. *****************************************************************/
  921. ql_audio_errcode_e ql_set_volume(AUDIOHAL_SPK_LEVEL_T vol);
  922. //删除以前的ql_set_volume_ex接口,当前频繁设置音量不会再造成音频卡顿
  923. #define ql_set_volume_ex(vol,delay) ql_set_volume(vol)
  924. /*****************************************************************
  925. * Function: ql_get_volume
  926. *
  927. * Description: Gets the volume level of local play
  928. *
  929. * Return:
  930. * 0~11: volume level
  931. * others: ql_audio_errcode_e
  932. *****************************************************************/
  933. AUDIOHAL_SPK_LEVEL_T ql_get_volume(void);
  934. /*****************************************************************
  935. * Function: ql_aud_get_output_type
  936. *
  937. * Description: get output path, speaker, earphone, or receiver
  938. *
  939. * Return:
  940. * AudOutputType_e
  941. ****************************************************************/
  942. AudOutputType_e ql_aud_get_output_type(void);
  943. /*****************************************************************
  944. * Function: ql_aud_get_input_type
  945. *
  946. * Description: get input path, main mic, HPL, ....
  947. *
  948. * Return:
  949. * AudInputType_e
  950. ****************************************************************/
  951. AudInputType_e ql_aud_get_input_type(void);
  952. /*****************************************************************
  953. * Function: ql_aud_set_output_type
  954. *
  955. * Description: set output path to speaker, earphone, or receiver
  956. * Parameters:
  957. * output_type [in] output path, speaker, earphone, or receiver
  958. * Return:
  959. * ql_audio_errcode_e
  960. ****************************************************************/
  961. ql_audio_errcode_e ql_aud_set_output_type(AudOutputType_e output_type);
  962. /*****************************************************************
  963. * Function: ql_aud_set_input_type
  964. *
  965. * Description: set input path, main mic, HPL, ....
  966. * Parameters:
  967. * output_type [in] input path, main mic, HPL, ....
  968. * Return:
  969. * ql_audio_errcode_e
  970. ****************************************************************/
  971. ql_audio_errcode_e ql_aud_set_input_type(AudInputType_e input_type);
  972. /*****************************************************************
  973. * Function: ql_set_audio_path_receiver
  974. *
  975. * Description: set output mode to receiver, input type
  976. to main mic
  977. *
  978. * Return:
  979. * 0: successful
  980. * others: ql_audio_errcode_e
  981. *****************************************************************/
  982. ql_audio_errcode_e ql_set_audio_path_receiver(void);
  983. /*****************************************************************
  984. * Function: ql_set_audio_path_earphone
  985. *
  986. * Description: set output mode to earphone, input type
  987. to main HPL mic
  988. *
  989. * Return:
  990. * 0: successful
  991. * others: ql_audio_errcode_e
  992. *****************************************************************/
  993. ql_audio_errcode_e ql_set_audio_path_earphone(void);
  994. /*****************************************************************
  995. * Function: ql_set_audio_path_speaker
  996. *
  997. * Description: set output mode to loud speaker, input type
  998. to main mic
  999. *
  1000. * Return:
  1001. * 0: successful
  1002. * others: ql_audio_errcode_e
  1003. *****************************************************************/
  1004. ql_audio_errcode_e ql_set_audio_path_speaker(void);
  1005. /*****************************************************************
  1006. * Function: ql_play_file_stop
  1007. *
  1008. * Description: stop play file
  1009. *
  1010. * Return:
  1011. * 0: successful
  1012. * others: ql_audio_errcode_e
  1013. *****************************************************************/
  1014. ql_audio_errcode_e ql_play_file_stop(void);
  1015. /*****************************************************************
  1016. * Function: ql_aud_pcm_open
  1017. *
  1018. * Description: Enable local play/recording, format can be amr, wav, mp3, pcm
  1019. *
  1020. * Parameters:
  1021. * config [in] play/record configuration
  1022. * flags
  1023. QL_PCM_BLOCK_FLAG (0x01): block
  1024. QL_PCM_NONBLOCK_FLAG (0x02): not block
  1025. QL_PCM_READ_FLAG (0x04): record
  1026. QL_PCM_WRITE_FLAG (0x08): play
  1027. *
  1028. * notice: in read mode, it will start record after ql_aud_pcm_open!!!
  1029. *
  1030. * Return:
  1031. * NULL: failed
  1032. * others: PCM handler
  1033. *****************************************************************/
  1034. PCM_HANDLE_T ql_aud_pcm_open(QL_PCM_CONFIG_T *config, AudStreamFormat_e format, unsigned int flags, pcm_path_e type);
  1035. /*****************************************************************
  1036. * Function: ql_pcm_open
  1037. *
  1038. * Description: Enable local play/recording, format is PCM
  1039. *
  1040. * Parameters:
  1041. * config [in] play/record configuration
  1042. * flags
  1043. QL_PCM_BLOCK_FLAG (0x01): block
  1044. QL_PCM_NONBLOCK_FLAG (0x02): not block
  1045. QL_PCM_READ_FLAG (0x04): record
  1046. QL_PCM_WRITE_FLAG (0x08): play
  1047. *
  1048. * notice: in read mode, it will start record after ql_pcm_open!!!
  1049. *
  1050. * Return:
  1051. * NULL: failed
  1052. * others: PCM handler
  1053. *****************************************************************/
  1054. PCM_HANDLE_T ql_pcm_open(QL_PCM_CONFIG_T *config, unsigned int flags);
  1055. /*****************************************************************
  1056. * Function: ql_pcm_write
  1057. *
  1058. * Description: play data of pcm format locally, no more than PACKET_WRITE_MAX_SIZE at a time
  1059. *
  1060. * Parameters:
  1061. * handle [in] PCM handler,get by ql_pcm_open, or ql_aud_pcm_open
  1062. * data [in] PCM data address, cannot be released until the end of playback
  1063. * count [in] data size, no more than PACKET_WRITE_MAX_SIZE at a time
  1064. *
  1065. * Return:
  1066. * >0: actual write size
  1067. * others: ql_audio_errcode_e
  1068. *****************************************************************/
  1069. int ql_pcm_write(PCM_HANDLE_T handle, void *data, unsigned int count);
  1070. /*****************************************************************
  1071. * Function: ql_pcm_read
  1072. *
  1073. * Description: get recording data locally
  1074. *
  1075. * Parameters:
  1076. * handle [in] PCM handler,get by ql_pcm_open, or ql_aud_pcm_open
  1077. * data [in] PCM data address, cannot be released until the end of playback
  1078. * count [in] data size
  1079. * Return:
  1080. * >0: actual read size
  1081. * others: ql_audio_errcode_e
  1082. *****************************************************************/
  1083. int ql_pcm_read(PCM_HANDLE_T handle, void *data, unsigned int count);
  1084. /*****************************************************************
  1085. * Function: ql_pcm_close
  1086. *
  1087. * Description: close pcm record/play
  1088. *
  1089. * Parameters:
  1090. * handle [in] PCM handler, get by ql_pcm_open
  1091. *
  1092. * Return:
  1093. * 0: successful
  1094. * others: ql_audio_errcode_e
  1095. *****************************************************************/
  1096. int ql_pcm_close(PCM_HANDLE_T handle);
  1097. /*****************************************************************
  1098. * Function: ql_pcm_buffer_reset
  1099. *
  1100. * Description: reset the pcm record/play buffer
  1101. *
  1102. * Parameters:
  1103. * handle [in] PCM handler,get by ql_pcm_open or ql_aud_pcm_open
  1104. * Return:
  1105. * =0: success
  1106. * others: ql_audio_errcode_e
  1107. *****************************************************************/
  1108. ql_audio_errcode_e ql_pcm_buffer_reset(PCM_HANDLE_T handle);
  1109. /*****************************************************************
  1110. * Function: ql_pcm_buffer_used
  1111. *
  1112. * Description: get the size that buffer used
  1113. *
  1114. * Parameters:
  1115. * handle [in] PCM handler,get by ql_pcm_open or ql_aud_pcm_open
  1116. * Return:
  1117. * >=0: used size
  1118. * <0: error
  1119. *****************************************************************/
  1120. int ql_pcm_buffer_used(PCM_HANDLE_T handle);
  1121. /*****************************************************************
  1122. * Function: ql_amr_stream_write
  1123. *
  1124. * Description: play amr stream locally, no more than 3K at a time
  1125. *
  1126. * Parameters:
  1127. * data [in] amr data address, cannot be released until the end of playback
  1128. * count [in] stream size, no more than 3K at a time
  1129. *
  1130. * Return:
  1131. * 0: successful
  1132. * others: ql_audio_errcode_e
  1133. *****************************************************************/
  1134. ql_audio_errcode_e ql_amr_stream_write(void *data, unsigned int count);
  1135. /*****************************************************************
  1136. * Function: ql_amr_stream_close
  1137. *
  1138. * Description: close amr play, and release play resource
  1139. *
  1140. * Return:
  1141. * 0: successful
  1142. * others: ql_audio_errcode_e
  1143. *****************************************************************/
  1144. ql_audio_errcode_e ql_amr_stream_close(void);
  1145. /*****************************************************************
  1146. * Function: ql_amr_file_start
  1147. *
  1148. * Description: play amr file locally
  1149. *
  1150. * Parameters:
  1151. * file_name [in] file name, full path required
  1152. * play_cb [in] The callback function, will be called at the beginning and end of the play
  1153. *
  1154. * Return:
  1155. * 0: successful
  1156. * others: ql_audio_errcode_e
  1157. *****************************************************************/
  1158. ql_audio_errcode_e ql_amr_file_start(char *file_name, cb_on_player aud_cb);
  1159. /*****************************************************************
  1160. * Function: ql_amr_file_pause
  1161. *
  1162. * Description: pause or resume amr player
  1163. *
  1164. * Parameters:
  1165. * pause [in] 1 for pause, 0 for resume
  1166. *
  1167. * Return:
  1168. * 0: successful
  1169. * others: ql_audio_errcode_e
  1170. *****************************************************************/
  1171. ql_audio_errcode_e ql_amr_file_pause(bool pause);
  1172. /*****************************************************************
  1173. * Function: ql_amr_file_end
  1174. *
  1175. * Description: end amr player
  1176. *
  1177. * Return:
  1178. * 0: successful
  1179. * others: ql_audio_errcode_e
  1180. *****************************************************************/
  1181. ql_audio_errcode_e ql_amr_file_end(void);
  1182. /*****************************************************************
  1183. * Function: ql_bind_speakerpa_cb
  1184. *
  1185. * Description: set the external pa callback of speaker path, only for
  1186. external PA to avoid POP noise. when player start and stoped,and play
  1187. path is speaker, kernal will call the callback to notify users to turn
  1188. on or turn off external pa
  1189. *
  1190. *****************************************************************/
  1191. void ql_bind_speakerpa_cb(cb_on_speakerpa cb);
  1192. /*****************************************************************
  1193. * Function: ql_bind_receiverpa_cb
  1194. *
  1195. * Description: set the external pa callback of receiver path, only for
  1196. external PA to avoid POP noise. when player start and stoped, and play
  1197. path is receiver, kernal will call the callback to notify users to turn
  1198. on or turn off external pa
  1199. *
  1200. *****************************************************************/
  1201. void ql_bind_receiverpa_cb(cb_on_receiverpa cb);
  1202. #ifdef CONFIG_QUEC_PROJECT_FEATURE_USB_AUDIO
  1203. /*****************************************************************
  1204. * Function: ql_aud_uac_enable
  1205. *
  1206. * Description: to enable usb audio class 1.0, reset to be effective
  1207. *
  1208. *Parameters:
  1209. * enable : whether to enable uac, 1 for enable, 0 for disable
  1210. *
  1211. *
  1212. * Return:
  1213. * 0: successful
  1214. * others: ql_errcode_usb_e
  1215. *****************************************************************/
  1216. #define ql_aud_uac_enable(enable) \
  1217. (enable ? ql_usb_set_enum_mode(QL_USB_ENUM_USBNET_COM_UAC) : \
  1218. ql_usb_set_enum_mode(QL_USB_ENUM_USBNET_COM))
  1219. /*****************************************************************
  1220. * Function: ql_aud_uac_is_enabled
  1221. *
  1222. * Description: whether the uac is enabled
  1223. *
  1224. * Return:
  1225. * 0: uac was disabled
  1226. * 1: uac was enabled
  1227. *****************************************************************/
  1228. #define ql_aud_uac_is_enabled() \
  1229. (ql_usb_get_enum_mode() == QL_USB_ENUM_USBNET_COM_UAC ? TRUE : FALSE)
  1230. #endif
  1231. /*****************************************************************
  1232. * Function: ql_bind_ring_tone_cbbind
  1233. *
  1234. * Description: ring tone callback, when call is comming and released,
  1235. the callback will be run if ring tone type was defined as
  1236. customer-def
  1237. *
  1238. *Parameters:
  1239. * cb: callbacK, cannot be NULL
  1240. *
  1241. * Return:
  1242. * 0: successful
  1243. * others: ql_audio_errcode_e
  1244. *****************************************************************/
  1245. #ifdef CONFIG_QUEC_PROJECT_FEATURE_VOICE_CALL
  1246. #ifdef CONFIG_QL_OPEN_EXPORT_PKG
  1247. ql_audio_errcode_e ql_bind_ring_tone_cb(cb_on_ring_tone cb);
  1248. #endif
  1249. /*****************************************************************
  1250. * Function: ql_aud_get_ringtone_type
  1251. *
  1252. * Description: get ring tone type when call is comming
  1253. *
  1254. * Return:
  1255. QL_AUD_RING_TYPE_E
  1256. *****************************************************************/
  1257. QL_AUD_RING_TYPE_E ql_aud_get_ringtone_type(void);
  1258. /*****************************************************************
  1259. * Function: ql_aud_set_ringtone_type
  1260. *
  1261. * Description: set ring tone type, to control the ring tone type when
  1262. voice call is comming
  1263. *
  1264. *Parameters:
  1265. *type:
  1266. QL_AUD_RING_NONE : no ring tone
  1267. QL_AUD_RING_NOKIA : invalid now, can use QL_AUD_RING_CUSTOMER_DEF
  1268. QL_AUD_RING_DIAL_TONE : DTMF tone, controled by system
  1269. QL_AUD_RING_CUSTOMER_DEF : play ring tone by customer; can use ql_bind_ring_tone_cb
  1270. to bind callback, when call is comming or released, the
  1271. callback will be called, users can send event to task to play
  1272. music
  1273. Attention: when use QL_AUD_RING_CUSTOMER_DEF, don't play music in callback directly!!!
  1274. * Return:
  1275. * 0: successful
  1276. * others: ql_audio_errcode_e
  1277. *****************************************************************/
  1278. ql_audio_errcode_e ql_aud_set_ringtone_type(QL_AUD_RING_TYPE_E type);
  1279. #endif
  1280. /*****************************************************************
  1281. * Function: ql_aud_set_adc_gain
  1282. *
  1283. * Description: set codec adc gain
  1284. *
  1285. *Parameters:
  1286. * adc_cfg: QL_ADC_GAIN_E gain level
  1287. *
  1288. * Return:
  1289. * 0: successful
  1290. * others: ql_audio_errcode_e
  1291. *****************************************************************/
  1292. ql_audio_errcode_e ql_aud_set_adc_gain(ql_aud_adc_cfg * adc_cfg);
  1293. /*****************************************************************
  1294. * Function: ql_aud_get_adc_gain
  1295. *
  1296. * Description: get codec adc gain
  1297. *
  1298. *Parameters:
  1299. * adc_cfg: QL_ADC_GAIN_E gain level
  1300. *
  1301. * Return:
  1302. * 0: successful
  1303. * others: ql_audio_errcode_e
  1304. *****************************************************************/
  1305. ql_audio_errcode_e ql_aud_get_adc_gain(ql_aud_adc_cfg * adc_cfg);
  1306. /*****************************************************************
  1307. * Function: ql_aud_set_dac_gain
  1308. *
  1309. * Description: set codec dac gain
  1310. *
  1311. *Parameters:
  1312. * dac_cfg: dac_gain value:0-0xff
  1313. *
  1314. * Return:
  1315. * 0: successful
  1316. * others: ql_audio_errcode_e
  1317. *****************************************************************/
  1318. ql_audio_errcode_e ql_aud_set_dac_gain(ql_aud_dac_cfg * dac_cfg);
  1319. /*****************************************************************
  1320. * Function: ql_aud_get_dac_gain
  1321. *
  1322. * Description: get codec dac gain
  1323. *
  1324. *Parameters:
  1325. * dac_cfg: dac_gain value:0-0xff
  1326. *
  1327. * Return:
  1328. * 0: successful
  1329. * others: ql_audio_errcode_e
  1330. *****************************************************************/
  1331. ql_audio_errcode_e ql_aud_get_dac_gain(ql_aud_dac_cfg * dac_cfg);
  1332. #ifdef CONFIG_QUEC_PROJECT_FEATURE_EXT_CODEC
  1333. /*****************************************************************
  1334. * Function: ql_audio_iic_write
  1335. *
  1336. * Description: write register data to codec
  1337. *
  1338. *Parameters:
  1339. * dev_addr: iic slave addr, for alc5616 is 0x1B
  1340. * reg_addr: codec register addr
  1341. * size: data size, for 16 bit register is 2, for 8bit register is 1
  1342. * val: data to be write
  1343. *
  1344. * Return:
  1345. * 0: successful
  1346. * others: ql_audio_errcode_e
  1347. *****************************************************************/
  1348. ql_audio_errcode_e ql_audio_iic_write(uint8 dev_addr, uint16 reg_addr, uint8 size, uint16 val);
  1349. /*****************************************************************
  1350. * Function: ql_audio_iic_read
  1351. *
  1352. * Description: read register data from codec
  1353. *
  1354. *Parameters:
  1355. * dev_addr: iic slave addr, for alc5616 is 0x1B
  1356. * reg_addr: codec register addr
  1357. * size: data size, for 16 bit register is 2, for 8bit register is 1
  1358. * val: data to be read
  1359. *
  1360. * Return:
  1361. * 0: successful
  1362. * others: ql_audio_errcode_e
  1363. *****************************************************************/
  1364. ql_audio_errcode_e ql_audio_iic_read(uint8 dev_addr, uint16 reg_addr, uint8 size, uint16 *p_val);
  1365. /*****************************************************************
  1366. * Function: ql_aud_ext_codec_cfg
  1367. *
  1368. * Description: set callback and other configuration for external codec
  1369. *
  1370. *Parameters:
  1371. *
  1372. * Return:
  1373. * 0: successful
  1374. * others: ql_audio_errcode_e
  1375. *****************************************************************/
  1376. ql_audio_errcode_e ql_aud_ext_codec_cfg(ql_extcodec_info_t * extcodec_info);
  1377. /*****************************************************************
  1378. * Function: ql_aud_get_ext_codec_cfg
  1379. *
  1380. * Description: get the current configuration of external codec
  1381. *
  1382. *Parameters:
  1383. *
  1384. * Return:
  1385. * 0: successful
  1386. * others: ql_audio_errcode_e
  1387. *****************************************************************/
  1388. ql_audio_errcode_e ql_aud_get_ext_codec_cfg(ql_extcodec_info_t *codec_cfg);
  1389. #endif
  1390. #ifdef __cplusplus
  1391. } /*"C" */
  1392. #endif
  1393. #endif