#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/cdev.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <linux/gpio/consumer.h>
#include <linux/of.h>
#include <sound/tlv.h>
#include "max98520.h"
static struct reg_default max98520_reg[] = …;
static int max98520_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{ … }
static const int bclk_sel_table[] = …;
static int max98520_get_bclk_sel(int bclk)
{ … }
static int max98520_set_clock(struct snd_soc_component *component,
struct snd_pcm_hw_params *params)
{ … }
static int max98520_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int max98520_dai_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask,
int slots, int slot_width)
{ … }
#define MAX98520_RATES …
#define MAX98520_FORMATS …
static const struct snd_soc_dai_ops max98520_dai_ops = …;
static int max98520_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const char * const max98520_switch_text[] = …;
static const struct soc_enum dai_sel_enum = …;
static const struct snd_kcontrol_new max98520_dai_controls = …;
static const struct snd_kcontrol_new max98520_left_input_mixer_controls[] = …;
static const struct snd_kcontrol_new max98520_right_input_mixer_controls[] = …;
static const struct snd_soc_dapm_widget max98520_dapm_widgets[] = …;
static const DECLARE_TLV_DB_SCALE(max98520_digital_tlv, -6300, 50, 1);
static const DECLARE_TLV_DB_SCALE(max98520_spk_tlv, -600, 300, 0);
static const DECLARE_TLV_DB_RANGE(max98520_dht_lim_thresh_tlv,
0, 15, TLV_DB_SCALE_ITEM(-1500, 100, 0),
);
static const DECLARE_TLV_DB_RANGE(max98520_dht_hysteresis_tlv,
0, 3, TLV_DB_SCALE_ITEM(100, 100, 0),
4, 7, TLV_DB_SCALE_ITEM(600, 200, 0),
);
static const DECLARE_TLV_DB_RANGE(max98520_dht_rotation_point_tlv,
0, 1, TLV_DB_SCALE_ITEM(-1500, 300, 0),
2, 4, TLV_DB_SCALE_ITEM(-1000, 200, 0),
5, 10, TLV_DB_SCALE_ITEM(-500, 100, 0),
);
static const DECLARE_TLV_DB_RANGE(max98520_dht_supply_hr_tlv,
0, 16, TLV_DB_SCALE_ITEM(-2000, 250, 0),
);
static const DECLARE_TLV_DB_RANGE(max98520_dht_max_atten_tlv,
1, 20, TLV_DB_SCALE_ITEM(-2000, 100, 0),
);
static const char * const max98520_dht_attack_rate_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98520_dht_attack_rate_enum,
MAX98520_R20D4_DHT_CFG3, 0,
max98520_dht_attack_rate_text);
static const char * const max98520_dht_release_rate_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98520_dht_release_rate_enum,
MAX98520_R20D5_DHT_CFG4, 0,
max98520_dht_release_rate_text);
static bool max98520_readable_register(struct device *dev, unsigned int reg)
{
switch (reg) {
case MAX98520_R2000_SW_RESET:
case MAX98520_R2027_THERM_FOLDBACK_EN:
case MAX98520_R2030_CLK_MON_CTRL:
case MAX98520_R2037_ERR_MON_CTRL:
case MAX98520_R204F_PCM_RX_EN:
case MAX98520_R209F_AMP_EN:
case MAX98520_R20CF_MEAS_ADC_CFG:
case MAX98520_R20D8_DHT_EN:
case MAX98520_R21FF_REVISION_ID:
case MAX98520_R2001_STATUS_1... MAX98520_R2002_STATUS_2:
case MAX98520_R2020_THERM_WARN_THRESH... MAX98520_R2023_THERM_FOLDBACK_SET:
case MAX98520_R2040_PCM_MODE_CFG... MAX98520_R2044_PCM_RX_SRC2:
case MAX98520_R2090_AMP_VOL_CTRL... MAX98520_R2092_AMP_DSP_CFG:
case MAX98520_R2094_SSM_CFG... MAX98520_R2095_AMP_CFG:
case MAX98520_R20B0_ADC_SR... MAX98520_R20BD_ADC_HIGH_TEMP_READBACK_LSB:
case MAX98520_R20D0_DHT_CFG1... MAX98520_R20D6_DHT_HYSTERESIS_CFG:
case MAX98520_R210E_AUTO_RESTART_BEHAVIOR... MAX98520_R210F_GLOBAL_EN:
case MAX98520_R2161_BOOST_TM1... MAX98520_R2163_BOOST_TM3:
return true;
default:
return false;
}
};
static bool max98520_volatile_reg(struct device *dev, unsigned int reg)
{ … }
static const struct snd_kcontrol_new max98520_snd_controls[] = …;
static const struct snd_soc_dapm_route max98520_audio_map[] = …;
static struct snd_soc_dai_driver max98520_dai[] = …;
static int max98520_probe(struct snd_soc_component *component)
{ … }
static int __maybe_unused max98520_suspend(struct device *dev)
{ … }
static int __maybe_unused max98520_resume(struct device *dev)
{ … }
static const struct dev_pm_ops max98520_pm = …;
static const struct snd_soc_component_driver soc_codec_dev_max98520 = …;
static const struct regmap_config max98520_regmap = …;
static void max98520_power_on(struct max98520_priv *max98520, bool poweron)
{ … }
static int max98520_i2c_probe(struct i2c_client *i2c)
{ … }
static const struct i2c_device_id max98520_i2c_id[] = …;
MODULE_DEVICE_TABLE(i2c, max98520_i2c_id);
#if defined(CONFIG_OF)
static const struct of_device_id max98520_of_match[] = …;
MODULE_DEVICE_TABLE(of, max98520_of_match);
#endif
static struct i2c_driver max98520_i2c_driver = …;
module_i2c_driver(…) …
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;