sound/soc/generic/test-component.c

Source file repositories/reference/linux-study-clean/sound/soc/generic/test-component.c

File Facts

System
Linux kernel
Corpus path
sound/soc/generic/test-component.c
Extension
.c
Size
16605 bytes
Lines
651
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 test_dai_name {
	char name[TEST_NAME_LEN];
	char name_playback[TEST_NAME_LEN];
	char name_capture[TEST_NAME_LEN];
};

struct test_priv {
	struct device *dev;
	struct snd_pcm_substream *substream;
	struct delayed_work dwork;
	struct snd_soc_component_driver *component_driver;
	struct snd_soc_dai_driver *dai_driver;
	struct test_dai_name *name;
};

struct test_adata {
	u32 is_cpu:1;
	u32 cmp_v:1;
	u32 dai_v:1;
};

#define mile_stone(d)		dev_info((d)->dev, "%s() : %s", __func__, (d)->driver->name)
#define mile_stone_x(dev)	dev_info(dev, "%s()", __func__)

static int test_dai_set_sysclk(struct snd_soc_dai *dai,
			       int clk_id, unsigned int freq, int dir)
{
	mile_stone(dai);

	return 0;
}

static int test_dai_set_pll(struct snd_soc_dai *dai, int pll_id, int source,
			    unsigned int freq_in, unsigned int freq_out)
{
	mile_stone(dai);

	return 0;
}

static int test_dai_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
{
	mile_stone(dai);

	return 0;
}

static int test_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
	unsigned int format = fmt & SND_SOC_DAIFMT_FORMAT_MASK;
	unsigned int clock  = fmt & SND_SOC_DAIFMT_CLOCK_MASK;
	unsigned int inv    = fmt & SND_SOC_DAIFMT_INV_MASK;
	unsigned int master = fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK;
	char *str;

	dev_info(dai->dev, "name   : %s", dai->name);

	str = "unknown";
	switch (format) {
	case SND_SOC_DAIFMT_I2S:
		str = "i2s";
		break;
	case SND_SOC_DAIFMT_RIGHT_J:
		str = "right_j";
		break;
	case SND_SOC_DAIFMT_LEFT_J:
		str = "left_j";
		break;
	case SND_SOC_DAIFMT_DSP_A:
		str = "dsp_a";
		break;
	case SND_SOC_DAIFMT_DSP_B:
		str = "dsp_b";
		break;
	case SND_SOC_DAIFMT_AC97:
		str = "ac97";
		break;
	case SND_SOC_DAIFMT_PDM:
		str = "pdm";
		break;
	}
	dev_info(dai->dev, "format : %s", str);

	if (clock == SND_SOC_DAIFMT_CONT)
		str = "continuous";
	else
		str = "gated";
	dev_info(dai->dev, "clock  : %s", str);

	str = "unknown";

Annotation

Implementation Notes