1
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
2
/*
3
- * HD audio interface patch for Cirrus Logic CS8409 HDA bridge chip
3
+ * HD audio codec driver for Cirrus Logic CS8409 HDA bridge chip
4
4
*
5
5
* Copyright (C) 2021 Cirrus Logic, Inc. and
6
6
* Cirrus Logic International Semiconductor Ltd.
@@ -954,15 +954,15 @@ static void cs42l42_suspend(struct sub_codec *cs42l42)
954
954
snd_hda_codec_write (codec , CS8409_PIN_AFG , 0 , AC_VERB_SET_GPIO_DATA , spec -> gpio_data );
955
955
}
956
956
957
- static void cs8409_free (struct hda_codec * codec )
957
+ static void cs8409_remove (struct hda_codec * codec )
958
958
{
959
959
struct cs8409_spec * spec = codec -> spec ;
960
960
961
961
/* Cancel i2c clock disable timer, and disable clock if left enabled */
962
962
cancel_delayed_work_sync (& spec -> i2c_clk_work );
963
963
cs8409_disable_i2c_clock (codec );
964
964
965
- snd_hda_gen_free (codec );
965
+ snd_hda_gen_remove (codec );
966
966
}
967
967
968
968
/******************************************************************************
@@ -1007,6 +1007,16 @@ static void cs8409_cs42l42_jack_unsol_event(struct hda_codec *codec, unsigned in
1007
1007
}
1008
1008
}
1009
1009
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
+
1010
1020
/* Manage PDREF, when transition to D3hot */
1011
1021
static int cs8409_cs42l42_suspend (struct hda_codec * codec )
1012
1022
{
@@ -1076,15 +1086,6 @@ static void cs8409_cs42l42_hw_init(struct hda_codec *codec)
1076
1086
cs8409_enable_ur (codec , 1 );
1077
1087
}
1078
1088
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
-
1088
1089
static int cs8409_cs42l42_exec_verb (struct hdac_device * dev , unsigned int cmd , unsigned int flags ,
1089
1090
unsigned int * res )
1090
1091
{
@@ -1134,7 +1135,6 @@ void cs8409_cs42l42_fixups(struct hda_codec *codec, const struct hda_fixup *fix,
1134
1135
spec -> scodecs [CS8409_CODEC0 ] = & cs8409_cs42l42_codec ;
1135
1136
spec -> num_scodecs = 1 ;
1136
1137
spec -> scodecs [CS8409_CODEC0 ]-> codec = codec ;
1137
- codec -> patch_ops = cs8409_cs42l42_patch_ops ;
1138
1138
1139
1139
spec -> gen .suppress_auto_mute = 1 ;
1140
1140
spec -> gen .no_primary_hp = 1 ;
@@ -1304,15 +1304,6 @@ static void dolphin_hw_init(struct hda_codec *codec)
1304
1304
cs8409_enable_ur (codec , 1 );
1305
1305
}
1306
1306
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
-
1316
1307
static int dolphin_exec_verb (struct hdac_device * dev , unsigned int cmd , unsigned int flags ,
1317
1308
unsigned int * res )
1318
1309
{
@@ -1371,7 +1362,7 @@ void dolphin_fixups(struct hda_codec *codec, const struct hda_fixup *fix, int ac
1371
1362
spec -> num_scodecs = 2 ;
1372
1363
spec -> gen .suppress_vmaster = 1 ;
1373
1364
1374
- codec -> patch_ops = cs8409_dolphin_patch_ops ;
1365
+ spec -> unsol_event = dolphin_jack_unsol_event ;
1375
1366
1376
1367
/* GPIO 1,5 out, 0,4 in */
1377
1368
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
1444
1435
}
1445
1436
}
1446
1437
1447
- static int patch_cs8409 (struct hda_codec * codec )
1438
+ static int cs8409_probe (struct hda_codec * codec , const struct hda_device_id * id )
1448
1439
{
1449
1440
int err ;
1450
1441
@@ -1461,22 +1452,34 @@ static int patch_cs8409(struct hda_codec *codec)
1461
1452
1462
1453
err = cs8409_parse_auto_config (codec );
1463
1454
if (err < 0 ) {
1464
- cs8409_free (codec );
1455
+ cs8409_remove (codec );
1465
1456
return err ;
1466
1457
}
1467
1458
1468
1459
snd_hda_apply_fixup (codec , HDA_FIXUP_ACT_PROBE );
1469
1460
return 0 ;
1470
1461
}
1471
1462
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
+
1472
1474
static const struct hda_device_id snd_hda_id_cs8409 [] = {
1473
- HDA_CODEC_ENTRY (0x10138409 , "CS8409" , patch_cs8409 ),
1475
+ HDA_CODEC_ID (0x10138409 , "CS8409" ),
1474
1476
{} /* terminator */
1475
1477
};
1476
1478
MODULE_DEVICE_TABLE (hdaudio , snd_hda_id_cs8409 );
1477
1479
1478
1480
static struct hda_codec_driver cs8409_driver = {
1479
1481
.id = snd_hda_id_cs8409 ,
1482
+ .ops = & cs8409_codec_ops ,
1480
1483
};
1481
1484
module_hda_codec_driver (cs8409_driver );
1482
1485
0 commit comments