Skip to content

Commit d60a197

Browse files
crojewsk-intelbroonie
authored andcommitted
ASoC: Intel: bdw_rt286: Refactor jack handling
Use link->exit() rather than pdev->remove() to unassign jack during card unbind procedure so codec link initialization and exit procedures are symmetrical. Also, there is no need to perform search for codec dai in suspend_pre() and resume_post() ourselves. Use snd_soc_card_get_codec_dai() instead. Signed-off-by: Cezary Rojewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 4cbb264 commit d60a197

File tree

1 file changed

+16
-39
lines changed

1 file changed

+16
-39
lines changed

sound/soc/intel/boards/bdw_rt286.c

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ static int codec_link_init(struct snd_soc_pcm_runtime *rtd)
7373
return snd_soc_component_set_jack(codec, &card_headset, NULL);
7474
}
7575

76+
static void codec_link_exit(struct snd_soc_pcm_runtime *rtd)
77+
{
78+
struct snd_soc_component *codec = asoc_rtd_to_codec(rtd, 0)->component;
79+
80+
snd_soc_component_set_jack(codec, NULL, NULL);
81+
}
82+
7683
static int codec_link_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
7784
struct snd_pcm_hw_params *params)
7885
{
@@ -165,6 +172,7 @@ static struct snd_soc_dai_link card_dai_links[] = {
165172
.nonatomic = 1,
166173
.no_pcm = 1,
167174
.init = codec_link_init,
175+
.exit = codec_link_exit,
168176
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBC_CFC,
169177
.ignore_pmdown_time = 1,
170178
.be_hw_params_fixup = codec_link_hw_params_fixup,
@@ -175,43 +183,24 @@ static struct snd_soc_dai_link card_dai_links[] = {
175183
},
176184
};
177185

178-
static void bdw_rt286_disable_jack(struct snd_soc_card *card)
179-
{
180-
struct snd_soc_component *component;
181-
182-
for_each_card_components(card, component) {
183-
if (!strcmp(component->name, "i2c-INT343A:00")) {
184-
dev_dbg(component->dev, "disabling jack detect before going to suspend.\n");
185-
snd_soc_component_set_jack(component, NULL, NULL);
186-
break;
187-
}
188-
}
189-
}
190-
191-
static int bdw_rt286_suspend(struct snd_soc_card *card)
186+
static int card_suspend_pre(struct snd_soc_card *card)
192187
{
193-
bdw_rt286_disable_jack(card);
188+
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1");
194189

195-
return 0;
190+
return snd_soc_component_set_jack(codec_dai->component, NULL, NULL);
196191
}
197192

198-
static int bdw_rt286_resume(struct snd_soc_card *card)
193+
static int card_resume_post(struct snd_soc_card *card)
199194
{
200-
struct snd_soc_component *component;
201-
202-
for_each_card_components(card, component) {
203-
if (!strcmp(component->name, "i2c-INT343A:00")) {
204-
dev_dbg(component->dev, "enabling jack detect for resume.\n");
205-
snd_soc_component_set_jack(component, &card_headset, NULL);
206-
break;
207-
}
208-
}
195+
struct snd_soc_dai *codec_dai = snd_soc_card_get_codec_dai(card, "rt286-aif1");
209196

210-
return 0;
197+
return snd_soc_component_set_jack(codec_dai->component, &card_headset, NULL);
211198
}
212199

213200
static struct snd_soc_card bdw_rt286_card = {
214201
.owner = THIS_MODULE,
202+
.suspend_pre = card_suspend_pre,
203+
.resume_post = card_resume_post,
215204
.dai_link = card_dai_links,
216205
.num_links = ARRAY_SIZE(card_dai_links),
217206
.controls = card_controls,
@@ -221,8 +210,6 @@ static struct snd_soc_card bdw_rt286_card = {
221210
.dapm_routes = card_routes,
222211
.num_dapm_routes = ARRAY_SIZE(card_routes),
223212
.fully_routed = true,
224-
.suspend_pre = bdw_rt286_suspend,
225-
.resume_post = bdw_rt286_resume,
226213
};
227214

228215
/* 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)
254241
return devm_snd_soc_register_card(dev, &bdw_rt286_card);
255242
}
256243

257-
static int bdw_rt286_remove(struct platform_device *pdev)
258-
{
259-
struct snd_soc_card *card = platform_get_drvdata(pdev);
260-
261-
bdw_rt286_disable_jack(card);
262-
263-
return 0;
264-
}
265-
266244
static struct platform_driver bdw_rt286_driver = {
267245
.probe = bdw_rt286_probe,
268-
.remove = bdw_rt286_remove,
269246
.driver = {
270247
.name = "bdw_rt286",
271248
.pm = &snd_soc_pm_ops

0 commit comments

Comments
 (0)