Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: dpcm: Add API for DAI link substream and runtime lookup

Some component drivers will need to be able to look up their
DAI link substream and RTD data. Provide a mechanism for this.

Signed-off-by: Liam Girdwood <lrg@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Liam Girdwood and committed by
Mark Brown
47c88fff 618dae11

+34
+5
include/sound/soc.h
··· 362 362 unsigned int reg, unsigned int val); 363 363 int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num); 364 364 365 + struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, 366 + const char *dai_link, int stream); 367 + struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, 368 + const char *dai_link); 369 + 365 370 /* Utility functions to get clock rates from various things */ 366 371 int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots); 367 372 int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
+29
sound/soc/soc-core.c
··· 465 465 } 466 466 #endif 467 467 468 + struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card, 469 + const char *dai_link, int stream) 470 + { 471 + int i; 472 + 473 + for (i = 0; i < card->num_links; i++) { 474 + if (card->rtd[i].dai_link->no_pcm && 475 + !strcmp(card->rtd[i].dai_link->name, dai_link)) 476 + return card->rtd[i].pcm->streams[stream].substream; 477 + } 478 + dev_dbg(card->dev, "failed to find dai link %s\n", dai_link); 479 + return NULL; 480 + } 481 + EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); 482 + 483 + struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card, 484 + const char *dai_link) 485 + { 486 + int i; 487 + 488 + for (i = 0; i < card->num_links; i++) { 489 + if (!strcmp(card->rtd[i].dai_link->name, dai_link)) 490 + return &card->rtd[i]; 491 + } 492 + dev_dbg(card->dev, "failed to find rtd %s\n", dai_link); 493 + return NULL; 494 + } 495 + EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); 496 + 468 497 #ifdef CONFIG_SND_SOC_AC97_BUS 469 498 /* unregister ac97 codec */ 470 499 static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)