drivers/audio/es8388: Add input support

This commit is contained in:
Lucas Saavedra Vaz 2023-03-16 22:54:34 -03:00 committed by Alan Carvalho de Assis
parent 64e7e43f1f
commit 326261dd7d
4 changed files with 374 additions and 186 deletions

View File

@ -210,6 +210,7 @@ config AUDIO_ES8388
bool "ES8388 codec chip"
default n
depends on AUDIO
select AUDIO_DRIVER_SPECIFIC_BUFFERS
---help---
Select to enable support for the ES8388 Audio codec by Everest
Semiconductor.
@ -223,10 +224,62 @@ config ES8388_INPUT_INITVOLUME
int "ES8388 initial input volume setting"
default 1000
config ES8388_OUTPUT_CHANNEL
int
default 0 if ES8388_OUTPUT_CHANNEL_LINE1
default 1 if ES8388_OUTPUT_CHANNEL_LINE2
default 2 if ES8388_OUTPUT_CHANNEL_ALL
choice
prompt "ES8388 output channel"
default ES8388_OUTPUT_CHANNEL_ALL
---help---
Select the codec channel that will output audio.
The actual device that will reproduce the audio signal depends
on the board implementation.
config ES8388_OUTPUT_CHANNEL_LINE1
bool "Line 1"
config ES8388_OUTPUT_CHANNEL_LINE2
bool "Line 2"
config ES8388_OUTPUT_CHANNEL_ALL
bool "Both"
endchoice
config ES8388_OUTPUT_INITVOLUME
int "ES8388 initial output volume setting"
default 400
config ES8388_INPUT_CHANNEL
int
default 0 if ES8388_INPUT_CHANNEL_LINE1
default 1 if ES8388_INPUT_CHANNEL_LINE2
default 3 if ES8388_INPUT_CHANNEL_DIFFERENTIAL
choice
prompt "ES8388 input channel"
default ES8388_INPUT_CHANNEL_LINE1
---help---
Select the codec channel that will input audio.
The actual device that will reproduce the audio signal depends
on the board implementation.
The "Differential" option will take the difference between the Line 1
left and right channels.
config ES8388_INPUT_CHANNEL_LINE1
bool "Line 1"
config ES8388_INPUT_CHANNEL_LINE2
bool "Line 2"
config ES8388_INPUT_CHANNEL_DIFFERENTIAL
bool "Differential"
endchoice
config ES8388_INFLIGHT
int "ES8388 maximum in-flight audio buffers"
default 2

File diff suppressed because it is too large Load Diff

View File

@ -1072,10 +1072,10 @@ struct es8388_dev_s
FAR const struct es8388_lower_s *lower; /* Pointer to the board lower functions */
FAR struct i2c_master_s *i2c; /* I2C driver to use */
FAR struct i2s_dev_s *i2s; /* I2S driver to use */
struct dq_queue_s pendq; /* Queue of pending buffers to be sent */
struct dq_queue_s pendq; /* Queue of pending buffers to be processed */
struct dq_queue_s doneq; /* Queue of sent buffers to be returned */
struct file mq; /* Message queue for receiving messages */
char mqname[16]; /* Our message queue name */
char mqname[NAME_MAX]; /* Our message queue name */
pthread_t threadid; /* ID of our thread */
uint32_t bitrate; /* Actual programmed bit rate */
mutex_t pendlock; /* Protect pendq */
@ -1084,7 +1084,8 @@ struct es8388_dev_s
#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
uint16_t balance; /* Current balance level {0..1000} */
#endif /* CONFIG_AUDIO_EXCLUDE_BALANCE */
uint16_t volume; /* Current volume level {0..1000} */
uint16_t volume_out; /* Current output volume level {0..1000} */
uint16_t volume_in; /* Current input volume level {0..1000} */
#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
uint8_t nchannels; /* Number of channels (1 or 2) */
uint8_t bpsamp; /* Bits per sample */
@ -1100,6 +1101,7 @@ struct es8388_dev_s
es8388_module_t audio_mode; /* The current audio mode of the ES8388 chip */
es8388_dac_output_t dac_output; /* The current output of the ES8388 DAC */
es8388_adc_input_t adc_input; /* The current input of the ES8388 ADC */
es8388_mic_gain_t mic_gain; /* The current microphone gain */
uint32_t mclk; /* The current MCLK frequency */
};

View File

@ -240,9 +240,7 @@
*/
#define AUDIO_VOLUME_MAX 1000
#define AUDIO_VOLUME_MAX_FLOAT 1000.0f
#define AUDIO_VOLUME_MIN 0
#define AUDIO_VOLUME_MIN_FLOAT 0.0f
/* Audio Balance Limits *****************************************************/
@ -252,11 +250,8 @@
*/
#define AUDIO_BALANCE_RIGHT 1000
#define AUDIO_BALANCE_RIGHT_FLOAT 1000.0f
#define AUDIO_BALANCE_CENTER 500
#define AUDIO_BALANCE_CENTER_FLOAT 500.0f
#define AUDIO_BALANCE_LEFT 0
#define AUDIO_BALANCE_LEFT_FLOAT 0.0f
/* Supported Feature Units controls *****************************************/