#include <linux/clk.h>
#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/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/acpi.h>
#include <linux/gpio/consumer.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/jack.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <sound/rt5659.h>
#include "rl6231.h"
#include "rt5659.h"
static const struct reg_default rt5659_reg[] = …;
static bool rt5659_volatile_register(struct device *dev, unsigned int reg)
{ … }
static bool rt5659_readable_register(struct device *dev, unsigned int reg)
{ … }
static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -2325, 75, 0);
static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0);
static const DECLARE_TLV_DB_SCALE(in_bst_tlv, -1200, 75, 0);
static const char * const rt5659_data_select[] = …;
static SOC_ENUM_SINGLE_DECL(rt5659_if1_01_adc_enum,
RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT01_SFT, rt5659_data_select);
static SOC_ENUM_SINGLE_DECL(rt5659_if1_23_adc_enum,
RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT23_SFT, rt5659_data_select);
static SOC_ENUM_SINGLE_DECL(rt5659_if1_45_adc_enum,
RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT45_SFT, rt5659_data_select);
static SOC_ENUM_SINGLE_DECL(rt5659_if1_67_adc_enum,
RT5659_TDM_CTRL_2, RT5659_DS_ADC_SLOT67_SFT, rt5659_data_select);
static SOC_ENUM_SINGLE_DECL(rt5659_if2_dac_enum,
RT5659_DIG_INF23_DATA, RT5659_IF2_DAC_SEL_SFT, rt5659_data_select);
static SOC_ENUM_SINGLE_DECL(rt5659_if2_adc_enum,
RT5659_DIG_INF23_DATA, RT5659_IF2_ADC_SEL_SFT, rt5659_data_select);
static SOC_ENUM_SINGLE_DECL(rt5659_if3_dac_enum,
RT5659_DIG_INF23_DATA, RT5659_IF3_DAC_SEL_SFT, rt5659_data_select);
static SOC_ENUM_SINGLE_DECL(rt5659_if3_adc_enum,
RT5659_DIG_INF23_DATA, RT5659_IF3_ADC_SEL_SFT, rt5659_data_select);
static const struct snd_kcontrol_new rt5659_if1_01_adc_swap_mux = …;
static const struct snd_kcontrol_new rt5659_if1_23_adc_swap_mux = …;
static const struct snd_kcontrol_new rt5659_if1_45_adc_swap_mux = …;
static const struct snd_kcontrol_new rt5659_if1_67_adc_swap_mux = …;
static const struct snd_kcontrol_new rt5659_if2_dac_swap_mux = …;
static const struct snd_kcontrol_new rt5659_if2_adc_swap_mux = …;
static const struct snd_kcontrol_new rt5659_if3_dac_swap_mux = …;
static const struct snd_kcontrol_new rt5659_if3_adc_swap_mux = …;
static int rt5659_hp_vol_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static void rt5659_enable_push_button_irq(struct snd_soc_component *component,
bool enable)
{ … }
static int rt5659_headset_detect(struct snd_soc_component *component, int jack_insert)
{ … }
static int rt5659_button_detect(struct snd_soc_component *component)
{ … }
static irqreturn_t rt5659_irq(int irq, void *data)
{ … }
int rt5659_set_jack_detect(struct snd_soc_component *component,
struct snd_soc_jack *hs_jack)
{ … }
EXPORT_SYMBOL_GPL(…);
static void rt5659_jack_detect_work(struct work_struct *work)
{ … }
static void rt5659_jack_detect_intel_hd_header(struct work_struct *work)
{ … }
static const struct snd_kcontrol_new rt5659_snd_controls[] = …;
static int set_dmic_clk(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int set_adc1_clk(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int set_adc2_clk(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5659_charge_pump_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *w,
struct snd_soc_dapm_widget *sink)
{ … }
static int is_using_asrc(struct snd_soc_dapm_widget *w,
struct snd_soc_dapm_widget *sink)
{ … }
static const struct snd_kcontrol_new rt5659_sto1_adc_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_sto1_adc_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_mono_adc_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_mono_adc_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_dac_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_dac_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_sto_dac_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_sto_dac_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_mono_dac_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_mono_dac_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_rec1_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_rec1_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_rec2_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_rec2_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_spk_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_spk_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_monovol_mix[] = …;
static const struct snd_kcontrol_new rt5659_out_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_out_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_spo_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_spo_r_mix[] = …;
static const struct snd_kcontrol_new rt5659_mono_mix[] = …;
static const struct snd_kcontrol_new rt5659_lout_l_mix[] = …;
static const struct snd_kcontrol_new rt5659_lout_r_mix[] = …;
static const char * const rt5659_dac2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_dac_l2_enum, RT5659_DAC_CTRL,
RT5659_DAC_L2_SEL_SFT, rt5659_dac2_src);
static const struct snd_kcontrol_new rt5659_dac_l2_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_dac_r2_enum, RT5659_DAC_CTRL,
RT5659_DAC_R2_SEL_SFT, rt5659_dac2_src);
static const struct snd_kcontrol_new rt5659_dac_r2_mux = …;
static const char * const rt5659_sto1_adc1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_sto1_adc1_enum, RT5659_STO1_ADC_MIXER,
RT5659_STO1_ADC1_SRC_SFT, rt5659_sto1_adc1_src);
static const struct snd_kcontrol_new rt5659_sto1_adc1_mux = …;
static const char * const rt5659_sto1_adc_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_sto1_adc_enum, RT5659_STO1_ADC_MIXER,
RT5659_STO1_ADC_SRC_SFT, rt5659_sto1_adc_src);
static const struct snd_kcontrol_new rt5659_sto1_adc_mux = …;
static const char * const rt5659_sto1_adc2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_sto1_adc2_enum, RT5659_STO1_ADC_MIXER,
RT5659_STO1_ADC2_SRC_SFT, rt5659_sto1_adc2_src);
static const struct snd_kcontrol_new rt5659_sto1_adc2_mux = …;
static const char * const rt5659_sto1_dmic_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_sto1_dmic_enum, RT5659_STO1_ADC_MIXER,
RT5659_STO1_DMIC_SRC_SFT, rt5659_sto1_dmic_src);
static const struct snd_kcontrol_new rt5659_sto1_dmic_mux = …;
static const char * const rt5659_mono_adc_l2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_adc_l2_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_ADC_L2_SRC_SFT, rt5659_mono_adc_l2_src);
static const struct snd_kcontrol_new rt5659_mono_adc_l2_mux = …;
static const char * const rt5659_mono_adc_l1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_adc_l1_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_ADC_L1_SRC_SFT, rt5659_mono_adc_l1_src);
static const struct snd_kcontrol_new rt5659_mono_adc_l1_mux = …;
static const char * const rt5659_mono_adc_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_adc_l_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_ADC_L_SRC_SFT, rt5659_mono_adc_src);
static const struct snd_kcontrol_new rt5659_mono_adc_l_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_adcr_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_ADC_R_SRC_SFT, rt5659_mono_adc_src);
static const struct snd_kcontrol_new rt5659_mono_adc_r_mux = …;
static const char * const rt5659_mono_dmic_l_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_dmic_l_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_DMIC_L_SRC_SFT, rt5659_mono_dmic_l_src);
static const struct snd_kcontrol_new rt5659_mono_dmic_l_mux = …;
static const char * const rt5659_mono_adc_r2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_adc_r2_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_ADC_R2_SRC_SFT, rt5659_mono_adc_r2_src);
static const struct snd_kcontrol_new rt5659_mono_adc_r2_mux = …;
static const char * const rt5659_mono_adc_r1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_adc_r1_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_ADC_R1_SRC_SFT, rt5659_mono_adc_r1_src);
static const struct snd_kcontrol_new rt5659_mono_adc_r1_mux = …;
static const char * const rt5659_mono_dmic_r_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_mono_dmic_r_enum, RT5659_MONO_ADC_MIXER,
RT5659_MONO_DMIC_R_SRC_SFT, rt5659_mono_dmic_r_src);
static const struct snd_kcontrol_new rt5659_mono_dmic_r_mux = …;
static const char * const rt5659_dac1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_dac_r1_enum, RT5659_AD_DA_MIXER,
RT5659_DAC1_R_SEL_SFT, rt5659_dac1_src);
static const struct snd_kcontrol_new rt5659_dac_r1_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_dac_l1_enum, RT5659_AD_DA_MIXER,
RT5659_DAC1_L_SEL_SFT, rt5659_dac1_src);
static const struct snd_kcontrol_new rt5659_dac_l1_mux = …;
static const char * const rt5659_dig_dac_mix_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_dig_dac_mixl_enum, RT5659_DIG_MIXER,
RT5659_DAC_MIX_L_SFT, rt5659_dig_dac_mix_src);
static const struct snd_kcontrol_new rt5659_dig_dac_mixl_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_dig_dac_mixr_enum, RT5659_DIG_MIXER,
RT5659_DAC_MIX_R_SFT, rt5659_dig_dac_mix_src);
static const struct snd_kcontrol_new rt5659_dig_dac_mixr_mux = …;
static const char * const rt5659_alg_dac1_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_alg_dac_l1_enum, RT5659_A_DAC_MUX,
RT5659_A_DACL1_SFT, rt5659_alg_dac1_src);
static const struct snd_kcontrol_new rt5659_alg_dac_l1_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_alg_dac_r1_enum, RT5659_A_DAC_MUX,
RT5659_A_DACR1_SFT, rt5659_alg_dac1_src);
static const struct snd_kcontrol_new rt5659_alg_dac_r1_mux = …;
static const char * const rt5659_alg_dac2_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_alg_dac_l2_enum, RT5659_A_DAC_MUX,
RT5659_A_DACL2_SFT, rt5659_alg_dac2_src);
static const struct snd_kcontrol_new rt5659_alg_dac_l2_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_alg_dac_r2_enum, RT5659_A_DAC_MUX,
RT5659_A_DACR2_SFT, rt5659_alg_dac2_src);
static const struct snd_kcontrol_new rt5659_alg_dac_r2_mux = …;
static const char * const rt5659_if2_adc_in_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_if2_adc_in_enum, RT5659_DIG_INF23_DATA,
RT5659_IF2_ADC_IN_SFT, rt5659_if2_adc_in_src);
static const struct snd_kcontrol_new rt5659_if2_adc_in_mux = …;
static const char * const rt5659_if3_adc_in_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_if3_adc_in_enum, RT5659_DIG_INF23_DATA,
RT5659_IF3_ADC_IN_SFT, rt5659_if3_adc_in_src);
static const struct snd_kcontrol_new rt5659_if3_adc_in_mux = …;
static const char * const rt5659_pdm_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_pdm_l_enum, RT5659_PDM_OUT_CTRL,
RT5659_PDM1_L_SFT, rt5659_pdm_src);
static const struct snd_kcontrol_new rt5659_pdm_l_mux = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_pdm_r_enum, RT5659_PDM_OUT_CTRL,
RT5659_PDM1_R_SFT, rt5659_pdm_src);
static const struct snd_kcontrol_new rt5659_pdm_r_mux = …;
static const char * const rt5659_spdif_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_spdif_enum, RT5659_SPDIF_CTRL,
RT5659_SPDIF_SEL_SFT, rt5659_spdif_src);
static const struct snd_kcontrol_new rt5659_spdif_mux = …;
static const char * const rt5659_rx_adc_data_src[] = …;
static SOC_ENUM_SINGLE_DECL(
rt5659_rx_adc_data_enum, RT5659_TDM_CTRL_2,
RT5659_ADCDAT_SRC_SFT, rt5659_rx_adc_data_src);
static const struct snd_kcontrol_new rt5659_rx_adc_dac_mux = …;
static const struct snd_kcontrol_new spkvol_l_switch = …;
static const struct snd_kcontrol_new spkvol_r_switch = …;
static const struct snd_kcontrol_new monovol_switch = …;
static const struct snd_kcontrol_new outvol_l_switch = …;
static const struct snd_kcontrol_new outvol_r_switch = …;
static const struct snd_kcontrol_new spo_switch = …;
static const struct snd_kcontrol_new mono_switch = …;
static const struct snd_kcontrol_new hpo_l_switch = …;
static const struct snd_kcontrol_new hpo_r_switch = …;
static const struct snd_kcontrol_new lout_l_switch = …;
static const struct snd_kcontrol_new lout_r_switch = …;
static const struct snd_kcontrol_new pdm_l_switch = …;
static const struct snd_kcontrol_new pdm_r_switch = …;
static int rt5659_spk_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5659_mono_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int rt5659_hp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int set_dmic_power(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const struct snd_soc_dapm_widget rt5659_particular_dapm_widgets[] = …;
static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = …;
static const struct snd_soc_dapm_route rt5659_dapm_routes[] = …;
static int rt5659_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
{ … }
static int rt5659_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ … }
static int rt5659_set_component_sysclk(struct snd_soc_component *component, int clk_id,
int source, unsigned int freq, int dir)
{ … }
static int rt5659_set_component_pll(struct snd_soc_component *component, int pll_id,
int source, unsigned int freq_in,
unsigned int freq_out)
{ … }
static int rt5659_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int slot_width)
{ … }
static int rt5659_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio)
{ … }
static int rt5659_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{ … }
static int rt5659_probe(struct snd_soc_component *component)
{ … }
static void rt5659_remove(struct snd_soc_component *component)
{ … }
#ifdef CONFIG_PM
static int rt5659_suspend(struct snd_soc_component *component)
{ … }
static int rt5659_resume(struct snd_soc_component *component)
{ … }
#else
#define rt5659_suspend …
#define rt5659_resume …
#endif
#define RT5659_STEREO_RATES …
#define RT5659_FORMATS …
static const struct snd_soc_dai_ops rt5659_aif_dai_ops = …;
static struct snd_soc_dai_driver rt5659_dai[] = …;
static const struct snd_soc_component_driver soc_component_dev_rt5659 = …;
static const struct regmap_config rt5659_regmap = …;
static const struct i2c_device_id rt5659_i2c_id[] = …;
MODULE_DEVICE_TABLE(i2c, rt5659_i2c_id);
static int rt5659_parse_dt(struct rt5659_priv *rt5659, struct device *dev)
{ … }
static void rt5659_calibrate(struct rt5659_priv *rt5659)
{ … }
static void rt5659_intel_hd_header_probe_setup(struct rt5659_priv *rt5659)
{ … }
static int rt5659_i2c_probe(struct i2c_client *i2c)
{ … }
static void rt5659_i2c_shutdown(struct i2c_client *client)
{ … }
#ifdef CONFIG_OF
static const struct of_device_id rt5659_of_match[] = …;
MODULE_DEVICE_TABLE(of, rt5659_of_match);
#endif
#ifdef CONFIG_ACPI
static const struct acpi_device_id rt5659_acpi_match[] = …;
MODULE_DEVICE_TABLE(acpi, rt5659_acpi_match);
#endif
static struct i2c_driver rt5659_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;