linux/sound/soc/codecs/tscs454.c

// SPDX-License-Identifier: GPL-2.0
// tscs454.c -- TSCS454 ALSA SoC Audio driver
// Copyright 2018 Tempo Semiconductor, Inc.
// Author: Steven Eckhoff <[email protected]>

#include <linux/kernel.h>
#include <linux/clk.h>
#include <linux/device.h>
#include <linux/regmap.h>
#include <linux/i2c.h>
#include <linux/err.h>
#include <linux/string.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/mutex.h>

#include <sound/tlv.h>
#include <sound/pcm_params.h>
#include <sound/pcm.h>
#include <sound/soc.h>
#include <sound/soc-dapm.h>

#include "tscs454.h"

static const unsigned int PLL_44_1K_RATE =;

#define COEFF_SIZE
#define BIQUAD_COEFF_COUNT
#define BIQUAD_SIZE

#define COEFF_RAM_MAX_ADDR
#define COEFF_RAM_COEFF_COUNT
#define COEFF_RAM_SIZE

enum {};

struct pll {};

static inline void pll_init(struct pll *pll, int id)
{}

struct internal_rate {};

struct aif {};

static inline void aif_init(struct aif *aif, unsigned int id)
{}

struct coeff_ram {};

static inline void init_coeff_ram_cache(u8 *cache)
{}

static inline void coeff_ram_init(struct coeff_ram *ram)
{}

struct aifs_status {};

static inline void set_aif_status_active(struct aifs_status *status,
		int aif_id, bool playback)
{}

static inline void set_aif_status_inactive(struct aifs_status *status,
		int aif_id, bool playback)
{}

static bool aifs_active(struct aifs_status *status)
{}

static bool aif_active(struct aifs_status *status, int aif_id)
{}

struct tscs454 {};

struct coeff_ram_ctl {};

static const struct reg_sequence tscs454_patch[] =;

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

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

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

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

static const struct regmap_range_cfg tscs454_regmap_range_cfg =;

static struct regmap_config const tscs454_regmap_cfg =;

static inline int tscs454_data_init(struct tscs454 *tscs454,
		struct i2c_client *i2c)
{}

struct reg_setting {};

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

#define DACCRSTAT_MAX_TRYS
static int write_coeff_ram(struct snd_soc_component *component, u8 *coeff_ram,
		unsigned int r_stat, unsigned int r_addr, unsigned int r_wr,
		unsigned int coeff_addr, unsigned int coeff_cnt)
{}

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

static inline int coeff_ram_sync(struct snd_soc_component *component,
		struct tscs454 *tscs454)
{}

#define PLL_REG_SETTINGS_COUNT
struct pll_ctl {};

#define PLL_CTL(f, t, c1, r1, o1, f1l, f1h, c2, r2, o2, f2l, f2h)

static const struct pll_ctl pll_ctls[] =;

static inline const struct pll_ctl *get_pll_ctl(unsigned long freq_in)
{}

enum {};

static int set_sysclk(struct snd_soc_component *component)
{}

static inline void reserve_pll(struct pll *pll)
{}

static inline void free_pll(struct pll *pll)
{}

static int pll_connected(struct snd_soc_dapm_widget *source,
		struct snd_soc_dapm_widget *sink)
{}

/*
 * PLL must be enabled after power up and must be disabled before power down
 * for proper clock switching.
 */
static int pll_power_event(struct snd_soc_dapm_widget *w,
		struct snd_kcontrol *kcontrol, int event)
{}

static inline int aif_set_provider(struct snd_soc_component *component,
		unsigned int aif_id, bool provider)
{}

static inline
int aif_prepare(struct snd_soc_component *component, struct aif *aif)
{}

static inline int aif_free(struct snd_soc_component *component,
		struct aif *aif, bool playback)
{}

/* R_PLLCTL PG 0 ADDR 0x15 */
static char const * const bclk_sel_txt[] =;

static struct soc_enum const bclk_sel_enum =;

/* R_ISRC PG 0 ADDR 0x16 */
static char const * const isrc_br_txt[] =;

static struct soc_enum const isrc_br_enum =;

static char const * const isrc_bm_txt[] =;

static struct soc_enum const isrc_bm_enum =;

/* R_SCLKCTL PG 0 ADDR 0x18 */
static char const * const modular_rate_txt[] =;

static struct soc_enum const adc_modular_rate_enum =;

static struct soc_enum const dac_modular_rate_enum =;

/* R_I2SIDCTL PG 0 ADDR 0x38 */
static char const * const data_ctrl_txt[] =;

static struct soc_enum const data_in_ctrl_enums[] =;

/* R_I2SODCTL PG 0 ADDR 0x39 */
static struct soc_enum const data_out_ctrl_enums[] =;

/* R_AUDIOMUX1 PG 0 ADDR 0x3A */
static char const * const asrc_mux_txt[] =;

static struct soc_enum const asrc_in_mux_enum =;

static char const * const dai_mux_txt[] =;

static struct soc_enum const dai2_mux_enum =;

static struct snd_kcontrol_new const dai2_mux_dapm_enum =;

static struct soc_enum const dai1_mux_enum =;

static struct snd_kcontrol_new const dai1_mux_dapm_enum =;

/* R_AUDIOMUX2 PG 0 ADDR 0x3B */
static struct soc_enum const asrc_out_mux_enum =;

static struct soc_enum const dac_mux_enum =;

static struct snd_kcontrol_new const dac_mux_dapm_enum =;

static struct soc_enum const dai3_mux_enum =;

static struct snd_kcontrol_new const dai3_mux_dapm_enum =;

/* R_AUDIOMUX3 PG 0 ADDR 0x3C */
static char const * const sub_mux_txt[] =;

static struct soc_enum const sub_mux_enum =;

static struct snd_kcontrol_new const sub_mux_dapm_enum =;

static struct soc_enum const classd_mux_enum =;

static struct snd_kcontrol_new const classd_mux_dapm_enum =;

/* R_HSDCTL1 PG 1 ADDR 0x01 */
static char const * const jack_type_txt[] =;

static struct soc_enum const hp_jack_type_enum =;

static char const * const hs_det_pol_txt[] =;

static struct soc_enum const hs_det_pol_enum =;

/* R_HSDCTL1 PG 1 ADDR 0x02 */
static char const * const hs_mic_bias_force_txt[] =;

static struct soc_enum const hs_mic_bias_force_enum =;

static char const * const plug_type_txt[] =;

static struct soc_enum const plug_type_force_enum =;


/* R_CH0AIC PG 1 ADDR 0x06 */
static char const * const in_bst_mux_txt[] =;

static struct soc_enum const in_bst_mux_ch0_enum =;
static struct snd_kcontrol_new const in_bst_mux_ch0_dapm_enum =;

static DECLARE_TLV_DB_SCALE(in_bst_vol_tlv_arr, 0, 1000, 0);

static char const * const adc_mux_txt[] =;

static struct soc_enum const adc_mux_ch0_enum =;
static struct snd_kcontrol_new const adc_mux_ch0_dapm_enum =;

static char const * const in_proc_mux_txt[] =;

static struct soc_enum const in_proc_ch0_enum =;
static struct snd_kcontrol_new const in_proc_mux_ch0_dapm_enum =;

/* R_CH1AIC PG 1 ADDR 0x07 */
static struct soc_enum const in_bst_mux_ch1_enum =;
static struct snd_kcontrol_new const in_bst_mux_ch1_dapm_enum =;

static struct soc_enum const adc_mux_ch1_enum =;
static struct snd_kcontrol_new const adc_mux_ch1_dapm_enum =;

static struct soc_enum const in_proc_ch1_enum =;
static struct snd_kcontrol_new const in_proc_mux_ch1_dapm_enum =;

/* R_ICTL0 PG 1 ADDR 0x0A */
static char const * const pol_txt[] =;

static struct soc_enum const in_pol_ch1_enum =;

static struct soc_enum const in_pol_ch0_enum =;

static char const * const in_proc_ch_sel_txt[] =;

static struct soc_enum const in_proc_ch01_sel_enum =;

/* R_ICTL1 PG 1 ADDR 0x0B */
static struct soc_enum const in_pol_ch3_enum =;

static struct soc_enum const in_pol_ch2_enum =;

static struct soc_enum const in_proc_ch23_sel_enum =;

/* R_MICBIAS PG 1 ADDR 0x0C */
static char const * const mic_bias_txt[] =;

static struct soc_enum const mic_bias_2_enum =;

static struct soc_enum const mic_bias_1_enum =;

/* R_PGACTL0 PG 1 ADDR 0x0D */
/* R_PGACTL1 PG 1 ADDR 0x0E */
/* R_PGACTL2 PG 1 ADDR 0x0F */
/* R_PGACTL3 PG 1 ADDR 0x10 */
static DECLARE_TLV_DB_SCALE(in_pga_vol_tlv_arr, -1725, 75, 0);

/* R_ICH0VOL PG1 ADDR 0x12 */
/* R_ICH1VOL PG1 ADDR 0x13 */
/* R_ICH2VOL PG1 ADDR 0x14 */
/* R_ICH3VOL PG1 ADDR 0x15 */
static DECLARE_TLV_DB_MINMAX(in_vol_tlv_arr, -7125, 2400);

/* R_ASRCILVOL PG1 ADDR 0x16 */
/* R_ASRCIRVOL PG1 ADDR 0x17 */
/* R_ASRCOLVOL PG1 ADDR 0x18 */
/* R_ASRCORVOL PG1 ADDR 0x19 */
static DECLARE_TLV_DB_MINMAX(asrc_vol_tlv_arr, -9562, 600);

/* R_ALCCTL0 PG1 ADDR 0x1D */
static char const * const alc_mode_txt[] =;

static struct soc_enum const alc_mode_enum =;

static char const * const alc_ref_text[] =;

static struct soc_enum const alc_ref_enum =;

/* R_ALCCTL1 PG 1 ADDR 0x1E */
static DECLARE_TLV_DB_SCALE(alc_max_gain_tlv_arr, -1200, 600, 0);
static DECLARE_TLV_DB_SCALE(alc_target_tlv_arr, -2850, 150, 0);

/* R_ALCCTL2 PG 1 ADDR 0x1F */
static DECLARE_TLV_DB_SCALE(alc_min_gain_tlv_arr, -1725, 600, 0);

/* R_NGATE PG 1 ADDR 0x21 */
static DECLARE_TLV_DB_SCALE(ngth_tlv_arr, -7650, 150, 0);

static char const * const ngate_type_txt[] =;

static struct soc_enum const ngate_type_enum =;

/* R_DMICCTL PG 1 ADDR 0x22 */
static char const * const dmic_mono_sel_txt[] =;

static struct soc_enum const dmic_mono_sel_enum =;

/* R_DACCTL PG 2 ADDR 0x01 */
static struct soc_enum const dac_pol_r_enum =;

static struct soc_enum const dac_pol_l_enum =;

static char const * const dac_dith_txt[] =;

static struct soc_enum const dac_dith_enum =;

/* R_SPKCTL PG 2 ADDR 0x02 */
static struct soc_enum const spk_pol_r_enum =;

static struct soc_enum const spk_pol_l_enum =;

/* R_SUBCTL PG 2 ADDR 0x03 */
static struct soc_enum const sub_pol_enum =;

/* R_MVOLL PG 2 ADDR 0x08 */
/* R_MVOLR PG 2 ADDR 0x09 */
static DECLARE_TLV_DB_MINMAX(mvol_tlv_arr, -9562, 0);

/* R_HPVOLL PG 2 ADDR 0x0A */
/* R_HPVOLR PG 2 ADDR 0x0B */
static DECLARE_TLV_DB_SCALE(hp_vol_tlv_arr, -8850, 75, 0);

/* R_SPKVOLL PG 2 ADDR 0x0C */
/* R_SPKVOLR PG 2 ADDR 0x0D */
static DECLARE_TLV_DB_SCALE(spk_vol_tlv_arr, -7725, 75, 0);

/* R_SPKEQFILT PG 3 ADDR 0x01 */
static char const * const eq_txt[] =;

static struct soc_enum const spk_eq_enums[] =;

/* R_SPKMBCCTL PG 3 ADDR 0x0B */
static char const * const lvl_mode_txt[] =;

static struct soc_enum const spk_mbc3_lvl_det_mode_enum =;

static char const * const win_sel_txt[] =;

static struct soc_enum const spk_mbc3_win_sel_enum =;

static struct soc_enum const spk_mbc2_lvl_det_mode_enum =;

static struct soc_enum const spk_mbc2_win_sel_enum =;

static struct soc_enum const spk_mbc1_lvl_det_mode_enum =;

static struct soc_enum const spk_mbc1_win_sel_enum =;

/* R_SPKMBCMUG1 PG 3 ADDR 0x0C */
static struct soc_enum const spk_mbc1_phase_pol_enum =;

static DECLARE_TLV_DB_MINMAX(mbc_mug_tlv_arr, -4650, 0);

/* R_SPKMBCTHR1 PG 3 ADDR 0x0D */
static DECLARE_TLV_DB_MINMAX(thr_tlv_arr, -9562, 0);

/* R_SPKMBCRAT1 PG 3 ADDR 0x0E */
static char const * const comp_rat_txt[] =;

static struct soc_enum const spk_mbc1_comp_rat_enum =;

/* R_SPKMBCMUG2 PG 3 ADDR 0x13 */
static struct soc_enum const spk_mbc2_phase_pol_enum =;

/* R_SPKMBCRAT2 PG 3 ADDR 0x15 */
static struct soc_enum const spk_mbc2_comp_rat_enum =;

/* R_SPKMBCMUG3 PG 3 ADDR 0x1A */
static struct soc_enum const spk_mbc3_phase_pol_enum =;

/* R_SPKMBCRAT3 PG 3 ADDR 0x1C */
static struct soc_enum const spk_mbc3_comp_rat_enum =;

/* R_SPKCLECTL PG 3 ADDR 0x21 */
static struct soc_enum const spk_cle_lvl_mode_enum =;

static struct soc_enum const spk_cle_win_sel_enum =;

/* R_SPKCLEMUG PG 3 ADDR 0x22 */
static DECLARE_TLV_DB_MINMAX(cle_mug_tlv_arr, 0, 4650);

/* R_SPKCOMPRAT PG 3 ADDR 0x24 */
static struct soc_enum const spk_comp_rat_enum =;

/* R_SPKEXPTHR PG 3 ADDR 0x2F */
static char const * const exp_rat_txt[] =;

static struct soc_enum const spk_exp_rat_enum =;

/* R_DACEQFILT PG 4 ADDR 0x01 */
static struct soc_enum const dac_eq_enums[] =;

/* R_DACMBCCTL PG 4 ADDR 0x0B */
static struct soc_enum const dac_mbc3_lvl_det_mode_enum =;

static struct soc_enum const dac_mbc3_win_sel_enum =;

static struct soc_enum const dac_mbc2_lvl_det_mode_enum =;

static struct soc_enum const dac_mbc2_win_sel_enum =;

static struct soc_enum const dac_mbc1_lvl_det_mode_enum =;

static struct soc_enum const dac_mbc1_win_sel_enum =;

/* R_DACMBCMUG1 PG 4 ADDR 0x0C */
static struct soc_enum const dac_mbc1_phase_pol_enum =;

/* R_DACMBCRAT1 PG 4 ADDR 0x0E */
static struct soc_enum const dac_mbc1_comp_rat_enum =;

/* R_DACMBCMUG2 PG 4 ADDR 0x13 */
static struct soc_enum const dac_mbc2_phase_pol_enum =;

/* R_DACMBCRAT2 PG 4 ADDR 0x15 */
static struct soc_enum const dac_mbc2_comp_rat_enum =;

/* R_DACMBCMUG3 PG 4 ADDR 0x1A */
static struct soc_enum const dac_mbc3_phase_pol_enum =;

/* R_DACMBCRAT3 PG 4 ADDR 0x1C */
static struct soc_enum const dac_mbc3_comp_rat_enum =;

/* R_DACCLECTL PG 4 ADDR 0x21 */
static struct soc_enum const dac_cle_lvl_mode_enum =;

static struct soc_enum const dac_cle_win_sel_enum =;

/* R_DACCOMPRAT PG 4 ADDR 0x24 */
static struct soc_enum const dac_comp_rat_enum =;

/* R_DACEXPRAT PG 4 ADDR 0x30 */
static struct soc_enum const dac_exp_rat_enum =;

/* R_SUBEQFILT PG 5 ADDR 0x01 */
static struct soc_enum const sub_eq_enums[] =;

/* R_SUBMBCCTL PG 5 ADDR 0x0B */
static struct soc_enum const sub_mbc3_lvl_det_mode_enum =;

static struct soc_enum const sub_mbc3_win_sel_enum =;

static struct soc_enum const sub_mbc2_lvl_det_mode_enum =;

static struct soc_enum const sub_mbc2_win_sel_enum =;

static struct soc_enum const sub_mbc1_lvl_det_mode_enum =;

static struct soc_enum const sub_mbc1_win_sel_enum =;

/* R_SUBMBCMUG1 PG 5 ADDR 0x0C */
static struct soc_enum const sub_mbc1_phase_pol_enum =;

/* R_SUBMBCRAT1 PG 5 ADDR 0x0E */
static struct soc_enum const sub_mbc1_comp_rat_enum =;

/* R_SUBMBCMUG2 PG 5 ADDR 0x13 */
static struct soc_enum const sub_mbc2_phase_pol_enum =;

/* R_SUBMBCRAT2 PG 5 ADDR 0x15 */
static struct soc_enum const sub_mbc2_comp_rat_enum =;

/* R_SUBMBCMUG3 PG 5 ADDR 0x1A */
static struct soc_enum const sub_mbc3_phase_pol_enum =;

/* R_SUBMBCRAT3 PG 5 ADDR 0x1C */
static struct soc_enum const sub_mbc3_comp_rat_enum =;

/* R_SUBCLECTL PG 5 ADDR 0x21 */
static struct soc_enum const sub_cle_lvl_mode_enum =;
static struct soc_enum const sub_cle_win_sel_enum =;

/* R_SUBCOMPRAT PG 5 ADDR 0x24 */
static struct soc_enum const sub_comp_rat_enum =;

/* R_SUBEXPRAT PG 5 ADDR 0x30 */
static struct soc_enum const sub_exp_rat_enum =;

static int bytes_info_ext(struct snd_kcontrol *kcontrol,
	struct snd_ctl_elem_info *ucontrol)
{}

/* CH 0_1 Input Mux */
static char const * const ch_0_1_mux_txt[] =;

static struct soc_enum const ch_0_1_mux_enum =;

static struct snd_kcontrol_new const ch_0_1_mux_dapm_enum =;

/* CH 2_3 Input Mux */
static char const * const ch_2_3_mux_txt[] =;

static struct soc_enum const ch_2_3_mux_enum =;

static struct snd_kcontrol_new const ch_2_3_mux_dapm_enum =;

/* CH 4_5 Input Mux */
static char const * const ch_4_5_mux_txt[] =;

static struct soc_enum const ch_4_5_mux_enum =;

static struct snd_kcontrol_new const ch_4_5_mux_dapm_enum =;

#define COEFF_RAM_CTL(xname, xcount, xaddr)

static struct snd_kcontrol_new const tscs454_snd_controls[] =;

static struct snd_soc_dapm_widget const tscs454_dapm_widgets[] =;

static struct snd_soc_dapm_route const tscs454_intercon[] =;

/* This is used when BCLK is sourcing the PLLs */
static int tscs454_set_sysclk(struct snd_soc_dai *dai,
		int clk_id, unsigned int freq, int dir)
{}

static int tscs454_set_bclk_ratio(struct snd_soc_dai *dai,
		unsigned int ratio)
{}

static inline int set_aif_provider_from_fmt(struct snd_soc_component *component,
		struct aif *aif, unsigned int fmt)
{}

static inline int set_aif_tdm_delay(struct snd_soc_component *component,
		unsigned int dai_id, bool delay)
{}

static inline int set_aif_format_from_fmt(struct snd_soc_component *component,
		unsigned int dai_id, unsigned int fmt)
{}

static inline int
set_aif_clock_format_from_fmt(struct snd_soc_component *component,
		unsigned int dai_id, unsigned int fmt)
{}

static int tscs454_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{}

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

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

static int set_aif_fs(struct snd_soc_component *component,
		unsigned int id,
		unsigned int rate)
{}

static int set_aif_sample_format(struct snd_soc_component *component,
		snd_pcm_format_t format,
		int aif_id)
{}

static int tscs454_hw_params(struct snd_pcm_substream *substream,
		struct snd_pcm_hw_params *params,
		struct snd_soc_dai *dai)
{}

static int tscs454_hw_free(struct snd_pcm_substream *substream,
		struct snd_soc_dai *dai)
{}

static int tscs454_prepare(struct snd_pcm_substream *substream,
		struct snd_soc_dai *dai)
{}

static struct snd_soc_dai_ops const tscs454_dai1_ops =;

static struct snd_soc_dai_ops const tscs454_dai23_ops =;

static int tscs454_probe(struct snd_soc_component *component)
{}

static const struct snd_soc_component_driver soc_component_dev_tscs454 =;

#define TSCS454_RATES

#define TSCS454_FORMATS

static struct snd_soc_dai_driver tscs454_dais[] =;

static char const * const src_names[] =;

static int tscs454_i2c_probe(struct i2c_client *i2c)
{}

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

static const struct of_device_id tscs454_of_match[] =;
MODULE_DEVICE_TABLE(of, tscs454_of_match);

static struct i2c_driver tscs454_i2c_driver =;

module_i2c_driver();

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