linux/sound/soc/codecs/da7219.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * da7219.c - DA7219 ALSA SoC Codec Driver
 *
 * Copyright (c) 2015 Dialog Semiconductor
 *
 * Author: Adam Thomson <[email protected]>
 */

#include <linux/acpi.h>
#include <linux/clk.h>
#include <linux/clkdev.h>
#include <linux/clk-provider.h>
#include <linux/i2c.h>
#include <linux/of.h>
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <linux/pm.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/regulator/consumer.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>
#include <sound/initval.h>
#include <sound/tlv.h>
#include <asm/div64.h>

#include <sound/da7219.h>
#include "da7219.h"
#include "da7219-aad.h"


/*
 * TLVs and Enums
 */

/* Input TLVs */
static const DECLARE_TLV_DB_SCALE(da7219_mic_gain_tlv, -600, 600, 0);
static const DECLARE_TLV_DB_SCALE(da7219_mixin_gain_tlv, -450, 150, 0);
static const DECLARE_TLV_DB_SCALE(da7219_adc_dig_gain_tlv, -8325, 75, 0);
static const DECLARE_TLV_DB_SCALE(da7219_alc_threshold_tlv, -9450, 150, 0);
static const DECLARE_TLV_DB_SCALE(da7219_alc_gain_tlv, 0, 600, 0);
static const DECLARE_TLV_DB_SCALE(da7219_alc_ana_gain_tlv, 0, 600, 0);
static const DECLARE_TLV_DB_SCALE(da7219_sidetone_gain_tlv, -4200, 300, 0);
static const DECLARE_TLV_DB_SCALE(da7219_tonegen_gain_tlv, -4500, 300, 0);

/* Output TLVs */
static const DECLARE_TLV_DB_SCALE(da7219_dac_eq_band_tlv, -1050, 150, 0);

static const DECLARE_TLV_DB_RANGE(da7219_dac_dig_gain_tlv,
	0x0, 0x07, TLV_DB_SCALE_ITEM(TLV_DB_GAIN_MUTE, 0, 1),
	/* -77.25dB to 12dB */
	0x08, 0x7f, TLV_DB_SCALE_ITEM(-7725, 75, 0)
);

static const DECLARE_TLV_DB_SCALE(da7219_dac_ng_threshold_tlv, -10200, 600, 0);
static const DECLARE_TLV_DB_SCALE(da7219_hp_gain_tlv, -5700, 100, 0);

/* Input Enums */
static const char * const da7219_alc_attack_rate_txt[] =;

static const struct soc_enum da7219_alc_attack_rate =;

static const char * const da7219_alc_release_rate_txt[] =;

static const struct soc_enum da7219_alc_release_rate =;

static const char * const da7219_alc_hold_time_txt[] =;

static const struct soc_enum da7219_alc_hold_time =;

static const char * const da7219_alc_env_rate_txt[] =;

static const struct soc_enum da7219_alc_env_attack_rate =;

static const struct soc_enum da7219_alc_env_release_rate =;

static const char * const da7219_alc_anticlip_step_txt[] =;

static const struct soc_enum da7219_alc_anticlip_step =;

/* Input/Output Enums */
static const char * const da7219_gain_ramp_rate_txt[] =;

static const struct soc_enum da7219_gain_ramp_rate =;

static const char * const da7219_hpf_mode_txt[] =;

static const unsigned int da7219_hpf_mode_val[] =;

static const struct soc_enum da7219_adc_hpf_mode =;

static const struct soc_enum da7219_dac_hpf_mode =;

static const char * const da7219_audio_hpf_corner_txt[] =;

static const struct soc_enum da7219_adc_audio_hpf_corner =;

static const struct soc_enum da7219_dac_audio_hpf_corner =;

static const char * const da7219_voice_hpf_corner_txt[] =;

static const struct soc_enum da7219_adc_voice_hpf_corner =;

static const struct soc_enum da7219_dac_voice_hpf_corner =;

static const char * const da7219_tonegen_dtmf_key_txt[] =;

static const struct soc_enum da7219_tonegen_dtmf_key =;

static const char * const da7219_tonegen_swg_sel_txt[] =;

static const struct soc_enum da7219_tonegen_swg_sel =;

/* Output Enums */
static const char * const da7219_dac_softmute_rate_txt[] =;

static const struct soc_enum da7219_dac_softmute_rate =;

static const char * const da7219_dac_ng_setup_time_txt[] =;

static const struct soc_enum da7219_dac_ng_setup_time =;

static const char * const da7219_dac_ng_rampup_txt[] =;

static const struct soc_enum da7219_dac_ng_rampup_rate =;

static const char * const da7219_dac_ng_rampdown_txt[] =;

static const struct soc_enum da7219_dac_ng_rampdown_rate =;


static const char * const da7219_cp_track_mode_txt[] =;

static const unsigned int da7219_cp_track_mode_val[] =;

static const struct soc_enum da7219_cp_track_mode =;


/*
 * Control Functions
 */

/* Locked Kcontrol calls */
static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{}

static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{}

static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{}

static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol,
				struct snd_ctl_elem_value *ucontrol)
{}

/* ALC */
static void da7219_alc_calib(struct snd_soc_component *component)
{}

static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol,
				 struct snd_ctl_elem_value *ucontrol)
{}

static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol,
			     struct snd_ctl_elem_value *ucontrol)
{}

/* ToneGen */
static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{}

static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol,
				   struct snd_ctl_elem_value *ucontrol)
{}


/*
 * KControls
 */

static const struct snd_kcontrol_new da7219_snd_controls[] =;


/*
 * DAPM Mux Controls
 */

static const char * const da7219_out_sel_txt[] =;

static const struct soc_enum da7219_out_dail_sel =;

static const struct snd_kcontrol_new da7219_out_dail_sel_mux =;

static const struct soc_enum da7219_out_dair_sel =;

static const struct snd_kcontrol_new da7219_out_dair_sel_mux =;

static const struct soc_enum da7219_out_dacl_sel =;

static const struct snd_kcontrol_new da7219_out_dacl_sel_mux =;

static const struct soc_enum da7219_out_dacr_sel =;

static const struct snd_kcontrol_new da7219_out_dacr_sel_mux =;


/*
 * DAPM Mixer Controls
 */

static const struct snd_kcontrol_new da7219_mixin_controls[] =;

static const struct snd_kcontrol_new da7219_mixout_l_controls[] =;

static const struct snd_kcontrol_new da7219_mixout_r_controls[] =;

#define DA7219_DMIX_ST_CTRLS(reg)		\

static const struct snd_kcontrol_new da7219_st_out_filtl_mix_controls[] =;

static const struct snd_kcontrol_new da7219_st_out_filtr_mix_controls[] =;


/*
 * DAPM Events
 */

static int da7219_mic_pga_event(struct snd_soc_dapm_widget *w,
				struct snd_kcontrol *kcontrol, int event)
{}

static int da7219_dai_event(struct snd_soc_dapm_widget *w,
			    struct snd_kcontrol *kcontrol, int event)
{}

static int da7219_settling_event(struct snd_soc_dapm_widget *w,
				 struct snd_kcontrol *kcontrol, int event)
{}

static int da7219_mixout_event(struct snd_soc_dapm_widget *w,
			       struct snd_kcontrol *kcontrol, int event)
{}

static int da7219_gain_ramp_event(struct snd_soc_dapm_widget *w,
				  struct snd_kcontrol *kcontrol, int event)
{}


/*
 * DAPM Widgets
 */

static const struct snd_soc_dapm_widget da7219_dapm_widgets[] =;


/*
 * DAPM Mux Routes
 */

#define DA7219_OUT_DAI_MUX_ROUTES(name)

#define DA7219_OUT_DAC_MUX_ROUTES(name)

/*
 * DAPM Mixer Routes
 */

#define DA7219_DMIX_ST_ROUTES(name)


/*
 * DAPM audio route definition
 */

static const struct snd_soc_dapm_route da7219_audio_map[] =;


/*
 * DAI operations
 */

static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
				 int clk_id, unsigned int freq, int dir)
{}

int da7219_set_pll(struct snd_soc_component *component, int source, unsigned int fout)
{}

static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
			      int source, unsigned int fref, unsigned int fout)
{}

static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{}

static int da7219_set_bclks_per_wclk(struct snd_soc_component *component,
				     unsigned long factor)
{}

static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai,
				   unsigned int tx_mask, unsigned int rx_mask,
				   int slots, int slot_width)
{}

static int da7219_set_sr(struct snd_soc_component *component,
			 unsigned long rate)
{}

static int da7219_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 da7219_dai_ops =;

#define DA7219_FORMATS

#define DA7219_RATES

static struct snd_soc_dai_driver da7219_dai =;


/*
 * DT/ACPI
 */

#ifdef CONFIG_OF
static const struct of_device_id da7219_of_match[] =;
MODULE_DEVICE_TABLE(of, da7219_of_match);
#endif

#ifdef CONFIG_ACPI
static const struct acpi_device_id da7219_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, da7219_acpi_match);
#endif

static enum da7219_micbias_voltage
	da7219_fw_micbias_lvl(struct device *dev, u32 val)
{}

static enum da7219_mic_amp_in_sel
	da7219_fw_mic_amp_in_sel(struct device *dev, const char *str)
{}

static struct da7219_pdata *da7219_fw_to_pdata(struct device *dev)
{}


/*
 * Codec driver functions
 */

static int da7219_set_bias_level(struct snd_soc_component *component,
				 enum snd_soc_bias_level level)
{}

static const char *da7219_supply_names[DA7219_NUM_SUPPLIES] =;

static int da7219_handle_supplies(struct snd_soc_component *component,
				  u8 *io_voltage_lvl)
{}

#ifdef CONFIG_COMMON_CLK
static int da7219_wclk_prepare(struct clk_hw *hw)
{}

static void da7219_wclk_unprepare(struct clk_hw *hw)
{}

static int da7219_wclk_is_prepared(struct clk_hw *hw)
{}

static unsigned long da7219_wclk_recalc_rate(struct clk_hw *hw,
					     unsigned long parent_rate)
{}

static long da7219_wclk_round_rate(struct clk_hw *hw, unsigned long rate,
				   unsigned long *parent_rate)
{}

static int da7219_wclk_set_rate(struct clk_hw *hw, unsigned long rate,
				unsigned long parent_rate)
{}

static unsigned long da7219_bclk_recalc_rate(struct clk_hw *hw,
					     unsigned long parent_rate)
{}

static unsigned long da7219_bclk_get_factor(unsigned long rate,
					    unsigned long parent_rate)
{}

static long da7219_bclk_round_rate(struct clk_hw *hw, unsigned long rate,
				   unsigned long *parent_rate)
{}

static int da7219_bclk_set_rate(struct clk_hw *hw, unsigned long rate,
				unsigned long parent_rate)
{}

static const struct clk_ops da7219_dai_clk_ops[DA7219_DAI_NUM_CLKS] =;

static int da7219_register_dai_clks(struct snd_soc_component *component)
{}

static void da7219_free_dai_clks(struct snd_soc_component *component)
{}
#else
static inline int da7219_register_dai_clks(struct snd_soc_component *component)
{
	return 0;
}

static void da7219_free_dai_clks(struct snd_soc_component *component) {}
#endif /* CONFIG_COMMON_CLK */

static void da7219_handle_pdata(struct snd_soc_component *component)
{}


/*
 * Regmap configs
 */

static struct reg_default da7219_reg_defaults[] =;

static bool da7219_volatile_register(struct device *dev, unsigned int reg)
{}

static const struct regmap_config da7219_regmap_config =;

static struct reg_sequence da7219_rev_aa_patch[] =;

static int da7219_probe(struct snd_soc_component *component)
{}

static void da7219_remove(struct snd_soc_component *component)
{}

#ifdef CONFIG_PM
static int da7219_suspend(struct snd_soc_component *component)
{}

static int da7219_resume(struct snd_soc_component *component)
{}
#else
#define da7219_suspend
#define da7219_resume
#endif

static int da7219_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack,
			   void *data)
{}

static const struct snd_soc_component_driver soc_component_dev_da7219 =;


/*
 * I2C layer
 */

static int da7219_i2c_probe(struct i2c_client *i2c)
{}

static const struct i2c_device_id da7219_i2c_id[] =;
MODULE_DEVICE_TABLE(i2c, da7219_i2c_id);

static struct i2c_driver da7219_i2c_driver =;

module_i2c_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();