#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/pm.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/acpi.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 <sound/jack.h>
#include "rl6231.h"
#include "rt5651.h"
#define RT5651_DEVICE_ID_VALUE …
#define RT5651_PR_RANGE_BASE …
#define RT5651_PR_SPACING …
#define RT5651_PR_BASE …
static const struct regmap_range_cfg rt5651_ranges[] = …;
static const struct reg_sequence init_list[] = …;
static const struct reg_default rt5651_reg[] = …;
static bool rt5651_volatile_register(struct device *dev, unsigned int reg)
{ … }
static bool rt5651_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_MINMAX(dac_vol_tlv, -6562, 0);
static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
static const DECLARE_TLV_DB_RANGE(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 const char * const rt5651_data_select[] = …;
static SOC_ENUM_SINGLE_DECL(rt5651_if2_dac_enum, RT5651_DIG_INF_DATA,
RT5651_IF2_DAC_SEL_SFT, rt5651_data_select);
static SOC_ENUM_SINGLE_DECL(rt5651_if2_adc_enum, RT5651_DIG_INF_DATA,
RT5651_IF2_ADC_SEL_SFT, rt5651_data_select);
static const struct snd_kcontrol_new rt5651_snd_controls[] = …;
static int set_dmic_clk(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const struct snd_kcontrol_new rt5651_sto1_adc_l_mix[] = …;
static const struct snd_kcontrol_new rt5651_sto1_adc_r_mix[] = …;
static const struct snd_kcontrol_new rt5651_sto2_adc_l_mix[] = …;
static const struct snd_kcontrol_new rt5651_sto2_adc_r_mix[] = …;
static const struct snd_kcontrol_new rt5651_dac_l_mix[] = …;
static const struct snd_kcontrol_new rt5651_dac_r_mix[] = …;
static const struct snd_kcontrol_new rt5651_sto_dac_l_mix[] = …;
static const struct snd_kcontrol_new rt5651_sto_dac_r_mix[] = …;
static const struct snd_kcontrol_new rt5651_dd_dac_l_mix[] = …;
static const struct snd_kcontrol_new rt5651_dd_dac_r_mix[] = …;
static const struct snd_kcontrol_new rt5651_rec_l_mix[] = …;
static const struct snd_kcontrol_new rt5651_rec_r_mix[] = …;
static const struct snd_kcontrol_new rt5651_out_l_mix[] = …;
static const struct snd_kcontrol_new rt5651_out_r_mix[] = …;
static const struct snd_kcontrol_new rt5651_hpo_mix[] = …;
static const struct snd_kcontrol_new rt5651_lout_mix[] = …;
static const struct snd_kcontrol_new outvol_l_control = …;
static const struct snd_kcontrol_new outvol_r_control = …;
static const struct snd_kcontrol_new lout_l_mute_control = …;
static const struct snd_kcontrol_new lout_r_mute_control = …;
static const struct snd_kcontrol_new hpovol_l_control = …;
static const struct snd_kcontrol_new hpovol_r_control = …;
static const struct snd_kcontrol_new hpo_l_mute_control = …;
static const struct snd_kcontrol_new hpo_r_mute_control = …;
static const char * const rt5651_stereo1_adc1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_stereo1_adc1_enum, RT5651_STO1_ADC_MIXER,
RT5651_STO1_ADC_1_SRC_SFT, rt5651_stereo1_adc1_src);
static const struct snd_kcontrol_new rt5651_sto1_adc_l1_mux = …;
static const struct snd_kcontrol_new rt5651_sto1_adc_r1_mux = …;
static const char * const rt5651_stereo1_adc2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_stereo1_adc2_enum, RT5651_STO1_ADC_MIXER,
RT5651_STO1_ADC_2_SRC_SFT, rt5651_stereo1_adc2_src);
static const struct snd_kcontrol_new rt5651_sto1_adc_l2_mux = …;
static const struct snd_kcontrol_new rt5651_sto1_adc_r2_mux = …;
static const char * const rt5651_sto2_adc_l1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_sto2_adc_l1_enum, RT5651_STO1_ADC_MIXER,
RT5651_STO2_ADC_L1_SRC_SFT, rt5651_sto2_adc_l1_src);
static const struct snd_kcontrol_new rt5651_sto2_adc_l1_mux = …;
static const char * const rt5651_sto2_adc_l2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_sto2_adc_l2_enum, RT5651_STO1_ADC_MIXER,
RT5651_STO2_ADC_L2_SRC_SFT, rt5651_sto2_adc_l2_src);
static const struct snd_kcontrol_new rt5651_sto2_adc_l2_mux = …;
static const char * const rt5651_sto2_adc_r1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_sto2_adc_r1_enum, RT5651_STO1_ADC_MIXER,
RT5651_STO2_ADC_R1_SRC_SFT, rt5651_sto2_adc_r1_src);
static const struct snd_kcontrol_new rt5651_sto2_adc_r1_mux = …;
static const char * const rt5651_sto2_adc_r2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_sto2_adc_r2_enum, RT5651_STO1_ADC_MIXER,
RT5651_STO2_ADC_R2_SRC_SFT, rt5651_sto2_adc_r2_src);
static const struct snd_kcontrol_new rt5651_sto2_adc_r2_mux = …;
static const char * const rt5651_dac_src[] = …;
static SOC_ENUM_SINGLE_DECL(rt5651_dac_l2_enum, RT5651_DAC2_CTRL,
RT5651_SEL_DAC_L2_SFT, rt5651_dac_src);
static const struct snd_kcontrol_new rt5651_dac_l2_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_dac_r2_enum, RT5651_DAC2_CTRL,
RT5651_SEL_DAC_R2_SFT, rt5651_dac_src);
static const struct snd_kcontrol_new rt5651_dac_r2_mux = …;
static const char * const rt5651_adc_src[] = …;
static SOC_ENUM_SINGLE_DECL(rt5651_if2_adc_src_enum, RT5651_DIG_INF_DATA,
RT5651_IF2_ADC_SRC_SFT, rt5651_adc_src);
static const struct snd_kcontrol_new rt5651_if2_adc_src_mux = …;
static const char * const rt5651_pdm_sel[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5651_pdm_l_sel_enum, RT5651_PDM_CTL,
RT5651_PDM_L_SEL_SFT, rt5651_pdm_sel);
static SOC_ENUM_SINGLE_DECL(
rt5651_pdm_r_sel_enum, RT5651_PDM_CTL,
RT5651_PDM_R_SEL_SFT, rt5651_pdm_sel);
static const struct snd_kcontrol_new rt5651_pdm_l_mux = …;
static const struct snd_kcontrol_new rt5651_pdm_r_mux = …;
static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5651_hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5651_bst1_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5651_bst2_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5651_bst3_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const struct snd_soc_dapm_widget rt5651_dapm_widgets[] = …;
static const struct snd_soc_dapm_route rt5651_dapm_routes[] = …;
static int rt5651_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{ … }
static int rt5651_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ … }
static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir)
{ … }
static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source,
unsigned int freq_in, unsigned int freq_out)
{ … }
static int rt5651_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{ … }
static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component)
{ … }
static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component)
{ … }
static void rt5651_enable_micbias1_ovcd_irq(struct snd_soc_component *component)
{ … }
static void rt5651_disable_micbias1_ovcd_irq(struct snd_soc_component *component)
{ … }
static void rt5651_clear_micbias1_ovcd(struct snd_soc_component *component)
{ … }
static bool rt5651_micbias1_ovcd(struct snd_soc_component *component)
{ … }
static bool rt5651_jack_inserted(struct snd_soc_component *component)
{ … }
#define JACK_SETTLE_TIME …
#define JACK_DETECT_COUNT …
#define JACK_DETECT_MAXCOUNT …
#define JACK_UNPLUG_TIME …
#define BP_POLL_TIME …
#define BP_POLL_MAXCOUNT …
#define BP_THRESHOLD …
static void rt5651_start_button_press_work(struct snd_soc_component *component)
{ … }
static void rt5651_button_press_work(struct work_struct *work)
{ … }
static int rt5651_detect_headset(struct snd_soc_component *component)
{ … }
static bool rt5651_support_button_press(struct rt5651_priv *rt5651)
{ … }
static void rt5651_jack_detect_work(struct work_struct *work)
{ … }
static irqreturn_t rt5651_irq(int irq, void *data)
{ … }
static void rt5651_cancel_work(void *data)
{ … }
static void rt5651_enable_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *hp_jack,
struct gpio_desc *gpiod_hp_det)
{ … }
static void rt5651_disable_jack_detect(struct snd_soc_component *component)
{ … }
static int rt5651_set_jack(struct snd_soc_component *component,
struct snd_soc_jack *jack, void *data)
{ … }
static void rt5651_apply_properties(struct snd_soc_component *component)
{ … }
static int rt5651_probe(struct snd_soc_component *component)
{ … }
#ifdef CONFIG_PM
static int rt5651_suspend(struct snd_soc_component *component)
{ … }
static int rt5651_resume(struct snd_soc_component *component)
{ … }
#else
#define rt5651_suspend …
#define rt5651_resume …
#endif
#define RT5651_STEREO_RATES …
#define RT5651_FORMATS …
static const struct snd_soc_dai_ops rt5651_aif_dai_ops = …;
static struct snd_soc_dai_driver rt5651_dai[] = …;
static const struct snd_soc_component_driver soc_component_dev_rt5651 = …;
static const struct regmap_config rt5651_regmap = …;
#if defined(CONFIG_OF)
static const struct of_device_id rt5651_of_match[] = …;
MODULE_DEVICE_TABLE(of, rt5651_of_match);
#endif
#ifdef CONFIG_ACPI
static const struct acpi_device_id rt5651_acpi_match[] = …;
MODULE_DEVICE_TABLE(acpi, rt5651_acpi_match);
#endif
static const struct i2c_device_id rt5651_i2c_id[] = …;
MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id);
static int rt5651_i2c_probe(struct i2c_client *i2c)
{ … }
static struct i2c_driver rt5651_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;