#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include "rt5631.h"
struct rt5631_priv { … };
static const struct reg_default rt5631_reg[] = …;
static void rt5631_write_index(struct snd_soc_component *component,
unsigned int reg, unsigned int value)
{ … }
static unsigned int rt5631_read_index(struct snd_soc_component *component,
unsigned int reg)
{ … }
static int rt5631_reset(struct snd_soc_component *component)
{ … }
static bool rt5631_volatile_register(struct device *dev, unsigned int reg)
{ … }
static bool rt5631_readable_register(struct device *dev, unsigned int reg)
{ … }
static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -95625, 375, 0);
static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
static const DECLARE_TLV_DB_RANGE(mic_bst_tlv,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
);
static int rt5631_dmic_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int rt5631_dmic_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const char *rt5631_input_mode[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_mic1_mode_enum, RT5631_MIC_CTRL_1,
RT5631_MIC1_DIFF_INPUT_SHIFT, rt5631_input_mode);
static SOC_ENUM_SINGLE_DECL(rt5631_mic2_mode_enum, RT5631_MIC_CTRL_1,
RT5631_MIC2_DIFF_INPUT_SHIFT, rt5631_input_mode);
static SOC_ENUM_SINGLE_DECL(rt5631_monoin_mode_enum, RT5631_MONO_INPUT_VOL,
RT5631_MONO_DIFF_INPUT_SHIFT, rt5631_input_mode);
static const char *rt5631_spk_ratio[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_spk_ratio_enum, RT5631_GEN_PUR_CTRL_REG,
RT5631_SPK_AMP_RATIO_CTRL_SHIFT, rt5631_spk_ratio);
static const struct snd_kcontrol_new rt5631_snd_controls[] = …;
static int check_sysclk1_source(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int check_dmic_used(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int check_dacl_to_outmixl(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int check_dacr_to_outmixr(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int check_dacl_to_spkmixl(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int check_dacr_to_spkmixr(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int check_adcl_select(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int check_adcr_select(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static void onebit_depop_power_stage(struct snd_soc_component *component, int enable)
{ … }
static void onebit_depop_mute_stage(struct snd_soc_component *component, int enable)
{ … }
static void depop_seq_power_stage(struct snd_soc_component *component, int enable)
{ … }
static void depop_seq_mute_stage(struct snd_soc_component *component, int enable)
{ … }
static int hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int set_dmic_params(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const struct snd_kcontrol_new rt5631_recmixl_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_recmixr_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_spkmixl_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_spkmixr_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_outmixl_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_outmixr_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_AXO1MIX_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_AXO2MIX_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_spolmix_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_spormix_mixer_controls[] = …;
static const struct snd_kcontrol_new rt5631_monomix_mixer_controls[] = …;
static const char *rt5631_spkvoll_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_spkvoll_enum, RT5631_SPK_OUT_VOL,
RT5631_L_EN_SHIFT, rt5631_spkvoll_sel);
static const struct snd_kcontrol_new rt5631_spkvoll_mux_control = …;
static const char *rt5631_hpvoll_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_hpvoll_enum, RT5631_HP_OUT_VOL,
RT5631_L_EN_SHIFT, rt5631_hpvoll_sel);
static const struct snd_kcontrol_new rt5631_hpvoll_mux_control = …;
static const char *rt5631_outvoll_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_outvoll_enum, RT5631_MONO_AXO_1_2_VOL,
RT5631_L_EN_SHIFT, rt5631_outvoll_sel);
static const struct snd_kcontrol_new rt5631_outvoll_mux_control = …;
static const char *rt5631_outvolr_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_outvolr_enum, RT5631_MONO_AXO_1_2_VOL,
RT5631_R_EN_SHIFT, rt5631_outvolr_sel);
static const struct snd_kcontrol_new rt5631_outvolr_mux_control = …;
static const char *rt5631_hpvolr_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_hpvolr_enum, RT5631_HP_OUT_VOL,
RT5631_R_EN_SHIFT, rt5631_hpvolr_sel);
static const struct snd_kcontrol_new rt5631_hpvolr_mux_control = …;
static const char *rt5631_spkvolr_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_spkvolr_enum, RT5631_SPK_OUT_VOL,
RT5631_R_EN_SHIFT, rt5631_spkvolr_sel);
static const struct snd_kcontrol_new rt5631_spkvolr_mux_control = …;
static const char *rt5631_spol_src_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_spol_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
RT5631_SPK_L_MUX_SEL_SHIFT, rt5631_spol_src_sel);
static const struct snd_kcontrol_new rt5631_spol_mux_control = …;
static const char *rt5631_spor_src_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_spor_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
RT5631_SPK_R_MUX_SEL_SHIFT, rt5631_spor_src_sel);
static const struct snd_kcontrol_new rt5631_spor_mux_control = …;
static const char *rt5631_mono_src_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_mono_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
RT5631_MONO_MUX_SEL_SHIFT, rt5631_mono_src_sel);
static const struct snd_kcontrol_new rt5631_mono_mux_control = …;
static const char *rt5631_hpl_src_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_hpl_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
RT5631_HP_L_MUX_SEL_SHIFT, rt5631_hpl_src_sel);
static const struct snd_kcontrol_new rt5631_hpl_mux_control = …;
static const char *rt5631_hpr_src_sel[] = …;
static SOC_ENUM_SINGLE_DECL(rt5631_hpr_src_enum, RT5631_SPK_MONO_HP_OUT_CTRL,
RT5631_HP_R_MUX_SEL_SHIFT, rt5631_hpr_src_sel);
static const struct snd_kcontrol_new rt5631_hpr_mux_control = …;
static const struct snd_soc_dapm_widget rt5631_dapm_widgets[] = …;
static const struct snd_soc_dapm_route rt5631_dapm_routes[] = …;
struct coeff_clk_div { … };
struct pll_div { … };
static const struct pll_div codec_master_pll_div[] = …;
static const struct pll_div codec_slave_pll_div[] = …;
static const struct coeff_clk_div coeff_div[] = …;
static int get_coeff(int mclk, int rate, int timesofbclk)
{ … }
static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{ … }
static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{ … }
static int rt5631_hifi_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{ … }
static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
int source, unsigned int freq_in, unsigned int freq_out)
{ … }
static int rt5631_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{ … }
static int rt5631_probe(struct snd_soc_component *component)
{ … }
#define RT5631_STEREO_RATES …
#define RT5631_FORMAT …
static const struct snd_soc_dai_ops rt5631_ops = …;
static struct snd_soc_dai_driver rt5631_dai[] = …;
static const struct snd_soc_component_driver soc_component_dev_rt5631 = …;
static const struct i2c_device_id rt5631_i2c_id[] = …;
MODULE_DEVICE_TABLE(i2c, rt5631_i2c_id);
#ifdef CONFIG_OF
static const struct of_device_id rt5631_i2c_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, rt5631_i2c_dt_ids);
#endif
static const struct regmap_config rt5631_regmap_config = …;
static int rt5631_i2c_probe(struct i2c_client *i2c)
{ … }
static void rt5631_i2c_remove(struct i2c_client *client)
{ … }
static struct i2c_driver rt5631_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;