#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/tlv.h>
#include <sound/soc.h>
#include <sound/adau1373.h>
#include "adau1373.h"
#include "adau-utils.h"
struct adau1373_dai { … };
struct adau1373 { … };
#define ADAU1373_INPUT_MODE …
#define ADAU1373_AINL_CTRL(x) …
#define ADAU1373_AINR_CTRL(x) …
#define ADAU1373_LLINE_OUT(x) …
#define ADAU1373_RLINE_OUT(x) …
#define ADAU1373_LSPK_OUT …
#define ADAU1373_RSPK_OUT …
#define ADAU1373_LHP_OUT …
#define ADAU1373_RHP_OUT …
#define ADAU1373_ADC_GAIN …
#define ADAU1373_LADC_MIXER …
#define ADAU1373_RADC_MIXER …
#define ADAU1373_LLINE1_MIX …
#define ADAU1373_RLINE1_MIX …
#define ADAU1373_LLINE2_MIX …
#define ADAU1373_RLINE2_MIX …
#define ADAU1373_LSPK_MIX …
#define ADAU1373_RSPK_MIX …
#define ADAU1373_LHP_MIX …
#define ADAU1373_RHP_MIX …
#define ADAU1373_EP_MIX …
#define ADAU1373_HP_CTRL …
#define ADAU1373_HP_CTRL2 …
#define ADAU1373_LS_CTRL …
#define ADAU1373_EP_CTRL …
#define ADAU1373_MICBIAS_CTRL1 …
#define ADAU1373_MICBIAS_CTRL2 …
#define ADAU1373_OUTPUT_CTRL …
#define ADAU1373_PWDN_CTRL1 …
#define ADAU1373_PWDN_CTRL2 …
#define ADAU1373_PWDN_CTRL3 …
#define ADAU1373_DPLL_CTRL(x) …
#define ADAU1373_PLL_CTRL1(x) …
#define ADAU1373_PLL_CTRL2(x) …
#define ADAU1373_PLL_CTRL3(x) …
#define ADAU1373_PLL_CTRL4(x) …
#define ADAU1373_PLL_CTRL5(x) …
#define ADAU1373_PLL_CTRL6(x) …
#define ADAU1373_HEADDECT …
#define ADAU1373_ADC_DAC_STATUS …
#define ADAU1373_ADC_CTRL …
#define ADAU1373_DAI(x) …
#define ADAU1373_CLK_SRC_DIV(x) …
#define ADAU1373_BCLKDIV(x) …
#define ADAU1373_SRC_RATIOA(x) …
#define ADAU1373_SRC_RATIOB(x) …
#define ADAU1373_DEEMP_CTRL …
#define ADAU1373_SRC_DAI_CTRL(x) …
#define ADAU1373_DIN_MIX_CTRL(x) …
#define ADAU1373_DOUT_MIX_CTRL(x) …
#define ADAU1373_DAI_PBL_VOL(x) …
#define ADAU1373_DAI_PBR_VOL(x) …
#define ADAU1373_DAI_RECL_VOL(x) …
#define ADAU1373_DAI_RECR_VOL(x) …
#define ADAU1373_DAC1_PBL_VOL …
#define ADAU1373_DAC1_PBR_VOL …
#define ADAU1373_DAC2_PBL_VOL …
#define ADAU1373_DAC2_PBR_VOL …
#define ADAU1373_ADC_RECL_VOL …
#define ADAU1373_ADC_RECR_VOL …
#define ADAU1373_DMIC_RECL_VOL …
#define ADAU1373_DMIC_RECR_VOL …
#define ADAU1373_VOL_GAIN1 …
#define ADAU1373_VOL_GAIN2 …
#define ADAU1373_VOL_GAIN3 …
#define ADAU1373_HPF_CTRL …
#define ADAU1373_BASS1 …
#define ADAU1373_BASS2 …
#define ADAU1373_DRC(x) …
#define ADAU1373_3D_CTRL1 …
#define ADAU1373_3D_CTRL2 …
#define ADAU1373_FDSP_SEL1 …
#define ADAU1373_FDSP_SEL2 …
#define ADAU1373_FDSP_SEL3 …
#define ADAU1373_FDSP_SEL4 …
#define ADAU1373_DIGMICCTRL …
#define ADAU1373_DIGEN …
#define ADAU1373_SOFT_RESET …
#define ADAU1373_PLL_CTRL6_DPLL_BYPASS …
#define ADAU1373_PLL_CTRL6_PLL_EN …
#define ADAU1373_DAI_INVERT_BCLK …
#define ADAU1373_DAI_MASTER …
#define ADAU1373_DAI_INVERT_LRCLK …
#define ADAU1373_DAI_WLEN_16 …
#define ADAU1373_DAI_WLEN_20 …
#define ADAU1373_DAI_WLEN_24 …
#define ADAU1373_DAI_WLEN_32 …
#define ADAU1373_DAI_WLEN_MASK …
#define ADAU1373_DAI_FORMAT_RIGHT_J …
#define ADAU1373_DAI_FORMAT_LEFT_J …
#define ADAU1373_DAI_FORMAT_I2S …
#define ADAU1373_DAI_FORMAT_DSP …
#define ADAU1373_BCLKDIV_SOURCE …
#define ADAU1373_BCLKDIV_SR_MASK …
#define ADAU1373_BCLKDIV_BCLK_MASK …
#define ADAU1373_BCLKDIV_32 …
#define ADAU1373_BCLKDIV_64 …
#define ADAU1373_BCLKDIV_128 …
#define ADAU1373_BCLKDIV_256 …
#define ADAU1373_ADC_CTRL_PEAK_DETECT …
#define ADAU1373_ADC_CTRL_RESET …
#define ADAU1373_ADC_CTRL_RESET_FORCE …
#define ADAU1373_OUTPUT_CTRL_LDIFF …
#define ADAU1373_OUTPUT_CTRL_LNFBEN …
#define ADAU1373_PWDN_CTRL3_PWR_EN …
#define ADAU1373_EP_CTRL_MICBIAS1_OFFSET …
#define ADAU1373_EP_CTRL_MICBIAS2_OFFSET …
static const struct reg_default adau1373_reg_defaults[] = …;
static const DECLARE_TLV_DB_RANGE(adau1373_out_tlv,
0, 7, TLV_DB_SCALE_ITEM(-7900, 400, 1),
8, 15, TLV_DB_SCALE_ITEM(-4700, 300, 0),
16, 23, TLV_DB_SCALE_ITEM(-2300, 200, 0),
24, 31, TLV_DB_SCALE_ITEM(-700, 100, 0)
);
static const DECLARE_TLV_DB_MINMAX(adau1373_digital_tlv, -9563, 0);
static const DECLARE_TLV_DB_SCALE(adau1373_in_pga_tlv, -1300, 100, 1);
static const DECLARE_TLV_DB_SCALE(adau1373_ep_tlv, -600, 600, 1);
static const DECLARE_TLV_DB_SCALE(adau1373_input_boost_tlv, 0, 2000, 0);
static const DECLARE_TLV_DB_SCALE(adau1373_gain_boost_tlv, 0, 600, 0);
static const DECLARE_TLV_DB_SCALE(adau1373_speaker_boost_tlv, 1200, 600, 0);
static const char *adau1373_fdsp_sel_text[] = …;
static SOC_ENUM_SINGLE_DECL(adau1373_drc1_channel_enum,
ADAU1373_FDSP_SEL1, 4, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_drc2_channel_enum,
ADAU1373_FDSP_SEL1, 0, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_drc3_channel_enum,
ADAU1373_FDSP_SEL2, 0, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_hpf_channel_enum,
ADAU1373_FDSP_SEL3, 0, adau1373_fdsp_sel_text);
static SOC_ENUM_SINGLE_DECL(adau1373_bass_channel_enum,
ADAU1373_FDSP_SEL4, 4, adau1373_fdsp_sel_text);
static const char *adau1373_hpf_cutoff_text[] = …;
static SOC_ENUM_SINGLE_DECL(adau1373_hpf_cutoff_enum,
ADAU1373_HPF_CTRL, 3, adau1373_hpf_cutoff_text);
static const char *adau1373_bass_lpf_cutoff_text[] = …;
static const char *adau1373_bass_clip_level_text[] = …;
static const unsigned int adau1373_bass_clip_level_values[] = …;
static const char *adau1373_bass_hpf_cutoff_text[] = …;
static const DECLARE_TLV_DB_RANGE(adau1373_bass_tlv,
0, 2, TLV_DB_SCALE_ITEM(-600, 600, 1),
3, 4, TLV_DB_SCALE_ITEM(950, 250, 0),
5, 7, TLV_DB_SCALE_ITEM(1400, 150, 0)
);
static SOC_ENUM_SINGLE_DECL(adau1373_bass_lpf_cutoff_enum,
ADAU1373_BASS1, 5, adau1373_bass_lpf_cutoff_text);
static SOC_VALUE_ENUM_SINGLE_DECL(adau1373_bass_clip_level_enum,
ADAU1373_BASS1, 2, 7, adau1373_bass_clip_level_text,
adau1373_bass_clip_level_values);
static SOC_ENUM_SINGLE_DECL(adau1373_bass_hpf_cutoff_enum,
ADAU1373_BASS1, 0, adau1373_bass_hpf_cutoff_text);
static const char *adau1373_3d_level_text[] = …;
static const char *adau1373_3d_cutoff_text[] = …;
static SOC_ENUM_SINGLE_DECL(adau1373_3d_level_enum,
ADAU1373_3D_CTRL1, 4, adau1373_3d_level_text);
static SOC_ENUM_SINGLE_DECL(adau1373_3d_cutoff_enum,
ADAU1373_3D_CTRL1, 0, adau1373_3d_cutoff_text);
static const DECLARE_TLV_DB_RANGE(adau1373_3d_tlv,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 7, TLV_DB_LINEAR_ITEM(-1800, -120)
);
static const char *adau1373_lr_mux_text[] = …;
static SOC_ENUM_SINGLE_DECL(adau1373_lineout1_lr_mux_enum,
ADAU1373_OUTPUT_CTRL, 4, adau1373_lr_mux_text);
static SOC_ENUM_SINGLE_DECL(adau1373_lineout2_lr_mux_enum,
ADAU1373_OUTPUT_CTRL, 6, adau1373_lr_mux_text);
static SOC_ENUM_SINGLE_DECL(adau1373_speaker_lr_mux_enum,
ADAU1373_LS_CTRL, 4, adau1373_lr_mux_text);
static const struct snd_kcontrol_new adau1373_controls[] = …;
static const struct snd_kcontrol_new adau1373_lineout2_controls[] = …;
static const struct snd_kcontrol_new adau1373_drc_controls[] = …;
static int adau1373_pll_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const char *adau1373_decimator_text[] = …;
static SOC_ENUM_SINGLE_VIRT_DECL(adau1373_decimator_enum,
adau1373_decimator_text);
static const struct snd_kcontrol_new adau1373_decimator_mux = …;
static const struct snd_kcontrol_new adau1373_left_adc_mixer_controls[] = …;
static const struct snd_kcontrol_new adau1373_right_adc_mixer_controls[] = …;
#define DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(_name, _reg) …
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_left_line1_mixer_controls,
ADAU1373_LLINE1_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_right_line1_mixer_controls,
ADAU1373_RLINE1_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_left_line2_mixer_controls,
ADAU1373_LLINE2_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_right_line2_mixer_controls,
ADAU1373_RLINE2_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_left_spk_mixer_controls,
ADAU1373_LSPK_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_right_spk_mixer_controls,
ADAU1373_RSPK_MIX);
static DECLARE_ADAU1373_OUTPUT_MIXER_CTRLS(adau1373_ep_mixer_controls,
ADAU1373_EP_MIX);
static const struct snd_kcontrol_new adau1373_left_hp_mixer_controls[] = …;
static const struct snd_kcontrol_new adau1373_right_hp_mixer_controls[] = …;
#define DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(_name, _reg) …
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel1_mixer_controls,
ADAU1373_DIN_MIX_CTRL(0));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel2_mixer_controls,
ADAU1373_DIN_MIX_CTRL(1));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel3_mixer_controls,
ADAU1373_DIN_MIX_CTRL(2));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel4_mixer_controls,
ADAU1373_DIN_MIX_CTRL(3));
static DECLARE_ADAU1373_DSP_CHANNEL_MIXER_CTRLS(adau1373_dsp_channel5_mixer_controls,
ADAU1373_DIN_MIX_CTRL(4));
#define DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(_name, _reg) …
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_aif1_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(0));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_aif2_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(1));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_aif3_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(2));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_dac1_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(3));
static DECLARE_ADAU1373_DSP_OUTPUT_MIXER_CTRLS(adau1373_dac2_mixer_controls,
ADAU1373_DOUT_MIX_CTRL(4));
static const struct snd_soc_dapm_widget adau1373_dapm_widgets[] = …;
static int adau1373_check_aif_clk(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int adau1373_check_src(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
#define DSP_CHANNEL_MIXER_ROUTES(_sink) …
#define DSP_OUTPUT_MIXER_ROUTES(_sink) …
#define LEFT_OUTPUT_MIXER_ROUTES(_sink) …
#define RIGHT_OUTPUT_MIXER_ROUTES(_sink) …
static const struct snd_soc_dapm_route adau1373_dapm_routes[] = …;
static int adau1373_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{ … }
static int adau1373_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ … }
static int adau1373_set_dai_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir)
{ … }
static const struct snd_soc_dai_ops adau1373_dai_ops = …;
#define ADAU1373_FORMATS …
static struct snd_soc_dai_driver adau1373_dai_driver[] = …;
static int adau1373_set_pll(struct snd_soc_component *component, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out)
{ … }
static void adau1373_load_drc_settings(struct adau1373 *adau1373,
unsigned int nr, uint8_t *drc)
{ … }
static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias)
{ … }
static int adau1373_probe(struct snd_soc_component *component)
{ … }
static int adau1373_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{ … }
static int adau1373_resume(struct snd_soc_component *component)
{ … }
static bool adau1373_register_volatile(struct device *dev, unsigned int reg)
{ … }
static const struct regmap_config adau1373_regmap_config = …;
static const struct snd_soc_component_driver adau1373_component_driver = …;
static int adau1373_i2c_probe(struct i2c_client *client)
{ … }
static const struct i2c_device_id adau1373_i2c_id[] = …;
MODULE_DEVICE_TABLE(i2c, adau1373_i2c_id);
static struct i2c_driver adau1373_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;