#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/of.h>
#include <linux/pm_runtime.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 <sound/tlv.h>
#include "max98388.h"
static struct reg_default max98388_reg[] = …;
static int max98388_dac_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const char * const max98388_monomix_switch_text[] = …;
static const struct soc_enum dai_sel_enum = …;
static const struct snd_kcontrol_new max98388_dai_controls = …;
static const struct snd_kcontrol_new max98388_vi_control = …;
static const struct snd_soc_dapm_widget max98388_dapm_widgets[] = …;
static DECLARE_TLV_DB_SCALE(max98388_digital_tlv, -6350, 50, 1);
static DECLARE_TLV_DB_SCALE(max98388_amp_gain_tlv, -300, 300, 0);
static const char * const max98388_alc_max_atten_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_alc_max_atten_enum,
MAX98388_R20E2_BP_ALC_ATTEN,
MAX98388_ALC_MAX_ATTEN_SHIFT,
max98388_alc_max_atten_text);
static const char * const max98388_thermal_warn_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_thermal_warning_thresh_enum,
MAX98388_R2020_THERM_WARN_THRESH,
MAX98388_THERM_WARN_THRESH_SHIFT,
max98388_thermal_warn_text);
static const char * const max98388_thermal_shutdown_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_thermal_shutdown_thresh_enum,
MAX98388_R2020_THERM_WARN_THRESH,
MAX98388_THERM_SHDN_THRESH_SHIFT,
max98388_thermal_shutdown_text);
static const char * const max98388_alc_thresh_single_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_alc_thresh_single_enum,
MAX98388_R20E0_BP_ALC_THRESH,
MAX98388_ALC_THRESH_SHIFT,
max98388_alc_thresh_single_text);
static const char * const max98388_alc_attack_rate_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_alc_attack_rate_enum,
MAX98388_R20E1_BP_ALC_RATES,
MAX98388_ALC_ATTACK_RATE_SHIFT,
max98388_alc_attack_rate_text);
static const char * const max98388_alc_release_rate_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_alc_release_rate_enum,
MAX98388_R20E1_BP_ALC_RATES,
MAX98388_ALC_RELEASE_RATE_SHIFT,
max98388_alc_release_rate_text);
static const char * const max98388_alc_debounce_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_alc_debouce_enum,
MAX98388_R20E3_BP_ALC_REL,
MAX98388_ALC_DEBOUNCE_TIME_SHIFT,
max98388_alc_debounce_text);
static const char * const max98388_alc_mute_delay_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_alc_mute_delay_enum,
MAX98388_R20E4_BP_ALC_MUTE,
MAX98388_ALC_MUTE_DELAY_SHIFT,
max98388_alc_mute_delay_text);
static const char * const max98388_spkmon_duration_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_spkmon_duration_enum,
MAX98388_R2033_SPK_MON_DURATION,
MAX98388_SPKMON_DURATION_SHIFT,
max98388_spkmon_duration_text);
static const char * const max98388_spkmon_thresh_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_spkmon_thresh_enum,
MAX98388_R2031_SPK_MON_THRESH,
MAX98388_SPKMON_THRESH_SHIFT,
max98388_spkmon_thresh_text);
static const char * const max98388_spkmon_load_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_spkmon_load_enum,
MAX98388_R2032_SPK_MON_LD_SEL,
MAX98388_SPKMON_LOAD_SHIFT,
max98388_spkmon_load_text);
static const char * const max98388_edge_rate_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_edge_rate_falling_enum,
MAX98388_R2094_SPK_AMP_ER_CTRL,
MAX98388_EDGE_RATE_FALL_SHIFT,
max98388_edge_rate_text);
static SOC_ENUM_SINGLE_DECL(max98388_edge_rate_rising_enum,
MAX98388_R2094_SPK_AMP_ER_CTRL,
MAX98388_EDGE_RATE_RISE_SHIFT,
max98388_edge_rate_text);
static const char * const max98388_ssm_mod_text[] = …;
static SOC_ENUM_SINGLE_DECL(max98388_ssm_mod_enum,
MAX98388_R2093_SPK_AMP_SSM_CFG,
MAX98388_SPK_AMP_SSM_MOD_SHIFT,
max98388_ssm_mod_text);
static const struct snd_kcontrol_new max98388_snd_controls[] = …;
static const struct snd_soc_dapm_route max98388_audio_map[] = …;
static void max98388_reset(struct max98388_priv *max98388, struct device *dev)
{ … }
static int max98388_probe(struct snd_soc_component *component)
{ … }
static int max98388_dai_set_fmt(struct snd_soc_dai *codec_dai,
unsigned int fmt)
{ … }
static const int bclk_sel_table[] = …;
static int max98388_get_bclk_sel(int bclk)
{ … }
static int max98388_set_clock(struct snd_soc_component *component,
struct snd_pcm_hw_params *params)
{ … }
static int max98388_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
#define MAX_NUM_SLOTS …
#define MAX_NUM_CH …
static int max98388_dai_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask,
int slots, int slot_width)
{ … }
#define MAX98388_RATES …
#define MAX98388_FORMATS …
static const struct snd_soc_dai_ops max98388_dai_ops = …;
static bool max98388_readable_register(struct device *dev,
unsigned int reg)
{
switch (reg) {
case MAX98388_R2001_INT_RAW1 ... MAX98388_R2002_INT_RAW2:
case MAX98388_R2004_INT_STATE1... MAX98388_R2005_INT_STATE2:
case MAX98388_R2020_THERM_WARN_THRESH:
case MAX98388_R2031_SPK_MON_THRESH
... MAX98388_R2033_SPK_MON_DURATION:
case MAX98388_R2037_ERR_MON_CTRL:
case MAX98388_R2040_PCM_MODE_CFG
... MAX98388_R2042_PCM_SR_SETUP:
case MAX98388_R2044_PCM_TX_CTRL1
... MAX98388_R2045_PCM_TX_CTRL2:
case MAX98388_R2050_PCM_TX_HIZ_CTRL1
... MAX98388_R2059_PCM_RX_SRC2:
case MAX98388_R205C_PCM_TX_DRIVE_STRENGTH
... MAX98388_R205F_PCM_TX_EN:
case MAX98388_R2090_SPK_CH_VOL_CTRL
... MAX98388_R2094_SPK_AMP_ER_CTRL:
case MAX98388_R209E_SPK_CH_PINK_NOISE_EN
... MAX98388_R209F_SPK_CH_AMP_EN:
case MAX98388_R20A0_IV_DATA_DSP_CTRL:
case MAX98388_R20A7_IV_DATA_EN:
case MAX98388_R20E0_BP_ALC_THRESH ... MAX98388_R20E4_BP_ALC_MUTE:
case MAX98388_R20EE_BP_INF_HOLD_REL ... MAX98388_R20EF_BP_ALC_EN:
case MAX98388_R210E_AUTO_RESTART:
case MAX98388_R210F_GLOBAL_EN:
case MAX98388_R22FF_REV_ID:
return true;
default:
return false;
}
};
static bool max98388_volatile_reg(struct device *dev, unsigned int reg)
{ … }
static struct snd_soc_dai_driver max98388_dai[] = …;
static int max98388_suspend(struct device *dev)
{ … }
static int max98388_resume(struct device *dev)
{ … }
static const struct dev_pm_ops max98388_pm = …;
static const struct regmap_config max98388_regmap = …;
static const struct snd_soc_component_driver soc_codec_dev_max98388 = …;
static void max98388_read_deveice_property(struct device *dev,
struct max98388_priv *max98388)
{ … }
static int max98388_i2c_probe(struct i2c_client *i2c)
{ … }
static const struct i2c_device_id max98388_i2c_id[] = …;
MODULE_DEVICE_TABLE(i2c, max98388_i2c_id);
static const struct of_device_id max98388_of_match[] = …;
MODULE_DEVICE_TABLE(of, max98388_of_match);
static const struct acpi_device_id max98388_acpi_match[] = …;
MODULE_DEVICE_TABLE(acpi, max98388_acpi_match);
static struct i2c_driver max98388_i2c_driver = …;
module_i2c_driver(…) …
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;