sound/soc/codecs/tas2552.c

Source file repositories/reference/linux-study-clean/sound/soc/codecs/tas2552.c

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/tas2552.c
Extension
.c
Size
21109 bytes
Lines
777
Domain
Driver Families
Bucket
sound/soc
Inferred role
Driver Families: implementation source
Status
source 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 tas2552_data {
	struct snd_soc_component *component;
	struct regmap *regmap;
	struct i2c_client *tas2552_client;
	struct regulator_bulk_data supplies[TAS2552_NUM_SUPPLIES];
	struct gpio_desc *enable_gpio;
	unsigned char regs[TAS2552_VBAT_DATA];
	unsigned int pll_clkin;
	int pll_clk_id;
	unsigned int pdm_clk;
	int pdm_clk_id;

	unsigned int dai_fmt;
	unsigned int tdm_delay;
};

static int tas2552_post_event(struct snd_soc_dapm_widget *w,
			      struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);

	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
		snd_soc_component_write(component, TAS2552_RESERVED_0D, 0xc0);
		snd_soc_component_update_bits(component, TAS2552_LIMIT_RATE_HYS, (1 << 5),
				    (1 << 5));
		snd_soc_component_update_bits(component, TAS2552_CFG_2, 1, 0);
		snd_soc_component_update_bits(component, TAS2552_CFG_1, TAS2552_SWS, 0);
		break;
	case SND_SOC_DAPM_POST_PMD:
		snd_soc_component_update_bits(component, TAS2552_CFG_1, TAS2552_SWS,
				    TAS2552_SWS);
		snd_soc_component_update_bits(component, TAS2552_CFG_2, 1, 1);
		snd_soc_component_update_bits(component, TAS2552_LIMIT_RATE_HYS, (1 << 5), 0);
		snd_soc_component_write(component, TAS2552_RESERVED_0D, 0xbe);
		break;
	}
	return 0;
}

/* Input mux controls */
static const char * const tas2552_input_texts[] = {
	"Digital", "Analog" };
static SOC_ENUM_SINGLE_DECL(tas2552_input_mux_enum, TAS2552_CFG_3, 7,
			    tas2552_input_texts);

static const struct snd_kcontrol_new tas2552_input_mux_control =
	SOC_DAPM_ENUM("Route", tas2552_input_mux_enum);

static const struct snd_soc_dapm_widget tas2552_dapm_widgets[] =
{
	SND_SOC_DAPM_INPUT("IN"),

	/* MUX Controls */
	SND_SOC_DAPM_MUX("Input selection", SND_SOC_NOPM, 0, 0,
			 &tas2552_input_mux_control),

	SND_SOC_DAPM_AIF_IN("DAC IN", "DAC Playback", 0, SND_SOC_NOPM, 0, 0),
	SND_SOC_DAPM_AIF_OUT("ASI OUT", "DAC Capture", 0, SND_SOC_NOPM, 0, 0),
	SND_SOC_DAPM_DAC("DAC", NULL, SND_SOC_NOPM, 0, 0),
	SND_SOC_DAPM_OUT_DRV("ClassD", TAS2552_CFG_2, 7, 0, NULL, 0),
	SND_SOC_DAPM_SUPPLY("PLL", TAS2552_CFG_2, 3, 0, NULL, 0),
	SND_SOC_DAPM_POST("Post Event", tas2552_post_event),

	SND_SOC_DAPM_OUTPUT("OUT"),
	SND_SOC_DAPM_INPUT("DMIC")
};

static const struct snd_soc_dapm_route tas2552_audio_map[] = {
	{"DAC", NULL, "DAC IN"},
	{"Input selection", "Digital", "DAC"},
	{"Input selection", "Analog", "IN"},
	{"ClassD", NULL, "Input selection"},
	{"OUT", NULL, "ClassD"},
	{"ClassD", NULL, "PLL"},
	{"ASI OUT", NULL, "DMIC"}
};

static void tas2552_sw_shutdown(struct tas2552_data *tas2552, int sw_shutdown)
{
	u8 cfg1_reg = 0;

	if (!tas2552->component)
		return;

	if (sw_shutdown)
		cfg1_reg = TAS2552_SWS;

	snd_soc_component_update_bits(tas2552->component, TAS2552_CFG_1, TAS2552_SWS,
			    cfg1_reg);

Annotation

Implementation Notes