sound/soc/intel/avs/boards/nau8825.c

Source file repositories/reference/linux-study-clean/sound/soc/intel/avs/boards/nau8825.c

File Facts

System
Linux kernel
Corpus path
sound/soc/intel/avs/boards/nau8825.c
Extension
.c
Size
9167 bytes
Lines
316
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 (ret < 0) {
			dev_err(codec_dai->dev, "can't set FS clock %d\n", ret);
			break;
		}

		ret = snd_soc_dai_set_pll(codec_dai, 0, 0, runtime->rate, runtime->rate * 256);
		if (ret < 0)
			dev_err(codec_dai->dev, "can't set FLL: %d\n", ret);
		break;

	case SNDRV_PCM_TRIGGER_RESUME:
		ret = snd_soc_dai_set_pll(codec_dai, 0, 0, runtime->rate, runtime->rate * 256);
		if (ret < 0)
			dev_err(codec_dai->dev, "can't set FLL: %d\n", ret);
		break;
	}

	return ret;
}


static const struct snd_soc_ops avs_nau8825_ops = {
	.trigger = avs_nau8825_trigger,
};

static int avs_create_dai_link(struct device *dev, int ssp_port, int tdm_slot,
			       struct snd_soc_dai_link **dai_link)
{
	struct snd_soc_dai_link_component *platform;
	struct snd_soc_dai_link *dl;

	dl = devm_kzalloc(dev, sizeof(*dl), GFP_KERNEL);
	platform = devm_kzalloc(dev, sizeof(*platform), GFP_KERNEL);
	if (!dl || !platform)
		return -ENOMEM;

	dl->name = devm_kasprintf(dev, GFP_KERNEL,
				  AVS_STRING_FMT("SSP", "-Codec", ssp_port, tdm_slot));
	dl->cpus = devm_kzalloc(dev, sizeof(*dl->cpus), GFP_KERNEL);
	dl->codecs = devm_kzalloc(dev, sizeof(*dl->codecs), GFP_KERNEL);
	if (!dl->name || !dl->cpus || !dl->codecs)
		return -ENOMEM;

	dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL,
					    AVS_STRING_FMT("SSP", " Pin", ssp_port, tdm_slot));
	dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-10508825:00");
	dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, SKL_NUVOTON_CODEC_DAI);
	if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name)
		return -ENOMEM;

	platform->name = dev_name(dev);
	dl->num_cpus = 1;
	dl->num_codecs = 1;
	dl->platforms = platform;
	dl->num_platforms = 1;
	dl->id = 0;
	dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC;
	dl->init = avs_nau8825_codec_init;
	dl->exit = avs_nau8825_codec_exit;
	dl->be_hw_params_fixup = avs_nau8825_be_fixup;
	dl->ops = &avs_nau8825_ops;
	dl->nonatomic = 1;
	dl->no_pcm = 1;

	*dai_link = dl;

	return 0;
}

static int avs_card_suspend_pre(struct snd_soc_card *card)
{
	struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);

	return snd_soc_component_set_jack(codec_dai->component, NULL, NULL);
}

static int avs_card_resume_post(struct snd_soc_card *card)
{
	struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, SKL_NUVOTON_CODEC_DAI);
	struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card);
	int stream = SNDRV_PCM_STREAM_PLAYBACK;

	if (!codec_dai) {
		dev_err(card->dev, "Codec dai not found\n");
		return -EINVAL;
	}

	if (snd_soc_dai_stream_active(codec_dai, stream) &&
	    snd_soc_dai_get_widget(codec_dai, stream)->active)
		snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_FS, 0, SND_SOC_CLOCK_IN);

Annotation

Implementation Notes