Page 1 of 1

Help with Ai-Thinker ESP32-A1S Audio Kit

Posted: Fri Feb 14, 2020 5:20 pm
by adrianrb
Hi all!
First THANK YOU for ESP32, IDF and ADF... Fantastic work!
I´ve this board (v2.2 - 2 mics - not 4), and managed to make it work OK from mics (stereo mode: left mic -> left speaker/earphone; right mic -> right speaker/earphone).
But no way to make LINEIN input work... never!
Changed audio_hal_codec_mode_t to AUDIO_HAL_CODEC_MODE_LINE_IN and nothing happens.
Any ideas?

Adrian

Re: Help with Ai-Thinker ESP32-A1S Audio Kit

Posted: Sat Feb 15, 2020 8:44 pm
by shabtronic
probably the mixer line-in routing isn't setup properly.

You'll need to read the AC101 codec data sheet and bodge in some functionality to do that.

http://www.x-powers.com/en.php/Info/down/id/96

I'd would code this up - but I no longer have my A1S boards for a short while :(

Seeed has some example AC101 code - maybe it'll help you roll some code?

https://github.com/respeaker/seeed-voic ... er/ac101.c

Re: Help with Ai-Thinker ESP32-A1S Audio Kit

Posted: Sun May 17, 2020 2:59 pm
by rabarar
Adrian,

Did you ever get a solution to make LINEIN work? I'm looking for a similar solution.

Best,
Rob

Re: Help with Ai-Thinker ESP32-A1S Audio Kit

Posted: Sun May 17, 2020 4:15 pm
by rabarar
Adrian,

I took a look at the code, and figured out how to make it work - so the short answer is you need to modify the ac101 codec init function - the HAL doesn't expose the necessary interfaces to control the register writing for the source selection - I downloaded the data sheet for the AC101 Codec and found the values for register 0x51 and 0x54 - here's the mods that I made:

i conditionally compiled it
in components/audio_hal/driver/ac101/ac101.c in ac101_init(audio_hal_codec_config_t *codec_cfg) modify the two register writes...

Code: Select all

 #ifndef USE_LINEIN
     res |= ac101_write_reg(ADC_SRC, 0x2020);
#else
     ESP_LOGI(TAG, "[ ROB ] ADC_SRC linein L/R");
     res |= ac101_write_reg(ADC_SRC, 0x0810);
#endif

Code: Select all

#ifndef USE_LINEIN
    res |= ac101_write_reg(OMIXER_SR, 0x0081);
#else
    ESP_LOGI(TAG, "[ ROB ] OMIXER_SR linein L/R");
     res |= ac101_write_reg(OMIXER_SR, 0x0810);
#endif
Hope that helps!

Rob