#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/of.h>
#include <linux/of_gpio.h>
#include <linux/mfd/twl.h>
#include <linux/slab.h>
#include <linux/gpio.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <linux/mfd/twl4030-audio.h>
#define TWL4030_PMBR1_REG …
#define TWL4030_GPIO6_PWM0_MUTE(value) …
#define TWL4030_CACHEREGNUM …
struct twl4030_board_params { … };
struct twl4030_priv { … };
static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030)
{ … }
static unsigned int twl4030_read(struct snd_soc_component *component, unsigned int reg)
{ … }
static bool twl4030_can_write_to_chip(struct twl4030_priv *twl4030,
unsigned int reg)
{ … }
static int twl4030_write(struct snd_soc_component *component, unsigned int reg,
unsigned int value)
{ … }
static inline void twl4030_wait_ms(int time)
{ … }
static void twl4030_codec_enable(struct snd_soc_component *component, int enable)
{ … }
static void
twl4030_get_board_param_values(struct twl4030_board_params *board_params,
struct device_node *node)
{ … }
static struct twl4030_board_params*
twl4030_get_board_params(struct snd_soc_component *component)
{ … }
static void twl4030_init_chip(struct snd_soc_component *component)
{ … }
static void twl4030_apll_enable(struct snd_soc_component *component, int enable)
{ … }
static const struct snd_kcontrol_new twl4030_dapm_earpiece_controls[] = …;
static const struct snd_kcontrol_new twl4030_dapm_predrivel_controls[] = …;
static const struct snd_kcontrol_new twl4030_dapm_predriver_controls[] = …;
static const struct snd_kcontrol_new twl4030_dapm_hsol_controls[] = …;
static const struct snd_kcontrol_new twl4030_dapm_hsor_controls[] = …;
static const struct snd_kcontrol_new twl4030_dapm_carkitl_controls[] = …;
static const struct snd_kcontrol_new twl4030_dapm_carkitr_controls[] = …;
static const char *twl4030_handsfreel_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_handsfreel_enum,
TWL4030_REG_HFL_CTL, 0,
twl4030_handsfreel_texts);
static const struct snd_kcontrol_new twl4030_dapm_handsfreel_control = …;
static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control = …;
static const char *twl4030_handsfreer_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_handsfreer_enum,
TWL4030_REG_HFR_CTL, 0,
twl4030_handsfreer_texts);
static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control = …;
static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control = …;
static const char *twl4030_vibra_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_vibra_enum,
TWL4030_REG_VIBRA_CTL, 2,
twl4030_vibra_texts);
static const struct snd_kcontrol_new twl4030_dapm_vibra_control = …;
static const char *twl4030_vibrapath_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_vibrapath_enum,
TWL4030_REG_VIBRA_CTL, 4,
twl4030_vibrapath_texts);
static const struct snd_kcontrol_new twl4030_dapm_vibrapath_control = …;
static const struct snd_kcontrol_new twl4030_dapm_analoglmic_controls[] = …;
static const struct snd_kcontrol_new twl4030_dapm_analogrmic_controls[] = …;
static const char *twl4030_micpathtx1_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_micpathtx1_enum,
TWL4030_REG_ADCMICSEL, 0,
twl4030_micpathtx1_texts);
static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control = …;
static const char *twl4030_micpathtx2_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_micpathtx2_enum,
TWL4030_REG_ADCMICSEL, 2,
twl4030_micpathtx2_texts);
static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control = …;
static const struct snd_kcontrol_new twl4030_dapm_abypassr1_control = …;
static const struct snd_kcontrol_new twl4030_dapm_abypassl1_control = …;
static const struct snd_kcontrol_new twl4030_dapm_abypassr2_control = …;
static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control = …;
static const struct snd_kcontrol_new twl4030_dapm_abypassv_control = …;
static const DECLARE_TLV_DB_RANGE(twl4030_dapm_dbypass_tlv,
0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0)
);
static const struct snd_kcontrol_new twl4030_dapm_dbypassl_control = …;
static const struct snd_kcontrol_new twl4030_dapm_dbypassr_control = …;
static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1);
static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control = …;
#define TWL4030_OUTPUT_PGA(pin_name, reg, mask) …
TWL4030_OUTPUT_PGA(earpiece, TWL4030_REG_EAR_CTL, TWL4030_EAR_GAIN);
TWL4030_OUTPUT_PGA(predrivel, TWL4030_REG_PREDL_CTL, TWL4030_PREDL_GAIN);
TWL4030_OUTPUT_PGA(predriver, TWL4030_REG_PREDR_CTL, TWL4030_PREDR_GAIN);
TWL4030_OUTPUT_PGA(carkitl, TWL4030_REG_PRECKL_CTL, TWL4030_PRECKL_GAIN);
TWL4030_OUTPUT_PGA(carkitr, TWL4030_REG_PRECKR_CTL, TWL4030_PRECKR_GAIN);
static void handsfree_ramp(struct snd_soc_component *component, int reg, int ramp)
{ … }
static int handsfreelpga_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int handsfreerpga_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int vibramux_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int apll_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int aif_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static void headset_ramp(struct snd_soc_component *component, int ramp)
{ … }
static int headsetlpga_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int headsetrpga_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int digimic_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const char *twl4030_op_modes_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum,
TWL4030_REG_CODEC_MODE, 0,
twl4030_op_modes_texts);
static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1);
static DECLARE_TLV_DB_SCALE(digital_coarse_tlv, 0, 600, 0);
static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1);
static DECLARE_TLV_DB_SCALE(analog_tlv, -2400, 200, 0);
static DECLARE_TLV_DB_SCALE(output_tvl, -1200, 600, 1);
static DECLARE_TLV_DB_SCALE(output_ear_tvl, -600, 600, 1);
static DECLARE_TLV_DB_SCALE(digital_capture_tlv, 0, 100, 0);
static DECLARE_TLV_DB_SCALE(input_gain_tlv, 0, 600, 0);
static const char *twl4030_avadc_clk_priority_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_avadc_clk_priority_enum,
TWL4030_REG_AVADC_CTL, 2,
twl4030_avadc_clk_priority_texts);
static const char *twl4030_rampdelay_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_rampdelay_enum,
TWL4030_REG_HS_POPN_SET, 2,
twl4030_rampdelay_texts);
static const char *twl4030_vibradirmode_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_vibradirmode_enum,
TWL4030_REG_VIBRA_CTL, 5,
twl4030_vibradirmode_texts);
static const char *twl4030_vibradir_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_vibradir_enum,
TWL4030_REG_VIBRA_CTL, 1,
twl4030_vibradir_texts);
static const char *twl4030_digimicswap_texts[] = …;
static SOC_ENUM_SINGLE_DECL(twl4030_digimicswap_enum,
TWL4030_REG_MISC_SET_1, 0,
twl4030_digimicswap_texts);
static const struct snd_kcontrol_new twl4030_snd_controls[] = …;
static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = …;
static const struct snd_soc_dapm_route intercon[] = …;
static int twl4030_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{ … }
static void twl4030_constraints(struct twl4030_priv *twl4030,
struct snd_pcm_substream *mst_substream)
{ … }
static void twl4030_tdm_enable(struct snd_soc_component *component, int direction,
int enable)
{ … }
static int twl4030_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static void twl4030_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static int twl4030_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
unsigned int freq, int dir)
{ … }
static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ … }
static int twl4030_set_tristate(struct snd_soc_dai *dai, int tristate)
{ … }
static void twl4030_voice_enable(struct snd_soc_component *component, int direction,
int enable)
{ … }
static int twl4030_voice_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static void twl4030_voice_shutdown(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{ … }
static int twl4030_voice_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai,
int clk_id, unsigned int freq, int dir)
{ … }
static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{ … }
static int twl4030_voice_set_tristate(struct snd_soc_dai *dai, int tristate)
{ … }
#define TWL4030_RATES …
#define TWL4030_FORMATS …
static const struct snd_soc_dai_ops twl4030_dai_hifi_ops = …;
static const struct snd_soc_dai_ops twl4030_dai_voice_ops = …;
static struct snd_soc_dai_driver twl4030_dai[] = …;
static int twl4030_soc_probe(struct snd_soc_component *component)
{ … }
static void twl4030_soc_remove(struct snd_soc_component *component)
{ … }
static const struct snd_soc_component_driver soc_component_dev_twl4030 = …;
static int twl4030_codec_probe(struct platform_device *pdev)
{ … }
MODULE_ALIAS(…) …;
static struct platform_driver twl4030_codec_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;