@@ -897,7 +897,7 @@ static int build_digital_input(struct hda_codec *codec)
897
897
* HP/SPK/SPDIF
898
898
*/
899
899
900
- static void cs_automute (struct hda_codec * codec )
900
+ static void cs_automute (struct hda_codec * codec , struct hda_jack_tbl * tbl )
901
901
{
902
902
struct cs_spec * spec = codec -> spec ;
903
903
struct auto_pin_cfg * cfg = & spec -> autocfg ;
@@ -973,7 +973,7 @@ static void cs_automute(struct hda_codec *codec)
973
973
* Switch max 3 inputs of a single ADC (nid 3)
974
974
*/
975
975
976
- static void cs_automic (struct hda_codec * codec )
976
+ static void cs_automic (struct hda_codec * codec , struct hda_jack_tbl * tbl )
977
977
{
978
978
struct cs_spec * spec = codec -> spec ;
979
979
struct auto_pin_cfg * cfg = & spec -> autocfg ;
@@ -1035,7 +1035,7 @@ static void init_output(struct hda_codec *codec)
1035
1035
if (!cfg -> speaker_outs )
1036
1036
continue ;
1037
1037
if (get_wcaps (codec , nid ) & AC_WCAP_UNSOL_CAP ) {
1038
- snd_hda_jack_detect_enable (codec , nid , HP_EVENT );
1038
+ snd_hda_jack_detect_enable_callback (codec , nid , HP_EVENT , cs_automute );
1039
1039
spec -> hp_detect = 1 ;
1040
1040
}
1041
1041
}
@@ -1046,7 +1046,7 @@ static void init_output(struct hda_codec *codec)
1046
1046
1047
1047
/* SPDIF is enabled on presence detect for CS421x */
1048
1048
if (spec -> hp_detect || spec -> spdif_detect )
1049
- cs_automute (codec );
1049
+ cs_automute (codec , NULL );
1050
1050
}
1051
1051
1052
1052
static void init_input (struct hda_codec * codec )
@@ -1070,13 +1070,13 @@ static void init_input(struct hda_codec *codec)
1070
1070
AC_VERB_SET_AMP_GAIN_MUTE ,
1071
1071
AMP_IN_MUTE (spec -> adc_idx [i ]));
1072
1072
if (spec -> mic_detect && spec -> automic_idx == i )
1073
- snd_hda_jack_detect_enable (codec , pin , MIC_EVENT );
1073
+ snd_hda_jack_detect_enable_callback (codec , pin , MIC_EVENT , cs_automic );
1074
1074
}
1075
1075
/* CS420x has multiple ADC, CS421x has single ADC */
1076
1076
if (spec -> vendor_nid == CS420X_VENDOR_NID ) {
1077
1077
change_cur_input (codec , spec -> cur_input , 1 );
1078
1078
if (spec -> mic_detect )
1079
- cs_automic (codec );
1079
+ cs_automic (codec , NULL );
1080
1080
1081
1081
coef = 0x000a ; /* ADC1/2 - Digital and Analog Soft Ramp */
1082
1082
if (is_active_pin (codec , CS_DMIC2_PIN_NID ))
@@ -1089,7 +1089,7 @@ static void init_input(struct hda_codec *codec)
1089
1089
cs_vendor_coef_set (codec , IDX_ADC_CFG , coef );
1090
1090
} else {
1091
1091
if (spec -> mic_detect )
1092
- cs_automic (codec );
1092
+ cs_automic (codec , NULL );
1093
1093
else {
1094
1094
spec -> cur_adc = spec -> adc_nid [spec -> cur_input ];
1095
1095
cs_update_input_select (codec );
@@ -1243,28 +1243,16 @@ static void cs_free(struct hda_codec *codec)
1243
1243
struct cs_spec * spec = codec -> spec ;
1244
1244
kfree (spec -> capture_bind [0 ]);
1245
1245
kfree (spec -> capture_bind [1 ]);
1246
+ snd_hda_gen_free (& spec -> gen );
1246
1247
kfree (codec -> spec );
1247
1248
}
1248
1249
1249
- static void cs_unsol_event (struct hda_codec * codec , unsigned int res )
1250
- {
1251
- switch (snd_hda_jack_get_action (codec , res >> 26 )) {
1252
- case HP_EVENT :
1253
- cs_automute (codec );
1254
- break ;
1255
- case MIC_EVENT :
1256
- cs_automic (codec );
1257
- break ;
1258
- }
1259
- snd_hda_jack_report_sync (codec );
1260
- }
1261
-
1262
1250
static const struct hda_codec_ops cs_patch_ops = {
1263
1251
.build_controls = cs_build_controls ,
1264
1252
.build_pcms = cs_build_pcms ,
1265
1253
.init = cs_init ,
1266
1254
.free = cs_free ,
1267
- .unsol_event = cs_unsol_event ,
1255
+ .unsol_event = snd_hda_jack_unsol_event ,
1268
1256
};
1269
1257
1270
1258
static int cs_parse_auto_config (struct hda_codec * codec )
@@ -1439,6 +1427,7 @@ static int patch_cs420x(struct hda_codec *codec)
1439
1427
if (!spec )
1440
1428
return - ENOMEM ;
1441
1429
codec -> spec = spec ;
1430
+ snd_hda_gen_init (& spec -> gen );
1442
1431
1443
1432
spec -> vendor_nid = CS420X_VENDOR_NID ;
1444
1433
@@ -1457,7 +1446,7 @@ static int patch_cs420x(struct hda_codec *codec)
1457
1446
return 0 ;
1458
1447
1459
1448
error :
1460
- kfree (codec -> spec );
1449
+ cs_free (codec );
1461
1450
codec -> spec = NULL ;
1462
1451
return err ;
1463
1452
}
@@ -1674,7 +1663,7 @@ static void init_cs421x_digital(struct hda_codec *codec)
1674
1663
if (!cfg -> speaker_outs )
1675
1664
continue ;
1676
1665
if (get_wcaps (codec , nid ) & AC_WCAP_UNSOL_CAP ) {
1677
- snd_hda_jack_detect_enable (codec , nid , SPDIF_EVENT );
1666
+ snd_hda_jack_detect_enable_callback (codec , nid , SPDIF_EVENT , cs_automute );
1678
1667
spec -> spdif_detect = 1 ;
1679
1668
}
1680
1669
}
@@ -1889,21 +1878,6 @@ static int cs421x_build_controls(struct hda_codec *codec)
1889
1878
return 0 ;
1890
1879
}
1891
1880
1892
- static void cs421x_unsol_event (struct hda_codec * codec , unsigned int res )
1893
- {
1894
- switch (snd_hda_jack_get_action (codec , res >> 26 )) {
1895
- case HP_EVENT :
1896
- case SPDIF_EVENT :
1897
- cs_automute (codec );
1898
- break ;
1899
-
1900
- case MIC_EVENT :
1901
- cs_automic (codec );
1902
- break ;
1903
- }
1904
- snd_hda_jack_report_sync (codec );
1905
- }
1906
-
1907
1881
static int parse_cs421x_input (struct hda_codec * codec )
1908
1882
{
1909
1883
struct cs_spec * spec = codec -> spec ;
@@ -1977,7 +1951,7 @@ static struct hda_codec_ops cs421x_patch_ops = {
1977
1951
.build_pcms = cs_build_pcms ,
1978
1952
.init = cs421x_init ,
1979
1953
.free = cs_free ,
1980
- .unsol_event = cs421x_unsol_event ,
1954
+ .unsol_event = snd_hda_jack_unsol_event ,
1981
1955
#ifdef CONFIG_PM
1982
1956
.suspend = cs421x_suspend ,
1983
1957
#endif
@@ -1992,6 +1966,7 @@ static int patch_cs4210(struct hda_codec *codec)
1992
1966
if (!spec )
1993
1967
return - ENOMEM ;
1994
1968
codec -> spec = spec ;
1969
+ snd_hda_gen_init (& spec -> gen );
1995
1970
1996
1971
spec -> vendor_nid = CS4210_VENDOR_NID ;
1997
1972
@@ -2017,7 +1992,7 @@ static int patch_cs4210(struct hda_codec *codec)
2017
1992
return 0 ;
2018
1993
2019
1994
error :
2020
- kfree (codec -> spec );
1995
+ cs_free (codec );
2021
1996
codec -> spec = NULL ;
2022
1997
return err ;
2023
1998
}
@@ -2031,6 +2006,7 @@ static int patch_cs4213(struct hda_codec *codec)
2031
2006
if (!spec )
2032
2007
return - ENOMEM ;
2033
2008
codec -> spec = spec ;
2009
+ snd_hda_gen_init (& spec -> gen );
2034
2010
2035
2011
spec -> vendor_nid = CS4213_VENDOR_NID ;
2036
2012
@@ -2042,7 +2018,7 @@ static int patch_cs4213(struct hda_codec *codec)
2042
2018
return 0 ;
2043
2019
2044
2020
error :
2045
- kfree (codec -> spec );
2021
+ cs_free (codec );
2046
2022
codec -> spec = NULL ;
2047
2023
return err ;
2048
2024
}
0 commit comments