sound/soc/codecs/max98926.c

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

File Facts

System
Linux kernel
Corpus path
sound/soc/codecs/max98926.c
Extension
.c
Size
16384 bytes
Lines
594
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

if (rate_table[i].rate >= rate) {
			dai_sr = rate_table[i].sr;
			break;
		}
	}
	if (dai_sr < 0)
		return -EINVAL;

	/* set DAI_SR to correct LRCLK frequency */
	regmap_update_bits(max98926->regmap,
		MAX98926_DAI_CLK_MODE2,
		MAX98926_DAI_SR_MASK, dai_sr << MAX98926_DAI_SR_SHIFT);
	return 0;
}

#define MAX98926_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \
		SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)

static const struct snd_soc_dai_ops max98926_dai_ops = {
	.set_fmt = max98926_dai_set_fmt,
	.hw_params = max98926_dai_hw_params,
};

static struct snd_soc_dai_driver max98926_dai[] = {
{
	.name = "max98926-aif1",
	.playback = {
		.stream_name = "HiFi Playback",
		.channels_min = 1,
		.channels_max = 2,
		.rates = SNDRV_PCM_RATE_8000_48000,
		.formats = MAX98926_FORMATS,
	},
	.capture = {
		.stream_name = "HiFi Capture",
		.channels_min = 1,
		.channels_max = 2,
		.rates = SNDRV_PCM_RATE_8000_48000,
		.formats = MAX98926_FORMATS,
	},
	.ops = &max98926_dai_ops,
}
};

static int max98926_probe(struct snd_soc_component *component)
{
	struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component);

	max98926->component = component;

	/* Hi-Z all the slots */
	regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG4, 0xF0);
	return 0;
}

static const struct snd_soc_component_driver soc_component_dev_max98926 = {
	.probe			= max98926_probe,
	.controls		= max98926_snd_controls,
	.num_controls		= ARRAY_SIZE(max98926_snd_controls),
	.dapm_routes		= max98926_audio_map,
	.num_dapm_routes	= ARRAY_SIZE(max98926_audio_map),
	.dapm_widgets		= max98926_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(max98926_dapm_widgets),
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
};

static const struct regmap_config max98926_regmap = {
	.reg_bits	= 8,
	.val_bits	= 8,
	.max_register	= MAX98926_VERSION,
	.reg_defaults	= max98926_reg,
	.num_reg_defaults = ARRAY_SIZE(max98926_reg),
	.volatile_reg	= max98926_volatile_register,
	.readable_reg	= max98926_readable_register,
	.cache_type		= REGCACHE_RBTREE,
};

static int max98926_i2c_probe(struct i2c_client *i2c)
{
	int ret, reg;
	u32 value;
	struct max98926_priv *max98926;

	max98926 = devm_kzalloc(&i2c->dev,
			sizeof(*max98926), GFP_KERNEL);
	if (!max98926)
		return -ENOMEM;

Annotation

Implementation Notes