1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef __UVOICE_PCM_H__ 6 #define __UVOICE_PCM_H__ 7 8 9 /* 10 * Set volume. 11 * 12 * Return: 13 * 0 -- success or unsupport 14 * -1 -- failed 15 */ 16 int uvoice_set_volume(snd_device_t device, int volume); 17 18 19 /* 20 * Select audio output/input device, return 0 if device switch unsupported. 21 * 22 * Return: 23 * 0 -- success or unsupport 24 * -1 -- failed 25 */ 26 int uvoice_set_path(struct pcm_device *pcm, snd_device_t device); 27 28 29 /* 30 * Configure external pa info if used. 31 * 32 * Return: 33 * 0 -- success or no external pa 34 * -1 -- failed 35 */ 36 int uvoice_extpa_config(struct external_pa_info *info); 37 38 39 /* 40 * Mute audio output/input. 41 * 42 * Return: 43 * 0 -- success or unsupport 44 * -1 -- failed 45 */ 46 int uvoice_dev_mute(struct pcm_device *pcm, snd_device_t device, int mute); 47 48 /* 49 * Called by audio driver to post some message if necessary. 50 */ 51 void uvoice_pcm_notify(pcm_message_t msg); 52 53 /* 54 * Update default pcm params to adapt custom hardware. 55 * you can set write/read buffer length by configure 56 * pcm->config.period_size 57 * 58 * Return: 59 * 0 -- success 60 * -1 -- failed 61 */ 62 int uvoice_pcm_setup(struct pcm_device *pcm); 63 64 /* 65 * Open pcm device with configured pcm. 66 * 67 * Return: 68 * 0 -- success 69 * -1 -- failed 70 */ 71 int uvoice_pcm_open(struct pcm_device *pcm); 72 73 /* 74 * Read data in. Block reading if data not ready. 75 * 76 * Return read length, or negative if failed. 77 */ 78 int uvoice_pcm_read(struct pcm_device *pcm, uint8_t *buffer, int nbytes); 79 80 /* 81 * Block write if free dma buffer not ready, otherwise, 82 * please return after copied. 83 * 84 * Return writen length, or negative if failed. 85 * 86 */ 87 int uvoice_pcm_write(struct pcm_device *pcm, uint8_t *buffer, int nbytes); 88 89 int uvoice_pcm_silence(struct pcm_device *pcm); 90 91 /* 92 * Flush remaining data in dma buffer 93 */ 94 int uvoice_pcm_flush(struct pcm_device *pcm); 95 96 /* 97 * close pcm device, release dma 98 * 99 * Return: 100 * 0 -- success 101 * -1 -- failed 102 * 103 */ 104 int uvoice_pcm_close(struct pcm_device *pcm); 105 106 /* 107 * Init pcm module 108 * 109 * Return: 110 * 0 -- success 111 * -1 -- failed 112 * 113 */ 114 int uvoice_pcm_init(void); 115 116 #endif 117