aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorDavid Henningsson <david.henningsson@canonical.com>2012-10-08 09:44:15 -0400
committerTakashi Iwai <tiwai@suse.de>2012-10-08 09:48:09 -0400
commit5c2e4e0ab6f3faa5b68ffa68a01b050acccf04ac (patch)
treee183b1f1c0bb629d9ee4ac428b43bfeab62345d3 /sound
parent4e2d16d326fd33e3101ddf08730c953b480ec2ef (diff)
ALSA: hda - make Cirrus codec use generic unsol event handler
Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/patch_cirrus.c48
1 files changed, 10 insertions, 38 deletions
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index fcfc9f0a056b..fc92819838a1 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -897,7 +897,7 @@ static int build_digital_input(struct hda_codec *codec)
897 * HP/SPK/SPDIF 897 * HP/SPK/SPDIF
898 */ 898 */
899 899
900static void cs_automute(struct hda_codec *codec) 900static void cs_automute(struct hda_codec *codec, struct hda_jack_tbl *tbl)
901{ 901{
902 struct cs_spec *spec = codec->spec; 902 struct cs_spec *spec = codec->spec;
903 struct auto_pin_cfg *cfg = &spec->autocfg; 903 struct auto_pin_cfg *cfg = &spec->autocfg;
@@ -973,7 +973,7 @@ static void cs_automute(struct hda_codec *codec)
973 * Switch max 3 inputs of a single ADC (nid 3) 973 * Switch max 3 inputs of a single ADC (nid 3)
974*/ 974*/
975 975
976static void cs_automic(struct hda_codec *codec) 976static void cs_automic(struct hda_codec *codec, struct hda_jack_tbl *tbl)
977{ 977{
978 struct cs_spec *spec = codec->spec; 978 struct cs_spec *spec = codec->spec;
979 struct auto_pin_cfg *cfg = &spec->autocfg; 979 struct auto_pin_cfg *cfg = &spec->autocfg;
@@ -1035,7 +1035,7 @@ static void init_output(struct hda_codec *codec)
1035 if (!cfg->speaker_outs) 1035 if (!cfg->speaker_outs)
1036 continue; 1036 continue;
1037 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { 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 spec->hp_detect = 1; 1039 spec->hp_detect = 1;
1040 } 1040 }
1041 } 1041 }
@@ -1046,7 +1046,7 @@ static void init_output(struct hda_codec *codec)
1046 1046
1047 /* SPDIF is enabled on presence detect for CS421x */ 1047 /* SPDIF is enabled on presence detect for CS421x */
1048 if (spec->hp_detect || spec->spdif_detect) 1048 if (spec->hp_detect || spec->spdif_detect)
1049 cs_automute(codec); 1049 cs_automute(codec, NULL);
1050} 1050}
1051 1051
1052static void init_input(struct hda_codec *codec) 1052static void init_input(struct hda_codec *codec)
@@ -1070,13 +1070,13 @@ static void init_input(struct hda_codec *codec)
1070 AC_VERB_SET_AMP_GAIN_MUTE, 1070 AC_VERB_SET_AMP_GAIN_MUTE,
1071 AMP_IN_MUTE(spec->adc_idx[i])); 1071 AMP_IN_MUTE(spec->adc_idx[i]));
1072 if (spec->mic_detect && spec->automic_idx == i) 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 /* CS420x has multiple ADC, CS421x has single ADC */ 1075 /* CS420x has multiple ADC, CS421x has single ADC */
1076 if (spec->vendor_nid == CS420X_VENDOR_NID) { 1076 if (spec->vendor_nid == CS420X_VENDOR_NID) {
1077 change_cur_input(codec, spec->cur_input, 1); 1077 change_cur_input(codec, spec->cur_input, 1);
1078 if (spec->mic_detect) 1078 if (spec->mic_detect)
1079 cs_automic(codec); 1079 cs_automic(codec, NULL);
1080 1080
1081 coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */ 1081 coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */
1082 if (is_active_pin(codec, CS_DMIC2_PIN_NID)) 1082 if (is_active_pin(codec, CS_DMIC2_PIN_NID))
@@ -1089,7 +1089,7 @@ static void init_input(struct hda_codec *codec)
1089 cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); 1089 cs_vendor_coef_set(codec, IDX_ADC_CFG, coef);
1090 } else { 1090 } else {
1091 if (spec->mic_detect) 1091 if (spec->mic_detect)
1092 cs_automic(codec); 1092 cs_automic(codec, NULL);
1093 else { 1093 else {
1094 spec->cur_adc = spec->adc_nid[spec->cur_input]; 1094 spec->cur_adc = spec->adc_nid[spec->cur_input];
1095 cs_update_input_select(codec); 1095 cs_update_input_select(codec);
@@ -1246,25 +1246,12 @@ static void cs_free(struct hda_codec *codec)
1246 kfree(codec->spec); 1246 kfree(codec->spec);
1247} 1247}
1248 1248
1249static 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
1262static const struct hda_codec_ops cs_patch_ops = { 1249static const struct hda_codec_ops cs_patch_ops = {
1263 .build_controls = cs_build_controls, 1250 .build_controls = cs_build_controls,
1264 .build_pcms = cs_build_pcms, 1251 .build_pcms = cs_build_pcms,
1265 .init = cs_init, 1252 .init = cs_init,
1266 .free = cs_free, 1253 .free = cs_free,
1267 .unsol_event = cs_unsol_event, 1254 .unsol_event = snd_hda_jack_unsol_event,
1268}; 1255};
1269 1256
1270static int cs_parse_auto_config(struct hda_codec *codec) 1257static int cs_parse_auto_config(struct hda_codec *codec)
@@ -1674,7 +1661,7 @@ static void init_cs421x_digital(struct hda_codec *codec)
1674 if (!cfg->speaker_outs) 1661 if (!cfg->speaker_outs)
1675 continue; 1662 continue;
1676 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { 1663 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
1677 snd_hda_jack_detect_enable(codec, nid, SPDIF_EVENT); 1664 snd_hda_jack_detect_enable_callback(codec, nid, SPDIF_EVENT, cs_automute);
1678 spec->spdif_detect = 1; 1665 spec->spdif_detect = 1;
1679 } 1666 }
1680 } 1667 }
@@ -1889,21 +1876,6 @@ static int cs421x_build_controls(struct hda_codec *codec)
1889 return 0; 1876 return 0;
1890} 1877}
1891 1878
1892static 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
1907static int parse_cs421x_input(struct hda_codec *codec) 1879static int parse_cs421x_input(struct hda_codec *codec)
1908{ 1880{
1909 struct cs_spec *spec = codec->spec; 1881 struct cs_spec *spec = codec->spec;
@@ -1977,7 +1949,7 @@ static struct hda_codec_ops cs421x_patch_ops = {
1977 .build_pcms = cs_build_pcms, 1949 .build_pcms = cs_build_pcms,
1978 .init = cs421x_init, 1950 .init = cs421x_init,
1979 .free = cs_free, 1951 .free = cs_free,
1980 .unsol_event = cs421x_unsol_event, 1952 .unsol_event = snd_hda_jack_unsol_event,
1981#ifdef CONFIG_PM 1953#ifdef CONFIG_PM
1982 .suspend = cs421x_suspend, 1954 .suspend = cs421x_suspend,
1983#endif 1955#endif