Skip to content

Commit e4c9f52

Browse files
committed
ALSA: hda/cs8409: Rewrite to new probe method
Convert the CS8409 codec driver to use the new hda_codec_ops probe. The Dolphin support needs an override of unsol_event callback, and redirect via spec->unsol_event function pointer for now. Other than that, no functional changes. Reviewed-by: Richard Fitzgerald <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 1cb8744 commit e4c9f52

File tree

3 files changed

+33
-28
lines changed

3 files changed

+33
-28
lines changed

sound/hda/codecs/cirrus/cs8409-tables.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* cs8409-tables.c -- HD audio interface patch for Cirrus Logic CS8409 HDA bridge chip
3+
* cs8409-tables.c -- HD audio codec driver for Cirrus Logic CS8409 HDA bridge chip
44
*
55
* Copyright (C) 2021 Cirrus Logic, Inc. and
66
* Cirrus Logic International Semiconductor Ltd.

sound/hda/codecs/cirrus/cs8409.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22
/*
3-
* HD audio interface patch for Cirrus Logic CS8409 HDA bridge chip
3+
* HD audio codec driver for Cirrus Logic CS8409 HDA bridge chip
44
*
55
* Copyright (C) 2021 Cirrus Logic, Inc. and
66
* Cirrus Logic International Semiconductor Ltd.
@@ -954,15 +954,15 @@ static void cs42l42_suspend(struct sub_codec *cs42l42)
954954
snd_hda_codec_write(codec, CS8409_PIN_AFG, 0, AC_VERB_SET_GPIO_DATA, spec->gpio_data);
955955
}
956956

957-
static void cs8409_free(struct hda_codec *codec)
957+
static void cs8409_remove(struct hda_codec *codec)
958958
{
959959
struct cs8409_spec *spec = codec->spec;
960960

961961
/* Cancel i2c clock disable timer, and disable clock if left enabled */
962962
cancel_delayed_work_sync(&spec->i2c_clk_work);
963963
cs8409_disable_i2c_clock(codec);
964964

965-
snd_hda_gen_free(codec);
965+
snd_hda_gen_remove(codec);
966966
}
967967

968968
/******************************************************************************
@@ -1007,6 +1007,16 @@ static void cs8409_cs42l42_jack_unsol_event(struct hda_codec *codec, unsigned in
10071007
}
10081008
}
10091009

1010+
static void cs8409_unsol_event(struct hda_codec *codec, unsigned int res)
1011+
{
1012+
struct cs8409_spec *spec = codec->spec;
1013+
1014+
if (spec->unsol_event)
1015+
spec->unsol_event(codec, res);
1016+
else
1017+
cs8409_cs42l42_jack_unsol_event(codec, res);
1018+
}
1019+
10101020
/* Manage PDREF, when transition to D3hot */
10111021
static int cs8409_cs42l42_suspend(struct hda_codec *codec)
10121022
{
@@ -1076,15 +1086,6 @@ static void cs8409_cs42l42_hw_init(struct hda_codec *codec)
10761086
cs8409_enable_ur(codec, 1);
10771087
}
10781088

1079-
static const struct hda_codec_ops cs8409_cs42l42_patch_ops = {
1080-
.build_controls = cs8409_build_controls,
1081-
.build_pcms = snd_hda_gen_build_pcms,
1082-
.init = cs8409_init,
1083-
.free = cs8409_free,
1084-
.unsol_event = cs8409_cs42l42_jack_unsol_event,
1085-
.suspend = cs8409_cs42l42_suspend,
1086-
};
1087-
10881089
static int cs8409_cs42l42_exec_verb(struct hdac_device *dev, unsigned int cmd, unsigned int flags,
10891090
unsigned int *res)
10901091
{
@@ -1134,7 +1135,6 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
11341135
spec->scodecs[CS8409_CODEC0] = &cs8409_cs42l42_codec;
11351136
spec->num_scodecs = 1;
11361137
spec->scodecs[CS8409_CODEC0]->codec = codec;
1137-
codec->patch_ops = cs8409_cs42l42_patch_ops;
11381138

11391139
spec->gen.suppress_auto_mute = 1;
11401140
spec->gen.no_primary_hp = 1;
@@ -1304,15 +1304,6 @@ static void dolphin_hw_init(struct hda_codec *codec)
13041304
cs8409_enable_ur(codec, 1);
13051305
}
13061306

1307-
static const struct hda_codec_ops cs8409_dolphin_patch_ops = {
1308-
.build_controls = cs8409_build_controls,
1309-
.build_pcms = snd_hda_gen_build_pcms,
1310-
.init = cs8409_init,
1311-
.free = cs8409_free,
1312-
.unsol_event = dolphin_jack_unsol_event,
1313-
.suspend = cs8409_cs42l42_suspend,
1314-
};
1315-
13161307
static int dolphin_exec_verb(struct hdac_device *dev, unsigned int cmd, unsigned int flags,
13171308
unsigned int *res)
13181309
{
@@ -1371,7 +1362,7 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
13711362
spec->num_scodecs = 2;
13721363
spec->gen.suppress_vmaster = 1;
13731364

1374-
codec->patch_ops = cs8409_dolphin_patch_ops;
1365+
spec->unsol_event = dolphin_jack_unsol_event;
13751366

13761367
/* GPIO 1,5 out, 0,4 in */
13771368
spec->gpio_dir = spec->scodecs[CS8409_CODEC0]->reset_gpio |
@@ -1444,7 +1435,7 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
14441435
}
14451436
}
14461437

1447-
static int patch_cs8409(struct hda_codec *codec)
1438+
static int cs8409_probe(struct hda_codec *codec, const struct hda_device_id *id)
14481439
{
14491440
int err;
14501441

@@ -1461,22 +1452,34 @@ static int patch_cs8409(struct hda_codec *codec)
14611452

14621453
err = cs8409_parse_auto_config(codec);
14631454
if (err < 0) {
1464-
cs8409_free(codec);
1455+
cs8409_remove(codec);
14651456
return err;
14661457
}
14671458

14681459
snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
14691460
return 0;
14701461
}
14711462

1463+
static const struct hda_codec_ops cs8409_codec_ops = {
1464+
.probe = cs8409_probe,
1465+
.remove = cs8409_remove,
1466+
.build_controls = cs8409_build_controls,
1467+
.build_pcms = snd_hda_gen_build_pcms,
1468+
.init = cs8409_init,
1469+
.unsol_event = cs8409_unsol_event,
1470+
.suspend = cs8409_cs42l42_suspend,
1471+
.stream_pm = snd_hda_gen_stream_pm,
1472+
};
1473+
14721474
static const struct hda_device_id snd_hda_id_cs8409[] = {
1473-
HDA_CODEC_ENTRY(0x10138409, "CS8409", patch_cs8409),
1475+
HDA_CODEC_ID(0x10138409, "CS8409"),
14741476
{} /* terminator */
14751477
};
14761478
MODULE_DEVICE_TABLE(hdaudio, snd_hda_id_cs8409);
14771479

14781480
static struct hda_codec_driver cs8409_driver = {
14791481
.id = snd_hda_id_cs8409,
1482+
.ops = &cs8409_codec_ops,
14801483
};
14811484
module_hda_codec_driver(cs8409_driver);
14821485

sound/hda/codecs/cirrus/cs8409.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0-or-later */
22
/*
3-
* HD audio interface patch for Cirrus Logic CS8409 HDA bridge chip
3+
* HD audio codec driver for Cirrus Logic CS8409 HDA bridge chip
44
*
55
* Copyright (C) 2021 Cirrus Logic, Inc. and
66
* Cirrus Logic International Semiconductor Ltd.
@@ -345,6 +345,8 @@ struct cs8409_spec {
345345
/* verb exec op override */
346346
int (*exec_verb)(struct hdac_device *dev, unsigned int cmd, unsigned int flags,
347347
unsigned int *res);
348+
/* unsol_event op override */
349+
void (*unsol_event)(struct hda_codec *codec, unsigned int res);
348350
};
349351

350352
extern const struct snd_kcontrol_new cs42l42_dac_volume_mixer;

0 commit comments

Comments
 (0)