#include <linux/bitfield.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <sound/pcm_params.h>
#include "mt8188-afe-clk.h"
#include "mt8188-afe-common.h"
#include "mt8188-reg.h"
#define MT8188_ETDM_MAX_CHANNELS …
#define MT8188_ETDM_NORMAL_MAX_BCK_RATE …
#define ETDM_TO_DAI_ID(x) …
#define ENUM_TO_STR(x) …
enum { … };
enum { … };
enum { … };
enum { … };
enum { … };
enum { … };
enum { … };
struct etdm_con_reg { … };
struct mtk_dai_etdm_rate { … };
struct mtk_dai_etdm_priv { … };
static const struct mtk_dai_etdm_rate mt8188_etdm_rates[] = …;
static int get_etdm_fs_timing(unsigned int rate)
{ … }
static unsigned int get_etdm_ch_fixup(unsigned int channels)
{ … }
static int get_etdm_reg(unsigned int dai_id, struct etdm_con_reg *etdm_reg)
{ … }
static int get_etdm_dir(unsigned int dai_id)
{ … }
static int get_etdm_wlen(unsigned int bitwidth)
{ … }
static bool is_valid_etdm_dai(int dai_id)
{ … }
static int is_cowork_mode(struct snd_soc_dai *dai)
{ … }
static int sync_to_dai_id(int source_sel)
{ … }
static int get_etdm_cowork_master_id(struct snd_soc_dai *dai)
{ … }
static int mtk_dai_etdm_get_cg_id_by_dai_id(int dai_id)
{ … }
static int mtk_dai_etdm_get_clk_id_by_dai_id(int dai_id)
{ … }
static int mtk_dai_etdm_get_clkdiv_id_by_dai_id(int dai_id)
{ … }
static int get_etdm_id_by_name(struct mtk_base_afe *afe,
const char *name)
{ … }
static struct mtk_dai_etdm_priv *get_etdm_priv_by_name(struct mtk_base_afe *afe,
const char *name)
{ … }
static int mtk_dai_etdm_enable_mclk(struct mtk_base_afe *afe, int dai_id)
{ … }
static int mtk_dai_etdm_disable_mclk(struct mtk_base_afe *afe, int dai_id)
{ … }
static int mtk_afe_etdm_apll_connect(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int mtk_afe_mclk_apll_connect(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int mtk_etdm_mclk_connect(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int mtk_etdm_cowork_connect(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink)
{ … }
static int mtk_apll_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{ … }
static int mtk_etdm_mclk_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{ … }
static int mtk_dptx_mclk_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{ … }
static int mtk_etdm_cg_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{ … }
static int mtk_etdm3_cg_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol,
int event)
{ … }
static const struct snd_kcontrol_new mtk_dai_etdm_o048_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o049_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o050_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o051_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o052_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o053_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o054_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o055_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o056_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o057_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o058_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o059_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o060_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o061_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o062_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o063_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o072_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o073_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o074_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o075_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o076_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o077_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o078_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o079_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o080_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o081_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o082_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o083_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o084_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o085_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o086_mix[] = …;
static const struct snd_kcontrol_new mtk_dai_etdm_o087_mix[] = …;
static const char * const mt8188_etdm_clk_src_sel_text[] = …;
static SOC_ENUM_SINGLE_EXT_DECL(etdmout_clk_src_enum,
mt8188_etdm_clk_src_sel_text);
static const char * const hdmitx_dptx_mux_map[] = …;
static int hdmitx_dptx_mux_map_value[] = …;
static SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(hdmi_out_mux_map_enum,
SND_SOC_NOPM,
0,
1,
hdmitx_dptx_mux_map,
hdmitx_dptx_mux_map_value);
static const struct snd_kcontrol_new hdmi_out_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(dptx_out_mux_map_enum,
SND_SOC_NOPM,
0,
1,
hdmitx_dptx_mux_map,
hdmitx_dptx_mux_map_value);
static const struct snd_kcontrol_new dptx_out_mux_control = …;
static const char *const afe_conn_hdmi_mux_map[] = …;
static int afe_conn_hdmi_mux_map_value[] = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch0_mux_map_enum,
AFE_TDMOUT_CONN0,
0,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch0_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch1_mux_map_enum,
AFE_TDMOUT_CONN0,
4,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch1_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch2_mux_map_enum,
AFE_TDMOUT_CONN0,
8,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch2_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch3_mux_map_enum,
AFE_TDMOUT_CONN0,
12,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch3_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch4_mux_map_enum,
AFE_TDMOUT_CONN0,
16,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch4_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch5_mux_map_enum,
AFE_TDMOUT_CONN0,
20,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch5_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch6_mux_map_enum,
AFE_TDMOUT_CONN0,
24,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch6_mux_control = …;
static SOC_VALUE_ENUM_SINGLE_DECL(hdmi_ch7_mux_map_enum,
AFE_TDMOUT_CONN0,
28,
0xf,
afe_conn_hdmi_mux_map,
afe_conn_hdmi_mux_map_value);
static const struct snd_kcontrol_new hdmi_ch7_mux_control = …;
static int mt8188_etdm_clk_src_sel_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static int mt8188_etdm_clk_src_sel_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol)
{ … }
static const struct snd_kcontrol_new mtk_dai_etdm_controls[] = …;
static const struct snd_soc_dapm_widget mtk_dai_etdm_widgets[] = …;
static const struct snd_soc_dapm_route mtk_dai_etdm_routes[] = …;
static int etdm_cowork_slv_sel(int id, int slave_mode)
{ … }
static int etdm_cowork_sync_sel(int id)
{ … }
static int mt8188_etdm_sync_mode_slv(struct mtk_base_afe *afe, int dai_id)
{ … }
static int mt8188_etdm_sync_mode_mst(struct mtk_base_afe *afe, int dai_id)
{ … }
static int mt8188_etdm_sync_mode_configure(struct mtk_base_afe *afe, int dai_id)
{ … }
static int mtk_dai_etdm_fifo_mode(struct mtk_base_afe *afe,
int dai_id, unsigned int rate)
{ … }
static int mtk_dai_etdm_in_configure(struct mtk_base_afe *afe,
unsigned int rate,
unsigned int channels,
int dai_id)
{ … }
static int mtk_dai_etdm_out_configure(struct mtk_base_afe *afe,
unsigned int rate,
unsigned int channels,
int dai_id)
{ … }
static int mtk_dai_etdm_configure(struct mtk_base_afe *afe,
unsigned int rate,
unsigned int channels,
unsigned int bit_width,
int dai_id)
{ … }
static int mtk_dai_etdm_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int mtk_dai_etdm_cal_mclk(struct mtk_base_afe *afe, int freq, int dai_id)
{ … }
static int mtk_dai_etdm_set_sysclk(struct snd_soc_dai *dai,
int clk_id, unsigned int freq, int dir)
{ … }
static int mtk_dai_etdm_set_tdm_slot(struct snd_soc_dai *dai,
unsigned int tx_mask, unsigned int rx_mask,
int slots, int slot_width)
{ … }
static int mtk_dai_etdm_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{ … }
static unsigned int mtk_dai_get_dptx_ch_en(unsigned int channel)
{ … }
static unsigned int mtk_dai_get_dptx_ch(unsigned int ch)
{ … }
static unsigned int mtk_dai_get_dptx_wlen(snd_pcm_format_t format)
{ … }
static int mtk_dai_hdmitx_dptx_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params,
struct snd_soc_dai *dai)
{ … }
static int mtk_dai_hdmitx_dptx_set_sysclk(struct snd_soc_dai *dai,
int clk_id,
unsigned int freq,
int dir)
{ … }
static const struct snd_soc_dai_ops mtk_dai_etdm_ops = …;
static const struct snd_soc_dai_ops mtk_dai_hdmitx_dptx_ops = …;
#define MTK_ETDM_RATES …
#define MTK_ETDM_FORMATS …
static struct snd_soc_dai_driver mtk_dai_etdm_driver[] = …;
static void mt8188_etdm_update_sync_info(struct mtk_base_afe *afe)
{ … }
static void mt8188_dai_etdm_parse_of(struct mtk_base_afe *afe)
{ … }
static int init_etdm_priv_data(struct mtk_base_afe *afe)
{ … }
int mt8188_dai_etdm_register(struct mtk_base_afe *afe)
{ … }