summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2022-11-29 16:56:44 +0000
committerMark Brown <broonie@kernel.org>2022-11-29 16:56:44 +0000
commitf4f473f8392534a027f1db5f887ac01a9f0e8905 (patch)
treead4d225596cce4c3e4bee90f0af0d4ed61ca20a2 /sound
parente8679db2970f04ee5281c042977fff880a3c045a (diff)
parent28baae9bfc1fb9fdaff2e8bd328b2a5b12a14273 (diff)
ASoC: Intel: avs: Refactor jack handling
Merge series from Cezary Rojewski <cezary.rojewski@intel.com>: For all the boards included in this patchset, a similar set of changes is proposed: 1) Move jack unassignment from platform_device->remove() to dai_link->exit(). This is done to make jack init and deinit flows symmetric 2) Remove platform_device->remove() function 3) Simplify card->suspend_pre() and card->resume_post() by making use of snd_soc_card_get_codec_dai() helper While bdw_rt286 board - which is utilized by the catpt-driver - is definitely not part of "avs", same treatment applies. And thus decided to make it part of this series instead of sending it separately.
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/intel/avs/boards/da7219.c34
-rw-r--r--sound/soc/intel/avs/boards/nau8825.c35
-rw-r--r--sound/soc/intel/avs/boards/rt274.c30
-rw-r--r--sound/soc/intel/avs/boards/rt286.c37
-rw-r--r--sound/soc/intel/avs/boards/rt298.c37
-rw-r--r--sound/soc/intel/boards/bdw_rt286.c55
6 files changed, 82 insertions, 146 deletions
diff --git a/sound/soc/intel/avs/boards/da7219.c b/sound/soc/intel/avs/boards/da7219.c
index ad86cef101cc..acd43b6108e9 100644
--- a/sound/soc/intel/avs/boards/da7219.c
+++ b/sound/soc/intel/avs/boards/da7219.c
@@ -72,10 +72,10 @@ static const struct snd_soc_dapm_route card_base_routes[] = {
static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime)
{
- struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(runtime, 0);
+ struct snd_soc_component *component = codec_dai->component;
struct snd_soc_card *card = runtime->card;
struct snd_soc_jack *jack;
- struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(runtime, 0);
int clk_freq;
int ret;
@@ -109,9 +109,12 @@ static int avs_da7219_codec_init(struct snd_soc_pcm_runtime *runtime)
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND);
- snd_soc_component_set_jack(component, jack, NULL);
+ return snd_soc_component_set_jack(component, jack, NULL);
+}
- return 0;
+static void avs_da7219_codec_exit(struct snd_soc_pcm_runtime *rtd)
+{
+ snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL);
}
static int avs_create_dai_link(struct device *dev, const char *platform_name, int ssp_port,
@@ -146,6 +149,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->id = 0;
dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
dl->init = avs_da7219_codec_init;
+ dl->exit = avs_da7219_codec_exit;
dl->nonatomic = 1;
dl->no_pcm = 1;
dl->dpcm_capture = 1;
@@ -188,30 +192,19 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port,
return 0;
}
-static int avs_card_set_jack(struct snd_soc_card *card, struct snd_soc_jack *jack)
-{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component)
- snd_soc_component_set_jack(component, jack, NULL);
- return 0;
-}
-
-static int avs_card_remove(struct snd_soc_card *card)
-{
- return avs_card_set_jack(card, NULL);
-}
-
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
- return avs_card_set_jack(card, NULL);
+ struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, DA7219_DAI_NAME);
+
+ 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, DA7219_DAI_NAME);
struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card);
- return avs_card_set_jack(card, jack);
+ return snd_soc_component_set_jack(codec_dai->component, jack, NULL);
}
static int avs_da7219_probe(struct platform_device *pdev)
@@ -249,7 +242,6 @@ static int avs_da7219_probe(struct platform_device *pdev)
card->name = "avs_da7219";
card->dev = dev;
card->owner = THIS_MODULE;
- card->remove = avs_card_remove;
card->suspend_pre = avs_card_suspend_pre;
card->resume_post = avs_card_resume_post;
card->dai_link = dai_link;
diff --git a/sound/soc/intel/avs/boards/nau8825.c b/sound/soc/intel/avs/boards/nau8825.c
index f76909e9f990..6731d8a49076 100644
--- a/sound/soc/intel/avs/boards/nau8825.c
+++ b/sound/soc/intel/avs/boards/nau8825.c
@@ -79,11 +79,9 @@ static struct snd_soc_jack_pin card_headset_pins[] = {
static int avs_nau8825_codec_init(struct snd_soc_pcm_runtime *runtime)
{
- struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(runtime, 0);
- struct snd_soc_component *component = codec_dai->component;
+ struct snd_soc_card *card = runtime->card;
struct snd_soc_jack_pin *pins;
struct snd_soc_jack *jack;
- struct snd_soc_card *card = runtime->card;
int num_pins, ret;
jack = snd_soc_card_get_drvdata(card);
@@ -108,11 +106,12 @@ static int avs_nau8825_codec_init(struct snd_soc_pcm_runtime *runtime)
snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
- //snd_soc_component_set_jack(component, jack, NULL);
- // TODO: Fix nau8825 codec to use .set_jack, like everyone else
- nau8825_enable_jack_detect(component, jack);
+ return snd_soc_component_set_jack(asoc_rtd_to_codec(runtime, 0)->component, jack, NULL);
+}
- return 0;
+static void avs_nau8825_codec_exit(struct snd_soc_pcm_runtime *rtd)
+{
+ snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL);
}
static int
@@ -203,6 +202,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->id = 0;
dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
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;
@@ -247,23 +247,11 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port,
return 0;
}
-static int avs_card_set_jack(struct snd_soc_card *card, struct snd_soc_jack *jack)
-{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component)
- snd_soc_component_set_jack(component, jack, NULL);
- return 0;
-}
-
-static int avs_card_remove(struct snd_soc_card *card)
-{
- return avs_card_set_jack(card, NULL);
-}
-
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
- return avs_card_set_jack(card, NULL);
+ 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)
@@ -280,7 +268,7 @@ static int avs_card_resume_post(struct snd_soc_card *card)
codec_dai->playback_widget->active)
snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_FS, 0, SND_SOC_CLOCK_IN);
- return avs_card_set_jack(card, jack);
+ return snd_soc_component_set_jack(codec_dai->component, jack, NULL);
}
static int avs_nau8825_probe(struct platform_device *pdev)
@@ -318,7 +306,6 @@ static int avs_nau8825_probe(struct platform_device *pdev)
card->name = "avs_nau8825";
card->dev = dev;
card->owner = THIS_MODULE;
- card->remove = avs_card_remove;
card->suspend_pre = avs_card_suspend_pre;
card->resume_post = avs_card_resume_post;
card->dai_link = dai_link;
diff --git a/sound/soc/intel/avs/boards/rt274.c b/sound/soc/intel/avs/boards/rt274.c
index afef5a3ca60b..6a1e121f082f 100644
--- a/sound/soc/intel/avs/boards/rt274.c
+++ b/sound/soc/intel/avs/boards/rt274.c
@@ -119,6 +119,11 @@ static int avs_rt274_codec_init(struct snd_soc_pcm_runtime *runtime)
return 0;
}
+static void avs_rt274_codec_exit(struct snd_soc_pcm_runtime *rtd)
+{
+ snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL);
+}
+
static int avs_rt274_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params)
{
struct snd_interval *rate, *channels;
@@ -160,7 +165,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port);
dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT34C2:00");
- dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "rt274-aif1");
+ dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT274_CODEC_DAI);
if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name)
return -ENOMEM;
@@ -171,6 +176,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->id = 0;
dl->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
dl->init = avs_rt274_codec_init;
+ dl->exit = avs_rt274_codec_exit;
dl->be_hw_params_fixup = avs_rt274_be_fixup;
dl->nonatomic = 1;
dl->no_pcm = 1;
@@ -214,30 +220,19 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port,
return 0;
}
-static int avs_card_set_jack(struct snd_soc_card *card, struct snd_soc_jack *jack)
-{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component)
- snd_soc_component_set_jack(component, jack, NULL);
- return 0;
-}
-
-static int avs_card_remove(struct snd_soc_card *card)
-{
- return avs_card_set_jack(card, NULL);
-}
-
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
- return avs_card_set_jack(card, NULL);
+ struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, RT274_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, RT274_CODEC_DAI);
struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card);
- return avs_card_set_jack(card, jack);
+ return snd_soc_component_set_jack(codec_dai->component, jack, NULL);
}
static int avs_rt274_probe(struct platform_device *pdev)
@@ -275,7 +270,6 @@ static int avs_rt274_probe(struct platform_device *pdev)
card->name = "avs_rt274";
card->dev = dev;
card->owner = THIS_MODULE;
- card->remove = avs_card_remove;
card->suspend_pre = avs_card_suspend_pre;
card->resume_post = avs_card_resume_post;
card->dai_link = dai_link;
diff --git a/sound/soc/intel/avs/boards/rt286.c b/sound/soc/intel/avs/boards/rt286.c
index e51d4e181274..8447b37a2a41 100644
--- a/sound/soc/intel/avs/boards/rt286.c
+++ b/sound/soc/intel/avs/boards/rt286.c
@@ -14,6 +14,8 @@
#include <sound/soc-acpi.h>
#include "../../../codecs/rt286.h"
+#define RT286_CODEC_DAI "rt286-aif1"
+
static const struct snd_kcontrol_new card_controls[] = {
SOC_DAPM_PIN_SWITCH("Headphone Jack"),
SOC_DAPM_PIN_SWITCH("Mic Jack"),
@@ -48,10 +50,9 @@ static struct snd_soc_jack_pin card_headset_pins[] = {
static int avs_rt286_codec_init(struct snd_soc_pcm_runtime *runtime)
{
- struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
+ struct snd_soc_card *card = runtime->card;
struct snd_soc_jack_pin *pins;
struct snd_soc_jack *jack;
- struct snd_soc_card *card = runtime->card;
int num_pins, ret;
jack = snd_soc_card_get_drvdata(card);
@@ -66,9 +67,12 @@ static int avs_rt286_codec_init(struct snd_soc_pcm_runtime *runtime)
if (ret)
return ret;
- snd_soc_component_set_jack(component, jack, NULL);
+ return snd_soc_component_set_jack(asoc_rtd_to_codec(runtime, 0)->component, jack, NULL);
+}
- return 0;
+static void avs_rt286_codec_exit(struct snd_soc_pcm_runtime *rtd)
+{
+ snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL);
}
static int avs_rt286_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params)
@@ -130,7 +134,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port);
dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343A:00");
- dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "rt286-aif1");
+ dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT286_CODEC_DAI);
if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name)
return -ENOMEM;
@@ -141,6 +145,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->id = 0;
dl->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
dl->init = avs_rt286_codec_init;
+ dl->exit = avs_rt286_codec_exit;
dl->be_hw_params_fixup = avs_rt286_be_fixup;
dl->ops = &avs_rt286_ops;
dl->nonatomic = 1;
@@ -185,30 +190,19 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port,
return 0;
}
-static int avs_card_set_jack(struct snd_soc_card *card, struct snd_soc_jack *jack)
-{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component)
- snd_soc_component_set_jack(component, jack, NULL);
- return 0;
-}
-
-static int avs_card_remove(struct snd_soc_card *card)
-{
- return avs_card_set_jack(card, NULL);
-}
-
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
- return avs_card_set_jack(card, NULL);
+ struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, RT286_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, RT286_CODEC_DAI);
struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card);
- return avs_card_set_jack(card, jack);
+ return snd_soc_component_set_jack(codec_dai->component, jack, NULL);
}
static int avs_rt286_probe(struct platform_device *pdev)
@@ -246,7 +240,6 @@ static int avs_rt286_probe(struct platform_device *pdev)
card->name = "avs_rt286";
card->dev = dev;
card->owner = THIS_MODULE;
- card->remove = avs_card_remove;
card->suspend_pre = avs_card_suspend_pre;
card->resume_post = avs_card_resume_post;
card->dai_link = dai_link;
diff --git a/sound/soc/intel/avs/boards/rt298.c b/sound/soc/intel/avs/boards/rt298.c
index 58c9d9edecf0..bd25f0fde35e 100644
--- a/sound/soc/intel/avs/boards/rt298.c
+++ b/sound/soc/intel/avs/boards/rt298.c
@@ -15,6 +15,8 @@
#include <sound/soc-acpi.h>
#include "../../../codecs/rt298.h"
+#define RT298_CODEC_DAI "rt298-aif1"
+
static const struct dmi_system_id kblr_dmi_table[] = {
{
.matches = {
@@ -59,10 +61,9 @@ static struct snd_soc_jack_pin card_headset_pins[] = {
static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime)
{
- struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component;
+ struct snd_soc_card *card = runtime->card;
struct snd_soc_jack_pin *pins;
struct snd_soc_jack *jack;
- struct snd_soc_card *card = runtime->card;
int num_pins, ret;
jack = snd_soc_card_get_drvdata(card);
@@ -77,9 +78,12 @@ static int avs_rt298_codec_init(struct snd_soc_pcm_runtime *runtime)
if (ret)
return ret;
- snd_soc_component_set_jack(component, jack, NULL);
+ return snd_soc_component_set_jack(asoc_rtd_to_codec(runtime, 0)->component, jack, NULL);
+}
- return 0;
+static void avs_rt298_codec_exit(struct snd_soc_pcm_runtime *rtd)
+{
+ snd_soc_component_set_jack(asoc_rtd_to_codec(rtd, 0)->component, NULL, NULL);
}
static int avs_rt298_be_fixup(struct snd_soc_pcm_runtime *runtime, struct snd_pcm_hw_params *params)
@@ -147,7 +151,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
dl->cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d Pin", ssp_port);
dl->codecs->name = devm_kasprintf(dev, GFP_KERNEL, "i2c-INT343A:00");
- dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, "rt298-aif1");
+ dl->codecs->dai_name = devm_kasprintf(dev, GFP_KERNEL, RT298_CODEC_DAI);
if (!dl->cpus->dai_name || !dl->codecs->name || !dl->codecs->dai_name)
return -ENOMEM;
@@ -161,6 +165,7 @@ static int avs_create_dai_link(struct device *dev, const char *platform_name, in
else
dl->dai_fmt = SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
dl->init = avs_rt298_codec_init;
+ dl->exit = avs_rt298_codec_exit;
dl->be_hw_params_fixup = avs_rt298_be_fixup;
dl->ops = &avs_rt298_ops;
dl->nonatomic = 1;
@@ -205,30 +210,19 @@ static int avs_create_dapm_routes(struct device *dev, int ssp_port,
return 0;
}
-static int avs_card_set_jack(struct snd_soc_card *card, struct snd_soc_jack *jack)
-{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component)
- snd_soc_component_set_jack(component, jack, NULL);
- return 0;
-}
-
-static int avs_card_remove(struct snd_soc_card *card)
-{
- return avs_card_set_jack(card, NULL);
-}
-
static int avs_card_suspend_pre(struct snd_soc_card *card)
{
- return avs_card_set_jack(card, NULL);
+ struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, RT298_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, RT298_CODEC_DAI);
struct snd_soc_jack *jack = snd_soc_card_get_drvdata(card);
- return avs_card_set_jack(card, jack);
+ return snd_soc_component_set_jack(codec_dai->component, jack, NULL);
}
static int avs_rt298_probe(struct platform_device *pdev)
@@ -266,7 +260,6 @@ static int avs_rt298_probe(struct platform_device *pdev)
card->name = "avs_rt298";
card->dev = dev;
card->owner = THIS_MODULE;
- card->remove = avs_card_remove;
card->suspend_pre = avs_card_suspend_pre;
card->resume_post = avs_card_resume_post;
card->dai_link = dai_link;
diff --git a/sound/soc/intel/boards/bdw_rt286.c b/sound/soc/intel/boards/bdw_rt286.c
index 6b76df0e7c9b..b7687a93a923 100644
--- a/sound/soc/intel/boards/bdw_rt286.c
+++ b/sound/soc/intel/boards/bdw_rt286.c
@@ -73,6 +73,13 @@ static int codec_link_init(struct snd_soc_pcm_runtime *rtd)
return snd_soc_component_set_jack(codec, &card_headset, NULL);
}
+static void codec_link_exit(struct snd_soc_pcm_runtime *rtd)
+{
+ struct snd_soc_component *codec = asoc_rtd_to_codec(rtd, 0)->component;
+
+ snd_soc_component_set_jack(codec, NULL, NULL);
+}
+
static int codec_link_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
@@ -165,6 +172,7 @@ static struct snd_soc_dai_link card_dai_links[] = {
.nonatomic = 1,
.no_pcm = 1,
.init = codec_link_init,
+ .exit = codec_link_exit,
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC,
.ignore_pmdown_time = 1,
.be_hw_params_fixup = codec_link_hw_params_fixup,
@@ -175,43 +183,24 @@ static struct snd_soc_dai_link card_dai_links[] = {
},
};
-static void bdw_rt286_disable_jack(struct snd_soc_card *card)
-{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component) {
- if (!strcmp(component->name, "i2c-INT343A:00")) {
- dev_dbg(component->dev, "disabling jack detect before going to suspend.\n");
- snd_soc_component_set_jack(component, NULL, NULL);
- break;
- }
- }
-}
-
-static int bdw_rt286_suspend(struct snd_soc_card *card)
+static int card_suspend_pre(struct snd_soc_card *card)
{
- bdw_rt286_disable_jack(card);
+ struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1");
- return 0;
+ return snd_soc_component_set_jack(codec_dai->component, NULL, NULL);
}
-static int bdw_rt286_resume(struct snd_soc_card *card)
+static int card_resume_post(struct snd_soc_card *card)
{
- struct snd_soc_component *component;
-
- for_each_card_components(card, component) {
- if (!strcmp(component->name, "i2c-INT343A:00")) {
- dev_dbg(component->dev, "enabling jack detect for resume.\n");
- snd_soc_component_set_jack(component, &card_headset, NULL);
- break;
- }
- }
+ struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1");
- return 0;
+ return snd_soc_component_set_jack(codec_dai->component, &card_headset, NULL);
}
static struct snd_soc_card bdw_rt286_card = {
.owner = THIS_MODULE,
+ .suspend_pre = card_suspend_pre,
+ .resume_post = card_resume_post,
.dai_link = card_dai_links,
.num_links = ARRAY_SIZE(card_dai_links),
.controls = card_controls,
@@ -221,8 +210,6 @@ static struct snd_soc_card bdw_rt286_card = {
.dapm_routes = card_routes,
.num_dapm_routes = ARRAY_SIZE(card_routes),
.fully_routed = true,
- .suspend_pre = bdw_rt286_suspend,
- .resume_post = bdw_rt286_resume,
};
/* Use space before codec name to simplify card ID, and simplify driver name. */
@@ -254,18 +241,8 @@ static int bdw_rt286_probe(struct platform_device *pdev)
return devm_snd_soc_register_card(dev, &bdw_rt286_card);
}
-static int bdw_rt286_remove(struct platform_device *pdev)
-{
- struct snd_soc_card *card = platform_get_drvdata(pdev);
-
- bdw_rt286_disable_jack(card);
-
- return 0;
-}
-
static struct platform_driver bdw_rt286_driver = {
.probe = bdw_rt286_probe,
- .remove = bdw_rt286_remove,
.driver = {
.name = "bdw_rt286",
.pm = &snd_soc_pm_ops