sound/soc/codecs/ak4118.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/ak4118.c
Extension
.c
Size
11376 bytes
Lines
417
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 ak4118_priv {
	struct regmap *regmap;
	struct gpio_desc *reset;
	struct gpio_desc *irq;
	struct snd_soc_component *component;
};

static const struct reg_default ak4118_reg_defaults[] = {
	{AK4118_REG_CLK_PWR_CTL,	0x43},
	{AK4118_REG_FORMAT_CTL,		0x6a},
	{AK4118_REG_IO_CTL0,		0x88},
	{AK4118_REG_IO_CTL1,		0x48},
	{AK4118_REG_INT0_MASK,		0xee},
	{AK4118_REG_INT1_MASK,		0xb5},
	{AK4118_REG_RCV_STATUS0,	0x00},
	{AK4118_REG_RCV_STATUS1,	0x10},
	{AK4118_REG_TXCHAN_STATUS0,	0x00},
	{AK4118_REG_TXCHAN_STATUS1,	0x00},
	{AK4118_REG_TXCHAN_STATUS2,	0x00},
	{AK4118_REG_TXCHAN_STATUS3,	0x00},
	{AK4118_REG_TXCHAN_STATUS4,	0x00},
	{AK4118_REG_GPE,		0x77},
	{AK4118_REG_GPDR,		0x00},
	{AK4118_REG_GPSCR,		0x00},
	{AK4118_REG_GPLR,		0x00},
	{AK4118_REG_DAT_MASK_DTS,	0x3f},
	{AK4118_REG_RX_DETECT,		0x00},
	{AK4118_REG_STC_DAT_DETECT,	0x00},
	{AK4118_REG_TXCHAN_STATUS5,	0x00},
};

static const char * const ak4118_input_select_txt[] = {
	"RX0", "RX1", "RX2", "RX3", "RX4", "RX5", "RX6", "RX7",
};
static SOC_ENUM_SINGLE_DECL(ak4118_insel_enum, AK4118_REG_IO_CTL1, 0x0,
			    ak4118_input_select_txt);

static const struct snd_kcontrol_new ak4118_input_mux_controls =
	SOC_DAPM_ENUM("Input Select", ak4118_insel_enum);

static const char * const ak4118_iec958_fs_txt[] = {
	"44100", "48000", "32000", "22050", "11025", "24000", "16000", "88200",
	"8000", "96000", "64000", "176400", "192000",
};

static const int ak4118_iec958_fs_val[] = {
	0x0, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xE,
};

static SOC_VALUE_ENUM_SINGLE_DECL(ak4118_iec958_fs_enum, AK4118_REG_RCV_STATUS1,
				  0x4, 0x4, ak4118_iec958_fs_txt,
				  ak4118_iec958_fs_val);

static struct snd_kcontrol_new ak4118_iec958_controls[] = {
	SOC_SINGLE("IEC958 Parity Errors", AK4118_REG_RCV_STATUS0, 0, 1, 0),
	SOC_SINGLE("IEC958 No Audio", AK4118_REG_RCV_STATUS0, 1, 1, 0),
	SOC_SINGLE("IEC958 PLL Lock", AK4118_REG_RCV_STATUS0, 4, 1, 1),
	SOC_SINGLE("IEC958 Non PCM", AK4118_REG_RCV_STATUS0, 6, 1, 0),
	SOC_ENUM("IEC958 Sampling Freq", ak4118_iec958_fs_enum),
};

static const struct snd_soc_dapm_widget ak4118_dapm_widgets[] = {
	SND_SOC_DAPM_INPUT("INRX0"),
	SND_SOC_DAPM_INPUT("INRX1"),
	SND_SOC_DAPM_INPUT("INRX2"),
	SND_SOC_DAPM_INPUT("INRX3"),
	SND_SOC_DAPM_INPUT("INRX4"),
	SND_SOC_DAPM_INPUT("INRX5"),
	SND_SOC_DAPM_INPUT("INRX6"),
	SND_SOC_DAPM_INPUT("INRX7"),
	SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, 0, 0,
			 &ak4118_input_mux_controls),
};

static const struct snd_soc_dapm_route ak4118_dapm_routes[] = {
	{"Input Mux", "RX0", "INRX0"},
	{"Input Mux", "RX1", "INRX1"},
	{"Input Mux", "RX2", "INRX2"},
	{"Input Mux", "RX3", "INRX3"},
	{"Input Mux", "RX4", "INRX4"},
	{"Input Mux", "RX5", "INRX5"},
	{"Input Mux", "RX6", "INRX6"},
	{"Input Mux", "RX7", "INRX7"},
};


static int ak4118_set_dai_fmt_provider(struct ak4118_priv *ak4118,
				       unsigned int format)
{
	int dif;

Annotation

Implementation Notes