#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/pm.h>
#include <linux/i2c.h>
#include <linux/clk.h>
#include <linux/log2.h>
#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/consumer.h>
#include <sound/core.h>
#include <sound/tlv.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include "sgtl5000.h"
#define SGTL5000_DAP_REG_OFFSET …
#define SGTL5000_MAX_REG_OFFSET …
#define SGTL5000_VAG_POWERUP_DELAY …
#define SGTL5000_VAG_POWERDOWN_DELAY …
#define SGTL5000_OUTPUTS_MUTE …
static const struct reg_default sgtl5000_reg_defaults[] = …;
static const u16 avc_thr_db2reg[97] = …;
enum sgtl5000_regulator_supplies { … };
static const char *supply_names[SGTL5000_SUPPLY_NUM] = …;
#define LDO_VOLTAGE …
#define LINREG_VDDD …
enum sgtl5000_micbias_resistor { … };
enum { … };
enum { … };
enum { … };
struct sgtl5000_priv { … };
static inline int hp_sel_input(struct snd_soc_component *component)
{ … }
static inline u16 mute_output(struct snd_soc_component *component,
u16 mute_mask)
{ … }
static inline void restore_output(struct snd_soc_component *component,
u16 mute_mask, u16 mute_reg)
{ … }
static void vag_power_on(struct snd_soc_component *component, u32 source)
{ … }
static int vag_power_consumers(struct snd_soc_component *component,
u16 ana_pwr_reg, u32 source)
{ … }
static void vag_power_off(struct snd_soc_component *component, u32 source)
{ … }
static int mic_bias_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int vag_and_mute_control(struct snd_soc_component *component,
int event, int event_source)
{ … }
static int headphone_pga_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int adc_updown_depop(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int dac_updown_depop(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const char *adc_mux_text[] = …;
static SOC_ENUM_SINGLE_DECL(adc_enum,
SGTL5000_CHIP_ANA_CTRL, 2,
adc_mux_text);
static const struct snd_kcontrol_new adc_mux = …;
static const char *hp_mux_text[] = …;
static SOC_ENUM_SINGLE_DECL(hp_enum,
SGTL5000_CHIP_ANA_CTRL, 6,
hp_mux_text);
static const struct snd_kcontrol_new hp_mux = …;
static const char *dac_mux_text[] = …;
static SOC_ENUM_SINGLE_DECL(dac_enum,
SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAC_SEL_SHIFT,
dac_mux_text);
static const struct snd_kcontrol_new dac_mux = …;
static const char *dap_mux_text[] = …;
static SOC_ENUM_SINGLE_DECL(dap_enum,
SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAP_SEL_SHIFT,
dap_mux_text);
static const struct snd_kcontrol_new dap_mux = …;
static const char *dapmix_mux_text[] = …;
static SOC_ENUM_SINGLE_DECL(dapmix_enum,
SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAP_MIX_SEL_SHIFT,
dapmix_mux_text);
static const struct snd_kcontrol_new dapmix_mux = …;
static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = …;
static const struct snd_soc_dapm_route sgtl5000_dapm_routes[] = …;
static int dac_info_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{ … }
static int dac_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int dac_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int avc_get_threshold(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int avc_put_threshold(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const DECLARE_TLV_DB_SCALE(capture_6db_attenuate, -600, 600, 0);
static const DECLARE_TLV_DB_RANGE(mic_gain_tlv,
0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0)
);
static const DECLARE_TLV_DB_SCALE(dap_volume, 0, 1, 0);
static const DECLARE_TLV_DB_SCALE(bass_band, -1175, 25, 0);
static const DECLARE_TLV_DB_SCALE(headphone_volume, -5150, 50, 0);
static const DECLARE_TLV_DB_SCALE(lineout_volume, -1550, 50, 0);
static const DECLARE_TLV_DB_SCALE(avc_max_gain, 0, 600, 0);
static const DECLARE_TLV_DB_MINMAX(avc_threshold, 0, 9600);
static const struct snd_kcontrol_new sgtl5000_snd_controls[] = …;
static int sgtl5000_mute_stream(struct snd_soc_dai *codec_dai, int mute, int direction)
{ … }
static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ … }
static int sgtl5000_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{ … }
static int sgtl5000_set_clock(struct snd_soc_component *component, int frame_rate)
{ … }
static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int sgtl5000_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{ … }
#define SGTL5000_FORMATS …
static const struct snd_soc_dai_ops sgtl5000_ops = …;
static struct snd_soc_dai_driver sgtl5000_dai = …;
static bool sgtl5000_volatile(struct device *dev, unsigned int reg)
{ … }
static bool sgtl5000_readable(struct device *dev, unsigned int reg)
{ … }
static const u8 vol_quot_table[] = …;
static int sgtl5000_set_power_regs(struct snd_soc_component *component)
{ … }
static int sgtl5000_enable_regulators(struct i2c_client *client)
{ … }
static int sgtl5000_probe(struct snd_soc_component *component)
{ … }
static int sgtl5000_of_xlate_dai_id(struct snd_soc_component *component,
struct device_node *endpoint)
{ … }
static const struct snd_soc_component_driver sgtl5000_driver = …;
static const struct regmap_config sgtl5000_regmap = …;
static void sgtl5000_fill_defaults(struct i2c_client *client)
{ … }
static int sgtl5000_i2c_probe(struct i2c_client *client)
{ … }
static void sgtl5000_i2c_remove(struct i2c_client *client)
{ … }
static void sgtl5000_i2c_shutdown(struct i2c_client *client)
{ … }
static const struct i2c_device_id sgtl5000_id[] = …;
MODULE_DEVICE_TABLE(i2c, sgtl5000_id);
static const struct of_device_id sgtl5000_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, sgtl5000_dt_ids);
static struct i2c_driver sgtl5000_i2c_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;