Skip to content

Commit

Permalink
Fixed 48k timing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
IQaudIO authored and pelwell committed Jun 11, 2019
1 parent 4395da0 commit 2a64d23
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions sound/soc/bcm/iqaudio-codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ static int snd_rpi_iqaudio_pll_control(struct snd_soc_dapm_widget *w,
0);
if (ret)
dev_err(card->dev, "Failed to bypass PLL: %d\n", ret);
/* Allow PLL time to bypass */
msleep(100);
} else if (SND_SOC_DAPM_EVENT_ON(event)) {
ret = snd_soc_dai_set_pll(codec_dai, 0, DA7213_SYSCLK_PLL, 0,
pll_out);
if (ret)
dev_err(card->dev, "Failed to enable PLL: %d\n", ret);
/* Allow PLL time to lock */
msleep(100);
}

return ret;
Expand All @@ -71,6 +75,13 @@ static int snd_rpi_iqaudio_post_dapm_event(struct snd_soc_dapm_widget *w,
return 0;
}

static const struct snd_kcontrol_new dapm_controls[] = {
SOC_DAPM_PIN_SWITCH("HP Jack"),
SOC_DAPM_PIN_SWITCH("MIC Jack"),
SOC_DAPM_PIN_SWITCH("Onboard MIC"),
SOC_DAPM_PIN_SWITCH("AUX Jack"),
};

static const struct snd_soc_dapm_widget dapm_widgets[] = {
SND_SOC_DAPM_HP("HP Jack", NULL),
SND_SOC_DAPM_MIC("MIC Jack", NULL),
Expand All @@ -87,14 +98,14 @@ static const struct snd_soc_dapm_route audio_map[] = {
{"HP Jack", NULL, "HPR"},
{"HP Jack", NULL, "PLL Control"},

{"AUX Jack", NULL, "AUXR"},
{"AUX Jack", NULL, "AUXL"},
{"AUXR", NULL, "AUX Jack"},
{"AUXL", NULL, "AUX Jack"},
{"AUX Jack", NULL, "PLL Control"},

/* Assume Mic1 is linked to Headset and Mic2 to on-board mic */
{"MIC Jack", NULL, "MIC1"},
{"MIC1", NULL, "MIC Jack"},
{"MIC Jack", NULL, "PLL Control"},
{"Onboard MIC", NULL, "MIC2"},
{"MIC2", NULL, "Onboard MIC"},
{"Onboard MIC", NULL, "PLL Control"},
};

Expand All @@ -106,6 +117,16 @@ static int snd_rpi_iqaudio_codec_init(struct snd_soc_pcm_runtime *rtd)
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
int ret;

/*
* Disable AUX Jack Pin by default to prevent PLL being enabled at
* startup. This avoids holding the PLL to a fixed SR config for
* subsequent streams.
*
* This pin can still be enabled later, as required by user-space.
*/
snd_soc_dapm_disable_pin(&rtd->card->dapm, "AUX Jack");
snd_soc_dapm_sync(&rtd->card->dapm);

/* Set bclk ratio to align with codec's BCLK rate */
ret = snd_soc_dai_set_bclk_ratio(cpu_dai, 64);
if (ret) {
Expand Down Expand Up @@ -168,6 +189,8 @@ static struct snd_soc_card snd_rpi_iqaudio_codec = {
.owner = THIS_MODULE,
.dai_link = snd_rpi_iqaudio_codec_dai,
.num_links = ARRAY_SIZE(snd_rpi_iqaudio_codec_dai),
.controls = dapm_controls,
.num_controls = ARRAY_SIZE(dapm_controls),
.dapm_widgets = dapm_widgets,
.num_dapm_widgets = ARRAY_SIZE(dapm_widgets),
.dapm_routes = audio_map,
Expand Down Expand Up @@ -204,7 +227,7 @@ static int snd_rpi_iqaudio_codec_probe(struct platform_device *pdev)

if (of_property_read_string(pdev->dev.of_node,
"dai_stream_name", &dai->stream_name))
dai->stream_name = "IQaudIO CODEC HiFi v1.1";
dai->stream_name = "IQaudIO CODEC HiFi v1.2";

}

Expand Down

0 comments on commit 2a64d23

Please sign in to comment.