#include <linux/bitops.h>
#include <linux/bits.h>
#include <linux/build_bug.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/find.h>
#include <linux/gcd.h>
#include <linux/irq.h>
#include <linux/irqdomain.h>
#include <linux/jiffies.h>
#include <linux/mfd/cs42l43.h>
#include <linux/mfd/cs42l43-regs.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/string.h>
#include <linux/workqueue.h>
#include <sound/control.h>
#include <sound/cs42l43.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc-component.h>
#include <sound/soc-dapm.h>
#include <sound/soc-dai.h>
#include <sound/soc.h>
#include <sound/tlv.h>
#include "cs42l43.h"
#define CS42L43_DECL_MUX(name, reg) …
#define CS42L43_DECL_MIXER(name, reg) …
#define CS42L43_DAPM_MUX(name_str, name) …
#define CS42L43_DAPM_MIXER(name_str, name) …
#define CS42L43_BASE_ROUTES(name_str) …
#define CS42L43_MUX_ROUTES(name_str, widget) …
#define CS42L43_MIXER_ROUTES(name_str, widget) …
#define CS42L43_MIXER_VOLUMES(name_str, base) …
#define CS42L43_IRQ_ERROR(name) …
CS42L43_IRQ_ERROR(pll_lost_lock)
CS42L43_IRQ_ERROR(spkr_clock_stop)
CS42L43_IRQ_ERROR(spkl_clock_stop)
CS42L43_IRQ_ERROR(spkr_brown_out)
CS42L43_IRQ_ERROR(spkl_brown_out)
CS42L43_IRQ_ERROR(spkr_therm_shutdown)
CS42L43_IRQ_ERROR(spkl_therm_shutdown)
CS42L43_IRQ_ERROR(spkr_therm_warm)
CS42L43_IRQ_ERROR(spkl_therm_warm)
CS42L43_IRQ_ERROR(spkr_sc_detect)
CS42L43_IRQ_ERROR(spkl_sc_detect)
static void cs42l43_hp_ilimit_clear_work(struct work_struct *work)
{ … }
static void cs42l43_hp_ilimit_work(struct work_struct *work)
{ … }
static irqreturn_t cs42l43_hp_ilimit(int irq, void *data)
{ … }
#define CS42L43_IRQ_COMPLETE(name) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
CS42L43_IRQ_COMPLETE(…) …
static irqreturn_t cs42l43_mic_shutter(int irq, void *data)
{ … }
static irqreturn_t cs42l43_spk_shutter(int irq, void *data)
{ … }
static const unsigned int cs42l43_sample_rates[] = …;
#define CS42L43_CONSUMER_RATE_MASK …
#define CS42L43_PROVIDER_RATE_MASK …
static const struct snd_pcm_hw_constraint_list cs42l43_constraint = …;
static int cs42l43_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
{ … }
static int cs42l43_convert_sample_rate(unsigned int rate)
{ … }
static int cs42l43_set_sample_rate(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int cs42l43_asp_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int cs42l43_asp_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ … }
static void cs42l43_mask_to_slots(struct cs42l43_codec *priv, unsigned long mask,
int *slots, unsigned int nslots)
{ … }
static int cs42l43_asp_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int slot_width)
{ … }
static int cs42l43_dai_probe(struct snd_soc_dai *dai)
{ … }
static int cs42l43_dai_remove(struct snd_soc_dai *dai)
{ … }
static const struct snd_soc_dai_ops cs42l43_asp_ops = …;
static int cs42l43_sdw_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static const struct snd_soc_dai_ops cs42l43_sdw_ops = …;
#define CS42L43_ASP_FORMATS …
#define CS42L43_SDW_FORMATS …
static struct snd_soc_dai_driver cs42l43_dais[] = …;
static const DECLARE_TLV_DB_SCALE(cs42l43_mixer_tlv, -3200, 100, 0);
static const char * const cs42l43_ramp_text[] = …;
static const char * const cs42l43_adc1_input_text[] = …;
static SOC_ENUM_SINGLE_DECL(cs42l43_adc1_input, CS42L43_ADC_B_CTRL1,
CS42L43_ADC_AIN_SEL_SHIFT,
cs42l43_adc1_input_text);
static const struct snd_kcontrol_new cs42l43_adc1_input_ctl = …;
static const char * const cs42l43_dec_mode_text[] = …;
static SOC_ENUM_SINGLE_VIRT_DECL(cs42l43_dec1_mode, cs42l43_dec_mode_text);
static SOC_ENUM_SINGLE_VIRT_DECL(cs42l43_dec2_mode, cs42l43_dec_mode_text);
static const struct snd_kcontrol_new cs42l43_dec_mode_ctl[] = …;
static const char * const cs42l43_pdm_clk_text[] = …;
static SOC_ENUM_SINGLE_DECL(cs42l43_pdm1_clk, CS42L43_PDM_CONTROL,
CS42L43_PDM1_CLK_DIV_SHIFT, cs42l43_pdm_clk_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_pdm2_clk, CS42L43_PDM_CONTROL,
CS42L43_PDM2_CLK_DIV_SHIFT, cs42l43_pdm_clk_text);
static DECLARE_TLV_DB_SCALE(cs42l43_adc_tlv, -600, 600, 0);
static DECLARE_TLV_DB_SCALE(cs42l43_dec_tlv, -6400, 50, 0);
static const char * const cs42l43_wnf_corner_text[] = …;
static SOC_ENUM_SINGLE_DECL(cs42l43_dec1_wnf_corner, CS42L43_DECIM_HPF_WNF_CTRL1,
CS42L43_DECIM_WNF_CF_SHIFT, cs42l43_wnf_corner_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec2_wnf_corner, CS42L43_DECIM_HPF_WNF_CTRL2,
CS42L43_DECIM_WNF_CF_SHIFT, cs42l43_wnf_corner_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec3_wnf_corner, CS42L43_DECIM_HPF_WNF_CTRL3,
CS42L43_DECIM_WNF_CF_SHIFT, cs42l43_wnf_corner_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec4_wnf_corner, CS42L43_DECIM_HPF_WNF_CTRL4,
CS42L43_DECIM_WNF_CF_SHIFT, cs42l43_wnf_corner_text);
static const char * const cs42l43_hpf_corner_text[] = …;
static SOC_ENUM_SINGLE_DECL(cs42l43_dec1_hpf_corner, CS42L43_DECIM_HPF_WNF_CTRL1,
CS42L43_DECIM_HPF_CF_SHIFT, cs42l43_hpf_corner_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec2_hpf_corner, CS42L43_DECIM_HPF_WNF_CTRL2,
CS42L43_DECIM_HPF_CF_SHIFT, cs42l43_hpf_corner_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec3_hpf_corner, CS42L43_DECIM_HPF_WNF_CTRL3,
CS42L43_DECIM_HPF_CF_SHIFT, cs42l43_hpf_corner_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec4_hpf_corner, CS42L43_DECIM_HPF_WNF_CTRL4,
CS42L43_DECIM_HPF_CF_SHIFT, cs42l43_hpf_corner_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec1_ramp_up, CS42L43_DECIM_VOL_CTRL_CH1_CH2,
CS42L43_DECIM1_VI_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec1_ramp_down, CS42L43_DECIM_VOL_CTRL_CH1_CH2,
CS42L43_DECIM1_VD_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec2_ramp_up, CS42L43_DECIM_VOL_CTRL_CH1_CH2,
CS42L43_DECIM2_VI_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec2_ramp_down, CS42L43_DECIM_VOL_CTRL_CH1_CH2,
CS42L43_DECIM2_VD_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec3_ramp_up, CS42L43_DECIM_VOL_CTRL_CH3_CH4,
CS42L43_DECIM3_VI_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec3_ramp_down, CS42L43_DECIM_VOL_CTRL_CH3_CH4,
CS42L43_DECIM3_VD_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec4_ramp_up, CS42L43_DECIM_VOL_CTRL_CH3_CH4,
CS42L43_DECIM4_VI_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_dec4_ramp_down, CS42L43_DECIM_VOL_CTRL_CH3_CH4,
CS42L43_DECIM4_VD_RAMP_SHIFT, cs42l43_ramp_text);
static DECLARE_TLV_DB_SCALE(cs42l43_speaker_tlv, -6400, 50, 0);
static SOC_ENUM_SINGLE_DECL(cs42l43_speaker_ramp_up, CS42L43_AMP1_2_VOL_RAMP,
CS42L43_AMP1_2_VI_RAMP_SHIFT, cs42l43_ramp_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_speaker_ramp_down, CS42L43_AMP1_2_VOL_RAMP,
CS42L43_AMP1_2_VD_RAMP_SHIFT, cs42l43_ramp_text);
static DECLARE_TLV_DB_SCALE(cs42l43_headphone_tlv, -11450, 50, 1);
static const char * const cs42l43_headphone_ramp_text[] = …;
static SOC_ENUM_SINGLE_DECL(cs42l43_headphone_ramp, CS42L43_PGAVOL,
CS42L43_HP_PATH_VOL_RAMP_SHIFT,
cs42l43_headphone_ramp_text);
static const char * const cs42l43_tone_freq_text[] = …;
static SOC_ENUM_SINGLE_DECL(cs42l43_tone1_freq, CS42L43_TONE_CH1_CTRL,
CS42L43_TONE_FREQ_SHIFT, cs42l43_tone_freq_text);
static SOC_ENUM_SINGLE_DECL(cs42l43_tone2_freq, CS42L43_TONE_CH2_CTRL,
CS42L43_TONE_FREQ_SHIFT, cs42l43_tone_freq_text);
static const char * const cs42l43_mixer_texts[] = …;
static const unsigned int cs42l43_mixer_values[] = …;
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MUX(…);
CS42L43_DECL_MIXER(…);
CS42L43_DECL_MIXER(…);
CS42L43_DECL_MIXER(…);
CS42L43_DECL_MIXER(…);
CS42L43_DECL_MIXER(…);
CS42L43_DECL_MIXER(…);
static int cs42l43_dapm_get_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int cs42l43_dapm_put_volsw(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int cs42l43_dapm_get_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int cs42l43_dapm_put_enum(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int cs42l43_eq_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int cs42l43_eq_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static void cs42l43_spk_vu_sync(struct cs42l43_codec *priv)
{ … }
static int cs42l43_shutter_get(struct cs42l43_codec *priv, unsigned int shift)
{ … }
static int cs42l43_decim_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int cs42l43_spk_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int cs42l43_spk_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new cs42l43_controls[] = …;
static int cs42l43_eq_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
struct cs42l43_pll_config { … };
static const struct cs42l43_pll_config cs42l43_pll_configs[] = …;
static int cs42l43_set_pll(struct cs42l43_codec *priv, unsigned int src,
unsigned int freq)
{ … }
static int cs42l43_enable_pll(struct cs42l43_codec *priv)
{ … }
static int cs42l43_disable_pll(struct cs42l43_codec *priv)
{ … }
static int cs42l43_pll_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int cs42l43_dapm_wait_completion(struct completion *pmu, struct completion *pmd,
int event, int timeout_ms)
{ … }
static int cs42l43_spkr_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int cs42l43_spkl_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int cs42l43_hp_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int cs42l43_mic_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static int cs42l43_adc_ev(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{ … }
static const struct snd_soc_dapm_widget cs42l43_widgets[] = …;
static const struct snd_soc_dapm_route cs42l43_routes[] = …;
static int cs42l43_set_sysclk(struct snd_soc_component *component, int clk_id,
int src, unsigned int freq, int dir)
{ … }
static int cs42l43_component_probe(struct snd_soc_component *component)
{ … }
static void cs42l43_component_remove(struct snd_soc_component *component)
{ … }
static const struct snd_soc_component_driver cs42l43_component_drv = …;
struct cs42l43_irq { … };
static const struct cs42l43_irq cs42l43_irqs[] = …;
static int cs42l43_request_irq(struct cs42l43_codec *priv,
struct irq_domain *dom, const char * const name,
unsigned int irq, irq_handler_t handler,
unsigned long flags)
{ … }
static int cs42l43_shutter_irq(struct cs42l43_codec *priv,
struct irq_domain *dom, unsigned int shutter,
const char * const open_name,
const char * const close_name,
irq_handler_t handler)
{ … }
static int cs42l43_codec_probe(struct platform_device *pdev)
{ … }
static void cs42l43_codec_remove(struct platform_device *pdev)
{ … }
static int cs42l43_codec_runtime_resume(struct device *dev)
{ … }
static int cs42l43_codec_suspend(struct device *dev)
{ … }
static int cs42l43_codec_suspend_noirq(struct device *dev)
{ … }
static int cs42l43_codec_resume(struct device *dev)
{ … }
static int cs42l43_codec_resume_noirq(struct device *dev)
{ … }
static const struct dev_pm_ops cs42l43_codec_pm_ops = …;
static const struct platform_device_id cs42l43_codec_id_table[] = …;
MODULE_DEVICE_TABLE(platform, cs42l43_codec_id_table);
static struct platform_driver cs42l43_codec_driver = …;
module_platform_driver(…) …;
MODULE_IMPORT_NS(…);
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;