sound/soc/codecs/lpass-wsa-macro.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/lpass-wsa-macro.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/lpass-wsa-macro.c
Extension
.c
Size
96028 bytes
Lines
2938
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct interp_sample_rate {
	int sample_rate;
	int rate_val;
};

static struct interp_sample_rate int_prim_sample_rate_val[] = {
	{8000, 0x0},	/* 8K */
	{16000, 0x1},	/* 16K */
	{24000, -EINVAL},/* 24K */
	{32000, 0x3},	/* 32K */
	{48000, 0x4},	/* 48K */
	{96000, 0x5},	/* 96K */
	{192000, 0x6},	/* 192K */
	{384000, 0x7},	/* 384K */
	{44100, 0x8}, /* 44.1K */
};

static struct interp_sample_rate int_mix_sample_rate_val[] = {
	{48000, 0x4},	/* 48K */
	{96000, 0x5},	/* 96K */
	{192000, 0x6},	/* 192K */
};

/* Matches also rx_mux_text */
enum {
	WSA_MACRO_AIF1_PB,
	WSA_MACRO_AIF_MIX1_PB,
	WSA_MACRO_AIF_VI,
	WSA_MACRO_AIF_ECHO,
	WSA_MACRO_MAX_DAIS,
};

/**
 * struct wsa_reg_layout - Register layout differences
 * @rx_intx_1_mix_inp0_sel_mask: register mask for RX_INTX_1_MIX_INP0_SEL_MASK
 * @rx_intx_1_mix_inp1_sel_mask: register mask for RX_INTX_1_MIX_INP1_SEL_MASK
 * @rx_intx_1_mix_inp2_sel_mask: register mask for RX_INTX_1_MIX_INP2_SEL_MASK
 * @rx_intx_2_sel_mask: register mask for RX_INTX_2_SEL_MASK
 * @compander1_reg_offset: offset between compander registers (compander1 - compander0)
 * @softclip0_reg_base: base address of softclip0 register
 * @softclip1_reg_offset: offset between compander registers (softclip1 - softclip0)
 */
struct wsa_reg_layout {
	unsigned int rx_intx_1_mix_inp0_sel_mask;
	unsigned int rx_intx_1_mix_inp1_sel_mask;
	unsigned int rx_intx_1_mix_inp2_sel_mask;
	unsigned int rx_intx_2_sel_mask;
	unsigned int compander1_reg_offset;
	unsigned int softclip0_reg_base;
	unsigned int softclip1_reg_offset;
};

struct wsa_macro {
	struct device *dev;
	int comp_enabled[WSA_MACRO_COMP_MAX];
	int ec_hq[WSA_MACRO_RX1 + 1];
	u16 prim_int_users[WSA_MACRO_RX1 + 1];
	u16 wsa_mclk_users;
	enum lpass_codec_version codec_version;
	const struct wsa_reg_layout *reg_layout;
	unsigned long active_ch_mask[WSA_MACRO_MAX_DAIS];
	unsigned long active_ch_cnt[WSA_MACRO_MAX_DAIS];
	int rx_port_value[WSA_MACRO_RX_MAX];
	int ear_spkr_gain;
	int spkr_gain_offset;
	int spkr_mode;
	u32 pcm_rate_vi;
	int is_softclip_on[WSA_MACRO_SOFTCLIP_MAX];
	int softclip_clk_users[WSA_MACRO_SOFTCLIP_MAX];
	struct regmap *regmap;
	struct clk *mclk;
	struct clk *npl;
	struct clk *macro;
	struct clk *dcodec;
	struct clk *fsgen;
	struct clk_hw hw;
};
#define to_wsa_macro(_hw) container_of(_hw, struct wsa_macro, hw)

static const struct wsa_reg_layout wsa_codec_v2_1 = {
	.rx_intx_1_mix_inp0_sel_mask		= GENMASK(2, 0),
	.rx_intx_1_mix_inp1_sel_mask		= GENMASK(5, 3),
	.rx_intx_1_mix_inp2_sel_mask		= GENMASK(5, 3),
	.rx_intx_2_sel_mask			= GENMASK(2, 0),
	.compander1_reg_offset			= 0x40,
	.softclip0_reg_base			= 0x600,
	.softclip1_reg_offset			= 0x40,
};

static const struct wsa_reg_layout wsa_codec_v2_5 = {

Annotation

Implementation Notes