linux/sound/soc/codecs/madera.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Cirrus Logic Madera class codecs common support
 *
 * Copyright (C) 2015-2018 Cirrus Logic, Inc. and
 *                         Cirrus Logic International Semiconductor Ltd.
 */

#ifndef ASOC_MADERA_H
#define ASOC_MADERA_H

#include <linux/completion.h>
#include <sound/soc.h>
#include <sound/madera-pdata.h>

#include "wm_adsp.h"

#define MADERA_FLL1_REFCLK
#define MADERA_FLL2_REFCLK
#define MADERA_FLL3_REFCLK
#define MADERA_FLLAO_REFCLK
#define MADERA_FLL1_SYNCCLK
#define MADERA_FLL2_SYNCCLK
#define MADERA_FLL3_SYNCCLK
#define MADERA_FLLAO_SYNCCLK

#define MADERA_FLL_SRC_NONE
#define MADERA_FLL_SRC_MCLK1
#define MADERA_FLL_SRC_MCLK2
#define MADERA_FLL_SRC_MCLK3
#define MADERA_FLL_SRC_SLIMCLK
#define MADERA_FLL_SRC_FLL1
#define MADERA_FLL_SRC_FLL2
#define MADERA_FLL_SRC_AIF1BCLK
#define MADERA_FLL_SRC_AIF2BCLK
#define MADERA_FLL_SRC_AIF3BCLK
#define MADERA_FLL_SRC_AIF4BCLK
#define MADERA_FLL_SRC_AIF1LRCLK
#define MADERA_FLL_SRC_AIF2LRCLK
#define MADERA_FLL_SRC_AIF3LRCLK
#define MADERA_FLL_SRC_AIF4LRCLK

#define MADERA_CLK_SYSCLK_1
#define MADERA_CLK_ASYNCCLK_1
#define MADERA_CLK_OPCLK
#define MADERA_CLK_ASYNC_OPCLK
#define MADERA_CLK_SYSCLK_2
#define MADERA_CLK_SYSCLK_3
#define MADERA_CLK_ASYNCCLK_2
#define MADERA_CLK_DSPCLK
#define MADERA_CLK_OUTCLK

#define MADERA_CLK_SRC_MCLK1
#define MADERA_CLK_SRC_MCLK2
#define MADERA_CLK_SRC_MCLK3
#define MADERA_CLK_SRC_FLL1
#define MADERA_CLK_SRC_FLL2
#define MADERA_CLK_SRC_FLL3
#define MADERA_CLK_SRC_FLLAO_HI
#define MADERA_CLK_SRC_FLL1_DIV6
#define MADERA_CLK_SRC_AIF1BCLK
#define MADERA_CLK_SRC_AIF2BCLK
#define MADERA_CLK_SRC_AIF3BCLK
#define MADERA_CLK_SRC_AIF4BCLK
#define MADERA_CLK_SRC_FLLAO

#define MADERA_OUTCLK_SYSCLK
#define MADERA_OUTCLK_ASYNCCLK
#define MADERA_OUTCLK_MCLK1
#define MADERA_OUTCLK_MCLK2
#define MADERA_OUTCLK_MCLK3

#define MADERA_MIXER_VOL_MASK
#define MADERA_MIXER_VOL_SHIFT
#define MADERA_MIXER_VOL_WIDTH

#define MADERA_DOM_GRP_FX
#define MADERA_DOM_GRP_ASRC1
#define MADERA_DOM_GRP_ASRC2
#define MADERA_DOM_GRP_ISRC1
#define MADERA_DOM_GRP_ISRC2
#define MADERA_DOM_GRP_ISRC3
#define MADERA_DOM_GRP_ISRC4
#define MADERA_DOM_GRP_OUT
#define MADERA_DOM_GRP_SPD
#define MADERA_DOM_GRP_DSP1
#define MADERA_DOM_GRP_DSP2
#define MADERA_DOM_GRP_DSP3
#define MADERA_DOM_GRP_DSP4
#define MADERA_DOM_GRP_DSP5
#define MADERA_DOM_GRP_DSP6
#define MADERA_DOM_GRP_DSP7
#define MADERA_DOM_GRP_AIF1
#define MADERA_DOM_GRP_AIF2
#define MADERA_DOM_GRP_AIF3
#define MADERA_DOM_GRP_AIF4
#define MADERA_DOM_GRP_SLIMBUS
#define MADERA_DOM_GRP_PWM
#define MADERA_DOM_GRP_DFC
#define MADERA_N_DOM_GRPS

#define MADERA_MAX_DAI
#define MADERA_MAX_ADSP

#define MADERA_NUM_MIXER_INPUTS

struct madera;
struct wm_adsp;

struct madera_voice_trigger_info {};

struct madera_dai_priv {};

struct madera_priv {};

struct madera_fll_cfg {};

struct madera_fll {};

struct madera_enum {};

extern const unsigned int madera_ana_tlv[];
extern const unsigned int madera_eq_tlv[];
extern const unsigned int madera_digital_tlv[];
extern const unsigned int madera_noise_tlv[];
extern const unsigned int madera_ng_tlv[];

extern const unsigned int madera_mixer_tlv[];
extern const char * const madera_mixer_texts[MADERA_NUM_MIXER_INPUTS];
extern const unsigned int madera_mixer_values[MADERA_NUM_MIXER_INPUTS];

#define MADERA_GAINMUX_CONTROLS(name, base)

#define MADERA_MIXER_CONTROLS(name, base)

#define MADERA_MUX_ENUM_DECL(name, reg)

#define MADERA_MUX_CTL_DECL(name)

#define MADERA_MUX_ENUMS(name, base_reg)

#define MADERA_MIXER_ENUMS(name, base_reg)

#define MADERA_DSP_AUX_ENUMS(name, base_reg)

#define MADERA_MUX(name, ctrl)

#define MADERA_MUX_WIDGETS(name, name_str)

#define MADERA_MIXER_WIDGETS(name, name_str)

#define MADERA_DSP_WIDGETS(name, name_str)

#define MADERA_MUX_ROUTES(widget, name)

#define MADERA_MIXER_ROUTES(widget, name)

#define MADERA_DSP_ROUTES(name)

#define MADERA_RATE_ENUM(xname, xenum)

#define MADERA_EQ_CONTROL(xname, xbase)

#define MADERA_LHPF_CONTROL(xname, xbase)

#define MADERA_RATES

#define MADERA_FORMATS

#define MADERA_OSR_ENUM_SIZE
#define MADERA_SYNC_RATE_ENUM_SIZE
#define MADERA_ASYNC_RATE_ENUM_SIZE
#define MADERA_RATE_ENUM_SIZE
#define MADERA_SAMPLE_RATE_ENUM_SIZE
#define MADERA_DFC_TYPE_ENUM_SIZE
#define MADERA_DFC_WIDTH_ENUM_SIZE

extern const struct snd_soc_dai_ops madera_dai_ops;
extern const struct snd_soc_dai_ops madera_simple_dai_ops;

extern const struct snd_kcontrol_new madera_inmux[];
extern const struct snd_kcontrol_new madera_inmode[];

extern const char * const madera_rate_text[MADERA_RATE_ENUM_SIZE];
extern const unsigned int madera_rate_val[MADERA_RATE_ENUM_SIZE];

extern const struct soc_enum madera_sample_rate[];
extern const struct soc_enum madera_isrc_fsl[];
extern const struct soc_enum madera_isrc_fsh[];
extern const struct soc_enum madera_asrc1_rate[];
extern const struct soc_enum madera_asrc1_bidir_rate[];
extern const struct soc_enum madera_asrc2_rate[];
extern const struct soc_enum madera_dfc_width[];
extern const struct soc_enum madera_dfc_type[];

extern const struct soc_enum madera_in_vi_ramp;
extern const struct soc_enum madera_in_vd_ramp;

extern const struct soc_enum madera_out_vi_ramp;
extern const struct soc_enum madera_out_vd_ramp;

extern const struct soc_enum madera_lhpf1_mode;
extern const struct soc_enum madera_lhpf2_mode;
extern const struct soc_enum madera_lhpf3_mode;
extern const struct soc_enum madera_lhpf4_mode;

extern const struct soc_enum madera_ng_hold;
extern const struct soc_enum madera_in_hpf_cut_enum;
extern const struct soc_enum madera_in_dmic_osr[];

extern const struct soc_enum madera_output_anc_src[];
extern const struct soc_enum madera_anc_input_src[];
extern const struct soc_enum madera_anc_ng_enum;

extern const struct snd_kcontrol_new madera_dsp_trigger_output_mux[];
extern const struct snd_kcontrol_new madera_drc_activity_output_mux[];

extern const struct snd_kcontrol_new madera_adsp_rate_controls[];

int madera_dfc_put(struct snd_kcontrol *kcontrol,
		   struct snd_ctl_elem_value *ucontrol);

int madera_lp_mode_put(struct snd_kcontrol *kcontrol,
		       struct snd_ctl_elem_value *ucontrol);

int madera_out1_demux_put(struct snd_kcontrol *kcontrol,
			  struct snd_ctl_elem_value *ucontrol);
int madera_out1_demux_get(struct snd_kcontrol *kcontrol,
			  struct snd_ctl_elem_value *ucontrol);

int madera_rate_put(struct snd_kcontrol *kcontrol,
		    struct snd_ctl_elem_value *ucontrol);

int madera_eq_coeff_put(struct snd_kcontrol *kcontrol,
			struct snd_ctl_elem_value *ucontrol);
int madera_lhpf_coeff_put(struct snd_kcontrol *kcontrol,
			  struct snd_ctl_elem_value *ucontrol);

int madera_clk_ev(struct snd_soc_dapm_widget *w,
		  struct snd_kcontrol *kcontrol, int event);
int madera_sysclk_ev(struct snd_soc_dapm_widget *w,
		     struct snd_kcontrol *kcontrol, int event);
int madera_spk_ev(struct snd_soc_dapm_widget *w,
		  struct snd_kcontrol *kcontrol, int event);
int madera_in_ev(struct snd_soc_dapm_widget *w,
		 struct snd_kcontrol *kcontrol, int event);
int madera_out_ev(struct snd_soc_dapm_widget *w,
		  struct snd_kcontrol *kcontrol, int event);
int madera_hp_ev(struct snd_soc_dapm_widget *w,
		 struct snd_kcontrol *kcontrol, int event);
int madera_anc_ev(struct snd_soc_dapm_widget *w,
		  struct snd_kcontrol *kcontrol, int event);
int madera_domain_clk_ev(struct snd_soc_dapm_widget *w,
			 struct snd_kcontrol *kcontrol,
			 int event);

int madera_set_adsp_clk(struct madera_priv *priv, int dsp_num,
			unsigned int freq);

int madera_set_sysclk(struct snd_soc_component *component, int clk_id,
		      int source, unsigned int freq, int dir);

int madera_init_fll(struct madera *madera, int id, int base,
		    struct madera_fll *fll);
int madera_set_fll_refclk(struct madera_fll *fll, int source,
			  unsigned int fref, unsigned int fout);
int madera_set_fll_syncclk(struct madera_fll *fll, int source,
			   unsigned int fref, unsigned int fout);
int madera_set_fll_ao_refclk(struct madera_fll *fll, int source,
			     unsigned int fin, unsigned int fout);
int madera_fllhj_set_refclk(struct madera_fll *fll, int source,
			    unsigned int fin, unsigned int fout);

int madera_core_init(struct madera_priv *priv);
int madera_core_free(struct madera_priv *priv);
int madera_init_overheat(struct madera_priv *priv);
int madera_free_overheat(struct madera_priv *priv);
int madera_init_inputs(struct snd_soc_component *component);
int madera_init_outputs(struct snd_soc_component *component,
			const struct snd_soc_dapm_route *routes,
			int n_mono_routes, int n_real);
int madera_init_bus_error_irq(struct madera_priv *priv, int dsp_num,
			      irq_handler_t handler);
void madera_free_bus_error_irq(struct madera_priv *priv, int dsp_num);

int madera_init_dai(struct madera_priv *priv, int id);

int madera_set_output_mode(struct snd_soc_component *component, int output,
			   bool differential);

/* Following functions are for use by machine drivers */
static inline int madera_register_notifier(struct snd_soc_component *component,
					   struct notifier_block *nb)
{}

static inline int
madera_unregister_notifier(struct snd_soc_component *component,
			   struct notifier_block *nb)
{}

#endif