Commit 2998369f authored by Rohit kumar's avatar Rohit kumar Committed by Mark Brown

ASoC: sdm845: set jack only for a specific backend

Headset codec is connected over PRIMARY_MI2S interface. Call
set_jack for codec associated with Primary Mi2s interface.
Also, set_jack to NULL when jack is freed.
Signed-off-by: default avatarRohit kumar <rohitkr@codeaurora.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent a7a850db
...@@ -158,17 +158,24 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream, ...@@ -158,17 +158,24 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream,
return ret; return ret;
} }
static void sdm845_jack_free(struct snd_jack *jack)
{
struct snd_soc_component *component = jack->private_data;
snd_soc_component_set_jack(component, NULL, NULL);
}
static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
{ {
struct snd_soc_component *component; struct snd_soc_component *component;
struct snd_soc_dai_link *dai_link = rtd->dai_link;
struct snd_soc_card *card = rtd->card; struct snd_soc_card *card = rtd->card;
struct snd_soc_dai *codec_dai = rtd->codec_dai;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card); struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card);
int i, rval; struct snd_jack *jack;
int rval;
if (!pdata->jack_setup) { if (!pdata->jack_setup) {
struct snd_jack *jack;
rval = snd_soc_card_jack_new(card, "Headset Jack", rval = snd_soc_card_jack_new(card, "Headset Jack",
SND_JACK_HEADSET | SND_JACK_HEADSET |
SND_JACK_HEADPHONE | SND_JACK_HEADPHONE |
...@@ -190,16 +197,22 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) ...@@ -190,16 +197,22 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
pdata->jack_setup = true; pdata->jack_setup = true;
} }
for (i = 0 ; i < dai_link->num_codecs; i++) { switch (cpu_dai->id) {
struct snd_soc_dai *dai = rtd->codec_dais[i]; case PRIMARY_MI2S_RX:
jack = pdata->jack.jack;
component = codec_dai->component;
component = dai->component; jack->private_data = component;
rval = snd_soc_component_set_jack( jack->private_free = sdm845_jack_free;
component, &pdata->jack, NULL); rval = snd_soc_component_set_jack(component,
&pdata->jack, NULL);
if (rval != 0 && rval != -ENOTSUPP) { if (rval != 0 && rval != -ENOTSUPP) {
dev_warn(card->dev, "Failed to set jack: %d\n", rval); dev_warn(card->dev, "Failed to set jack: %d\n", rval);
return rval; return rval;
} }
break;
default:
break;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment