move to new cspot

This commit is contained in:
philippe44
2023-03-25 16:48:41 -07:00
parent c712b78931
commit 008c36facf
2983 changed files with 465270 additions and 13569 deletions

View File

@@ -0,0 +1,26 @@
#ifndef AC101AUDIOSINK_H
#define AC101AUDIOSINK_H
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
#include "ac101.h"
#include "adac.h"
class AC101AudioSink : public BufferedAudioSink
{
public:
AC101AudioSink();
~AC101AudioSink();
void volumeChanged(uint16_t volume);
private:
adac_s *dac;
};
#endif

View File

@@ -0,0 +1,25 @@
#ifndef BUFFEREDAUDIOSINK_H
#define BUFFEREDAUDIOSINK_H
#include <vector>
#include <iostream>
#include "AudioSink.h"
#include <stdio.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
class BufferedAudioSink : public AudioSink
{
public:
void feedPCMFrames(const uint8_t *buffer, size_t bytes) override;
bool setParams(uint32_t sampleRate, uint8_t channelCount, uint8_t bitDepth) override;
protected:
void startI2sFeed(size_t buf_size = 4096 * 8);
void feedPCMFramesInternal(const void *pvItem, size_t xItemSize);
private:
};
#endif

View File

@@ -0,0 +1,28 @@
#ifndef ES8311AUDIOSINK_H
#define ES8311AUDIOSINK_H
#include "driver/i2s.h"
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include "driver/gpio.h"
#include "driver/i2c.h"
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
class ES8311AudioSink : public BufferedAudioSink
{
public:
ES8311AudioSink();
~ES8311AudioSink();
void writeReg(uint8_t reg_add, uint8_t data);
void volumeChanged(uint16_t volume);
void setSampleRate(uint32_t sampleRate);
private:
};
#endif

View File

@@ -0,0 +1,105 @@
#ifndef ES8388AUDIOSINK_H
#define ES8388AUDIOSINK_H
#include "driver/i2s.h"
#include <driver/i2c.h>
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
#define ES8388_ADDR 0x20
#define ACK_CHECK_EN 0x1
/* ES8388 register */
#define ES8388_CONTROL1 0x00
#define ES8388_CONTROL2 0x01
#define ES8388_CHIPPOWER 0x02
#define ES8388_ADCPOWER 0x03
#define ES8388_DACPOWER 0x04
#define ES8388_CHIPLOPOW1 0x05
#define ES8388_CHIPLOPOW2 0x06
#define ES8388_ANAVOLMANAG 0x07
#define ES8388_MASTERMODE 0x08
/* ADC */
#define ES8388_ADCCONTROL1 0x09
#define ES8388_ADCCONTROL2 0x0a
#define ES8388_ADCCONTROL3 0x0b
#define ES8388_ADCCONTROL4 0x0c
#define ES8388_ADCCONTROL5 0x0d
#define ES8388_ADCCONTROL6 0x0e
#define ES8388_ADCCONTROL7 0x0f
#define ES8388_ADCCONTROL8 0x10
#define ES8388_ADCCONTROL9 0x11
#define ES8388_ADCCONTROL10 0x12
#define ES8388_ADCCONTROL11 0x13
#define ES8388_ADCCONTROL12 0x14
#define ES8388_ADCCONTROL13 0x15
#define ES8388_ADCCONTROL14 0x16
/* DAC */
#define ES8388_DACCONTROL1 0x17
#define ES8388_DACCONTROL2 0x18
#define ES8388_DACCONTROL3 0x19
#define ES8388_DACCONTROL4 0x1a
#define ES8388_DACCONTROL5 0x1b
#define ES8388_DACCONTROL6 0x1c
#define ES8388_DACCONTROL7 0x1d
#define ES8388_DACCONTROL8 0x1e
#define ES8388_DACCONTROL9 0x1f
#define ES8388_DACCONTROL10 0x20
#define ES8388_DACCONTROL11 0x21
#define ES8388_DACCONTROL12 0x22
#define ES8388_DACCONTROL13 0x23
#define ES8388_DACCONTROL14 0x24
#define ES8388_DACCONTROL15 0x25
#define ES8388_DACCONTROL16 0x26
#define ES8388_DACCONTROL17 0x27
#define ES8388_DACCONTROL18 0x28
#define ES8388_DACCONTROL19 0x29
#define ES8388_DACCONTROL20 0x2a
#define ES8388_DACCONTROL21 0x2b
#define ES8388_DACCONTROL22 0x2c
#define ES8388_DACCONTROL23 0x2d
#define ES8388_DACCONTROL24 0x2e
#define ES8388_DACCONTROL25 0x2f
#define ES8388_DACCONTROL26 0x30
#define ES8388_DACCONTROL27 0x31
#define ES8388_DACCONTROL28 0x32
#define ES8388_DACCONTROL29 0x33
#define ES8388_DACCONTROL30 0x34
class ES8388AudioSink : public BufferedAudioSink
{
public:
ES8388AudioSink();
~ES8388AudioSink();
bool begin(int sda = -1, int scl = -1, uint32_t frequency = 400000U);
enum ES8388_OUT
{
ES_MAIN, // this is the DAC output volume (both outputs)
ES_OUT1, // this is the additional gain for OUT1
ES_OUT2 // this is the additional gain for OUT2
};
void mute(const ES8388_OUT out, const bool muted);
void volume(const ES8388_OUT out, const uint8_t vol);
void writeReg(uint8_t reg_add, uint8_t data);
private:
i2c_config_t i2c_config;
i2c_port_t i2c_port = 0;
};
#endif

View File

@@ -0,0 +1,22 @@
#ifndef ES9018AUDIOSINK_H
#define ES9018AUDIOSINK_H
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
class ES9018AudioSink : public BufferedAudioSink
{
public:
ES9018AudioSink();
~ES9018AudioSink();
private:
};
#endif

View File

@@ -0,0 +1,22 @@
#ifndef INTERNALAUDIOSINK_H
#define INTERNALAUDIOSINK_H
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
class InternalAudioSink : public BufferedAudioSink
{
public:
InternalAudioSink();
~InternalAudioSink();
private:
};
#endif

View File

@@ -0,0 +1,22 @@
#ifndef PCM5102AUDIOSINK_H
#define PCM5102AUDIOSINK_H
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
class PCM5102AudioSink : public BufferedAudioSink
{
public:
PCM5102AudioSink();
~PCM5102AudioSink();
private:
};
#endif

View File

@@ -0,0 +1,26 @@
#ifndef SPDIFAUDIOSINK_H
#define SPDIFAUDIOSINK_H
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
class SPDIFAudioSink : public BufferedAudioSink
{
private:
uint8_t spdifPin;
public:
explicit SPDIFAudioSink(uint8_t spdifPin);
~SPDIFAudioSink() override;
void feedPCMFrames(const uint8_t *buffer, size_t bytes) override;
bool setParams(uint32_t sampleRate, uint8_t channelCount, uint8_t bitDepth) override;
private:
};
#endif

View File

@@ -0,0 +1,30 @@
#ifndef TAS5711AUDIOSINK_H
#define TAS5711AUDIOSINK_H
#include "driver/i2s.h"
#include <driver/i2c.h>
#include <vector>
#include <iostream>
#include "BufferedAudioSink.h"
#include <stdio.h>
#include <string.h>
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_err.h"
#include "esp_log.h"
class TAS5711AudioSink : public BufferedAudioSink
{
public:
TAS5711AudioSink();
~TAS5711AudioSink();
void writeReg(uint8_t reg, uint8_t value);
private:
i2c_config_t i2c_config;
i2c_port_t i2c_port = 0;
};
#endif

View File

@@ -0,0 +1,176 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2018 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __AC101_H__
#define __AC101_H__
#include "esp_types.h"
#define AC101_ADDR 0x1a /*!< Device address*/
#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */
#define READ_BIT I2C_MASTER_READ /*!< I2C master read */
#define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/
#define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */
#define ACK_VAL 0x0 /*!< I2C ack value */
#define NACK_VAL 0x1 /*!< I2C nack value */
#define CHIP_AUDIO_RS 0x00
#define PLL_CTRL1 0x01
#define PLL_CTRL2 0x02
#define SYSCLK_CTRL 0x03
#define MOD_CLK_ENA 0x04
#define MOD_RST_CTRL 0x05
#define I2S_SR_CTRL 0x06
#define I2S1LCK_CTRL 0x10
#define I2S1_SDOUT_CTRL 0x11
#define I2S1_SDIN_CTRL 0x12
#define I2S1_MXR_SRC 0x13
#define I2S1_VOL_CTRL1 0x14
#define I2S1_VOL_CTRL2 0x15
#define I2S1_VOL_CTRL3 0x16
#define I2S1_VOL_CTRL4 0x17
#define I2S1_MXR_GAIN 0x18
#define ADC_DIG_CTRL 0x40
#define ADC_VOL_CTRL 0x41
#define HMIC_CTRL1 0x44
#define HMIC_CTRL2 0x45
#define HMIC_STATUS 0x46
#define DAC_DIG_CTRL 0x48
#define DAC_VOL_CTRL 0x49
#define DAC_MXR_SRC 0x4c
#define DAC_MXR_GAIN 0x4d
#define ADC_ANA_CTRL 0x50
#define ADC_SRC 0x51
#define ADC_SRCBST_CTRL 0x52
#define OMIXER_DACA_CTRL 0x53
#define OMIXER_SR 0x54
#define OMIXER_BST1_CTRL 0x55
#define HPOUT_CTRL 0x56
#define SPKOUT_CTRL 0x58
#define AC_DAC_DAPCTRL 0xa0
#define AC_DAC_DAPHHPFC 0xa1
#define AC_DAC_DAPLHPFC 0xa2
#define AC_DAC_DAPLHAVC 0xa3
#define AC_DAC_DAPLLAVC 0xa4
#define AC_DAC_DAPRHAVC 0xa5
#define AC_DAC_DAPRLAVC 0xa6
#define AC_DAC_DAPHGDEC 0xa7
#define AC_DAC_DAPLGDEC 0xa8
#define AC_DAC_DAPHGATC 0xa9
#define AC_DAC_DAPLGATC 0xaa
#define AC_DAC_DAPHETHD 0xab
#define AC_DAC_DAPLETHD 0xac
#define AC_DAC_DAPHGKPA 0xad
#define AC_DAC_DAPLGKPA 0xae
#define AC_DAC_DAPHGOPA 0xaf
#define AC_DAC_DAPLGOPA 0xb0
#define AC_DAC_DAPOPT 0xb1
#define DAC_DAP_ENA 0xb5
typedef enum{
SAMPLE_RATE_8000 = 0x0000,
SAMPLE_RATE_11052 = 0x1000,
SAMPLE_RATE_12000 = 0x2000,
SAMPLE_RATE_16000 = 0x3000,
SAMPLE_RATE_22050 = 0x4000,
SAMPLE_RATE_24000 = 0x5000,
SAMPLE_RATE_32000 = 0x6000,
SAMPLE_RATE_44100 = 0x7000,
SAMPLE_RATE_48000 = 0x8000,
SAMPLE_RATE_96000 = 0x9000,
SAMPLE_RATE_192000 = 0xa000,
} ac_adda_fs_i2s1_t;
typedef enum{
BCLK_DIV_1 = 0x0,
BCLK_DIV_2 = 0x1,
BCLK_DIV_4 = 0x2,
BCLK_DIV_6 = 0x3,
BCLK_DIV_8 = 0x4,
BCLK_DIV_12 = 0x5,
BCLK_DIV_16 = 0x6,
BCLK_DIV_24 = 0x7,
BCLK_DIV_32 = 0x8,
BCLK_DIV_48 = 0x9,
BCLK_DIV_64 = 0xa,
BCLK_DIV_96 = 0xb,
BCLK_DIV_128 = 0xc,
BCLK_DIV_192 = 0xd,
} ac_i2s1_bclk_div_t;
typedef enum{
LRCK_DIV_16 =0x0,
LRCK_DIV_32 =0x1,
LRCK_DIV_64 =0x2,
LRCK_DIV_128 =0x3,
LRCK_DIV_256 =0x4,
} ac_i2s1_lrck_div_t;
typedef enum {
BIT_LENGTH_8_BITS = 0x00,
BIT_LENGTH_16_BITS = 0x01,
BIT_LENGTH_20_BITS = 0x02,
BIT_LENGTH_24_BITS = 0x03,
} ac_bits_length_t;
typedef enum {
AC_MODE_MIN = -1,
AC_MODE_SLAVE = 0x00,
AC_MODE_MASTER = 0x01,
AC_MODE_MAX,
} ac_mode_sm_t;
typedef enum {
AC_MODULE_MIN = -1,
AC_MODULE_ADC = 0x01,
AC_MODULE_DAC = 0x02,
AC_MODULE_ADC_DAC = 0x03,
AC_MODULE_LINE = 0x04,
AC_MODULE_MAX
} ac_module_t;
typedef enum{
SRC_MIC1 = 1,
SRC_MIC2 = 2,
SRC_LINEIN = 3,
}ac_output_mixer_source_t;
typedef enum {
GAIN_N45DB = 0,
GAIN_N30DB = 1,
GAIN_N15DB = 2,
GAIN_0DB = 3,
GAIN_15DB = 4,
GAIN_30DB = 5,
GAIN_45DB = 6,
GAIN_60DB = 7,
} ac_output_mixer_gain_t;
typedef struct {
ac_i2s1_bclk_div_t bclk_div; /*!< bits clock divide */
ac_i2s1_lrck_div_t lclk_div; /*!< WS clock divide */
} ac_i2s_clock_t;
#endif

View File

@@ -0,0 +1,28 @@
/*
* Squeezelite for esp32
*
* (c) Sebastien 2019
* Philippe G. 2019, philippe_44@outlook.com
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*
*/
#include "freertos/FreeRTOS.h"
#include "driver/i2s.h"
typedef enum { ADAC_ON = 0, ADAC_STANDBY, ADAC_OFF } adac_power_e;
struct adac_s {
bool (*init)(int i2c_port_num, int i2s_num, i2s_config_t *config);
void (*deinit)(void);
void (*power)(adac_power_e mode);
void (*speaker)(bool active);
void (*headset)(bool active);
void (*volume)(unsigned left, unsigned right);
};
extern struct adac_s dac_tas57xx;
extern struct adac_s dac_a1s;
extern struct adac_s dac_external;

View File

@@ -0,0 +1,122 @@
/*
* ES8311.h -- ES8311 ALSA SoC Audio Codec
*
* Authors:
*
* Based on ES8374.h by David Yang
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef _ES8311_H
#define _ES8311_H
#include "driver/i2c.h"
#include "esxxx_common.h"
/*
* ES8311_REGISTER NAME_REG_REGISTER ADDRESS
*/
#define ES8311_RESET_REG00 0x00 /*reset digital,csm,clock manager etc.*/
/*
* Clock Scheme Register definition
*/
#define ES8311_CLK_MANAGER_REG01 0x01 /* select clk src for mclk, enable clock for codec */
#define ES8311_CLK_MANAGER_REG02 0x02 /* clk divider and clk multiplier */
#define ES8311_CLK_MANAGER_REG03 0x03 /* adc fsmode and osr */
#define ES8311_CLK_MANAGER_REG04 0x04 /* dac osr */
#define ES8311_CLK_MANAGER_REG05 0x05 /* clk divier for adc and dac */
#define ES8311_CLK_MANAGER_REG06 0x06 /* bclk inverter and divider */
#define ES8311_CLK_MANAGER_REG07 0x07 /* tri-state, lrck divider */
#define ES8311_CLK_MANAGER_REG08 0x08 /* lrck divider */
#define ES8311_SDPIN_REG09 0x09 /* dac serial digital port */
#define ES8311_SDPOUT_REG0A 0x0A /* adc serial digital port */
#define ES8311_SYSTEM_REG0B 0x0B /* system */
#define ES8311_SYSTEM_REG0C 0x0C /* system */
#define ES8311_SYSTEM_REG0D 0x0D /* system, power up/down */
#define ES8311_SYSTEM_REG0E 0x0E /* system, power up/down */
#define ES8311_SYSTEM_REG0F 0x0F /* system, low power */
#define ES8311_SYSTEM_REG10 0x10 /* system */
#define ES8311_SYSTEM_REG11 0x11 /* system */
#define ES8311_SYSTEM_REG12 0x12 /* system, Enable DAC */
#define ES8311_SYSTEM_REG13 0x13 /* system */
#define ES8311_SYSTEM_REG14 0x14 /* system, select DMIC, select analog pga gain */
#define ES8311_ADC_REG15 0x15 /* ADC, adc ramp rate, dmic sense */
#define ES8311_ADC_REG16 0x16 /* ADC */
#define ES8311_ADC_REG17 0x17 /* ADC, volume */
#define ES8311_ADC_REG18 0x18 /* ADC, alc enable and winsize */
#define ES8311_ADC_REG19 0x19 /* ADC, alc maxlevel */
#define ES8311_ADC_REG1A 0x1A /* ADC, alc automute */
#define ES8311_ADC_REG1B 0x1B /* ADC, alc automute, adc hpf s1 */
#define ES8311_ADC_REG1C 0x1C /* ADC, equalizer, hpf s2 */
#define ES8311_DAC_REG31 0x31 /* DAC, mute */
#define ES8311_DAC_REG32 0x32 /* DAC, volume */
#define ES8311_DAC_REG33 0x33 /* DAC, offset */
#define ES8311_DAC_REG34 0x34 /* DAC, drc enable, drc winsize */
#define ES8311_DAC_REG35 0x35 /* DAC, drc maxlevel, minilevel */
#define ES8311_DAC_REG37 0x37 /* DAC, ramprate */
#define ES8311_GPIO_REG44 0x44 /* GPIO, dac2adc for test */
#define ES8311_GP_REG45 0x45 /* GP CONTROL */
#define ES8311_CHD1_REGFD 0xFD /* CHIP ID1 */
#define ES8311_CHD2_REGFE 0xFE /* CHIP ID2 */
#define ES8311_CHVER_REGFF 0xFF /* VERSION */
#define ES8311_CHD1_REGFD 0xFD /* CHIP ID1 */
#define ES8311_MAX_REGISTER 0xFF
typedef struct {
ESCodecMode esMode;
i2c_port_t i2c_port_num;
i2c_config_t i2c_cfg;
DacOutput dacOutput;
AdcInput adcInput;
} Es8311Config;
#define AUDIO_CODEC_ES8311_DEFAULT(){ \
.esMode = ES_MODE_SLAVE, \
.i2c_port_num = I2C_NUM_0, \
.i2c_cfg = { \
.mode = I2C_MODE_MASTER, \
.sda_io_num = IIC_DATA, \
.scl_io_num = IIC_CLK, \
.sda_pullup_en = GPIO_PULLUP_ENABLE,\
.scl_pullup_en = GPIO_PULLUP_ENABLE,\
.master.clk_speed = 100000\
}, \
.adcInput = ADC_INPUT_LINPUT1_RINPUT1,\
.dacOutput = DAC_OUTPUT_LOUT1 | DAC_OUTPUT_LOUT2 | DAC_OUTPUT_ROUT1 | DAC_OUTPUT_ROUT2,\
};
int Es8311Init(Es8311Config *cfg);
void Es8311Uninit();
esp_err_t Es8311GetRef(bool flag);
esp_err_t Es7243Init(void);
int Es7243ReadReg(uint8_t regAdd);
int Es8311ConfigFmt(ESCodecModule mode, ESCodecI2SFmt fmt);
int Es8311I2sConfigClock(ESCodecI2sClock cfg);
int Es8311SetBitsPerSample(ESCodecModule mode, BitsLength bitPerSample);
void es8311_Codec_Startup(uint32_t mclk_freq, uint32_t lrck_freq);
int Es8311Start(ESCodecModule mode);
int Es8311Stop(ESCodecModule mode);
int Es8311SetVoiceVolume(int volume);
int Es8311GetVoiceVolume(int *volume);
int Es8311SetVoiceMute(int enable);
int Es8311GetVoiceMute(int *mute);
int Es8311SetMicGain(MicGain gain);
int Es8311ConfigAdcInput(AdcInput input);
int Es8311ConfigDacOutput(DacOutput output);
int ES8311WriteReg(uint8_t regAdd, uint8_t data);
void Es8311ReadAll();
int Es8311ReadReg(uint8_t regAdd);
#endif

View File

@@ -0,0 +1,166 @@
#ifndef __ESCODEC_COMMON_H__
#define __ESCODEC_COMMON_H__
typedef enum BitsLength {
BIT_LENGTH_MIN = -1,
BIT_LENGTH_16BITS = 0x03,
BIT_LENGTH_18BITS = 0x02,
BIT_LENGTH_20BITS = 0x01,
BIT_LENGTH_24BITS = 0x00,
BIT_LENGTH_32BITS = 0x04,
BIT_LENGTH_MAX,
} BitsLength;
typedef enum {
SAMPLE_RATE_MIN = -1,
SAMPLE_RATE_16K,
SAMPLE_RATE_32K,
SAMPLE_RATE_44_1K,
SAMPLE_RATE_MAX,
} SampleRate;
typedef enum {
MclkDiv_MIN = -1,
MclkDiv_1 = 1,
MclkDiv_2 = 2,
MclkDiv_3 = 3,
MclkDiv_4 = 4,
MclkDiv_6 = 5,
MclkDiv_8 = 6,
MclkDiv_9 = 7,
MclkDiv_11 = 8,
MclkDiv_12 = 9,
MclkDiv_16 = 10,
MclkDiv_18 = 11,
MclkDiv_22 = 12,
MclkDiv_24 = 13,
MclkDiv_33 = 14,
MclkDiv_36 = 15,
MclkDiv_44 = 16,
MclkDiv_48 = 17,
MclkDiv_66 = 18,
MclkDiv_72 = 19,
MclkDiv_5 = 20,
MclkDiv_10 = 21,
MclkDiv_15 = 22,
MclkDiv_17 = 23,
MclkDiv_20 = 24,
MclkDiv_25 = 25,
MclkDiv_30 = 26,
MclkDiv_32 = 27,
MclkDiv_34 = 28,
MclkDiv_7 = 29,
MclkDiv_13 = 30,
MclkDiv_14 = 31,
MclkDiv_MAX,
} SclkDiv;
typedef enum {
LclkDiv_MIN = -1,
LclkDiv_128 = 0,
LclkDiv_192 = 1,
LclkDiv_256 = 2,
LclkDiv_384 = 3,
LclkDiv_512 = 4,
LclkDiv_576 = 5,
LclkDiv_768 = 6,
LclkDiv_1024 = 7,
LclkDiv_1152 = 8,
LclkDiv_1408 = 9,
LclkDiv_1536 = 10,
LclkDiv_2112 = 11,
LclkDiv_2304 = 12,
LclkDiv_125 = 16,
LclkDiv_136 = 17,
LclkDiv_250 = 18,
LclkDiv_272 = 19,
LclkDiv_375 = 20,
LclkDiv_500 = 21,
LclkDiv_544 = 22,
LclkDiv_750 = 23,
LclkDiv_1000 = 24,
LclkDiv_1088 = 25,
LclkDiv_1496 = 26,
LclkDiv_1500 = 27,
LclkDiv_MAX,
} LclkDiv;
typedef enum {
ADC_INPUT_MIN = -1,
ADC_INPUT_LINPUT1_RINPUT1 = 0x00,
ADC_INPUT_MIC1 = 0x05,
ADC_INPUT_MIC2 = 0x06,
ADC_INPUT_LINPUT2_RINPUT2 = 0x50,
ADC_INPUT_DIFFERENCE = 0xf0,
ADC_INPUT_MAX,
} AdcInput;
typedef enum {
DAC_OUTPUT_MIN = -1,
DAC_OUTPUT_LOUT1 = 0x04,
DAC_OUTPUT_LOUT2 = 0x08,
DAC_OUTPUT_SPK = 0x09,
DAC_OUTPUT_ROUT1 = 0x10,
DAC_OUTPUT_ROUT2 = 0x20,
DAC_OUTPUT_ALL = 0x3c,
DAC_OUTPUT_MAX,
} DacOutput;
typedef enum {
D2SE_PGA_GAIN_MIN = -1,
D2SE_PGA_GAIN_DIS = 0,
D2SE_PGA_GAIN_EN = 1,
D2SE_PGA_GAIN_MAX = 2,
} D2SEPGA;
typedef enum {
MIC_GAIN_MIN = -1,
MIC_GAIN_0DB = 0,
MIC_GAIN_3DB = 3,
MIC_GAIN_6DB = 6,
MIC_GAIN_9DB = 9,
MIC_GAIN_12DB = 12,
MIC_GAIN_15DB = 15,
MIC_GAIN_18DB = 18,
MIC_GAIN_21DB = 21,
MIC_GAIN_24DB = 24,
#if defined CONFIG_CODEC_CHIP_IS_ES8311
MIC_GAIN_30DB = 30,
MIC_GAIN_36DB = 36,
MIC_GAIN_42DB = 42,
#endif
MIC_GAIN_MAX,
} MicGain;
typedef enum {
ES_MODULE_MIN = -1,
ES_MODULE_ADC = 0x01,
ES_MODULE_DAC = 0x02,
ES_MODULE_ADC_DAC = 0x03,
ES_MODULE_LINE = 0x04,
ES_MODULE_MAX
} ESCodecModule;
typedef enum {
ES_MODE_MIN = -1,
ES_MODE_SLAVE = 0x00,
ES_MODE_MASTER = 0x01,
ES_MODE_MAX,
} ESCodecMode;
typedef enum {
ES_ = -1,
ES_I2S_NORMAL = 0,
ES_I2S_LEFT = 1,
ES_I2S_RIGHT = 2,
ES_I2S_DSP = 3,
ES_I2S_MAX
} ESCodecI2SFmt;
typedef struct {
SclkDiv sclkDiv;
LclkDiv lclkDiv;
} ESCodecI2sClock;
#endif //__ESCODEC_COMMON_H__