[alsa-devel] [PATCH 1/3] ALSA: hda - Remove dead GPIO code for VIA codec
From what I can conclude all GPIO handling was removed in 2009.
Remove dead code remnants.
Signed-off-by: David Henningsson david.henningsson@canonical.com --- sound/pci/hda/patch_via.c | 47 --------------------------------------------- 1 file changed, 47 deletions(-)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 5a45a91..430cb33 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -299,7 +299,6 @@ static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
#define VIA_JACK_EVENT 0x20 #define VIA_HP_EVENT 0x01 -#define VIA_GPIO_EVENT 0x02 #define VIA_LINE_EVENT 0x03
enum { @@ -1685,50 +1684,6 @@ static void via_hp_automute(struct hda_codec *codec) via_line_automute(codec, present); }
-static void via_gpio_control(struct hda_codec *codec) -{ - unsigned int gpio_data; - unsigned int vol_counter; - unsigned int vol; - unsigned int master_vol; - - struct via_spec *spec = codec->spec; - - gpio_data = snd_hda_codec_read(codec, codec->afg, 0, - AC_VERB_GET_GPIO_DATA, 0) & 0x03; - - vol_counter = (snd_hda_codec_read(codec, codec->afg, 0, - 0xF84, 0) & 0x3F0000) >> 16; - - vol = vol_counter & 0x1F; - master_vol = snd_hda_codec_read(codec, 0x1A, 0, - AC_VERB_GET_AMP_GAIN_MUTE, - AC_AMP_GET_INPUT); - - if (gpio_data == 0x02) { - /* unmute line out */ - snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], - PIN_OUT); - if (vol_counter & 0x20) { - /* decrease volume */ - if (vol > master_vol) - vol = master_vol; - snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT, - 0, HDA_AMP_VOLMASK, - master_vol-vol); - } else { - /* increase volume */ - snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT, 0, - HDA_AMP_VOLMASK, - ((master_vol+vol) > 0x2A) ? 0x2A : - (master_vol+vol)); - } - } else if (!(gpio_data & 0x02)) { - /* mute line out */ - snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], 0); - } -} - /* unsolicited event for jack sensing */ static void via_unsol_event(struct hda_codec *codec, unsigned int res) @@ -1743,8 +1698,6 @@ static void via_unsol_event(struct hda_codec *codec,
if (res == VIA_HP_EVENT || res == VIA_LINE_EVENT) via_hp_automute(codec); - else if (res == VIA_GPIO_EVENT) - via_gpio_control(codec); snd_hda_jack_report_sync(codec); }
Signed-off-by: David Henningsson david.henningsson@canonical.com --- sound/pci/hda/patch_via.c | 47 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 24 deletions(-)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 430cb33..eae466a 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -1684,23 +1684,6 @@ static void via_hp_automute(struct hda_codec *codec) via_line_automute(codec, present); }
-/* unsolicited event for jack sensing */ -static void via_unsol_event(struct hda_codec *codec, - unsigned int res) -{ - res >>= 26; - res = snd_hda_jack_get_action(codec, res); - - if (res & VIA_JACK_EVENT) - set_widgets_power_state(codec); - - res &= ~VIA_JACK_EVENT; - - if (res == VIA_HP_EVENT || res == VIA_LINE_EVENT) - via_hp_automute(codec); - snd_hda_jack_report_sync(codec); -} - #ifdef CONFIG_PM static int via_suspend(struct hda_codec *codec) { @@ -1736,7 +1719,7 @@ static const struct hda_codec_ops via_patch_ops = { .build_pcms = via_build_pcms, .init = via_init, .free = via_free, - .unsol_event = via_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .suspend = via_suspend, .check_power_status = via_check_power_status, @@ -2714,6 +2697,17 @@ static void via_auto_init_dig_in(struct hda_codec *codec) snd_hda_set_pin_ctl(codec, spec->autocfg.dig_in_pin, PIN_IN); }
+static void via_jack_output_event(struct hda_codec *codec, struct hda_jack_tbl *tbl) +{ + set_widgets_power_state(codec); + via_hp_automute(codec); +} + +static void via_jack_powerstate_event(struct hda_codec *codec, struct hda_jack_tbl *tbl) +{ + set_widgets_power_state(codec); +} + /* initialize the unsolicited events */ static void via_auto_init_unsol_event(struct hda_codec *codec) { @@ -2721,26 +2715,31 @@ static void via_auto_init_unsol_event(struct hda_codec *codec) struct auto_pin_cfg *cfg = &spec->autocfg; unsigned int ev; int i; + hda_jack_callback cb;
if (cfg->hp_pins[0] && is_jack_detectable(codec, cfg->hp_pins[0])) - snd_hda_jack_detect_enable(codec, cfg->hp_pins[0], - VIA_HP_EVENT | VIA_JACK_EVENT); + snd_hda_jack_detect_enable_callback(codec, cfg->hp_pins[0], + VIA_HP_EVENT | VIA_JACK_EVENT, + via_jack_output_event);
if (cfg->speaker_pins[0]) ev = VIA_LINE_EVENT; else ev = 0; + cb = ev ? via_jack_output_event : via_jack_powerstate_event; + for (i = 0; i < cfg->line_outs; i++) { if (cfg->line_out_pins[i] && is_jack_detectable(codec, cfg->line_out_pins[i])) - snd_hda_jack_detect_enable(codec, cfg->line_out_pins[i], - ev | VIA_JACK_EVENT); + snd_hda_jack_detect_enable_callback(codec, cfg->line_out_pins[i], + ev | VIA_JACK_EVENT, cb); }
for (i = 0; i < cfg->num_inputs; i++) { if (is_jack_detectable(codec, cfg->inputs[i].pin)) - snd_hda_jack_detect_enable(codec, cfg->inputs[i].pin, - VIA_JACK_EVENT); + snd_hda_jack_detect_enable_callback(codec, cfg->inputs[i].pin, + VIA_JACK_EVENT, + via_jack_powerstate_event); } }
Signed-off-by: David Henningsson david.henningsson@canonical.com --- sound/pci/hda/patch_cirrus.c | 48 +++++++++--------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-)
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index fcfc9f0..fc92819 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) * HP/SPK/SPDIF */
-static void cs_automute(struct hda_codec *codec) +static void cs_automute(struct hda_codec *codec, struct hda_jack_tbl *tbl) { struct cs_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; @@ -973,7 +973,7 @@ static void cs_automute(struct hda_codec *codec) * Switch max 3 inputs of a single ADC (nid 3) */
-static void cs_automic(struct hda_codec *codec) +static void cs_automic(struct hda_codec *codec, struct hda_jack_tbl *tbl) { struct cs_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; @@ -1035,7 +1035,7 @@ static void init_output(struct hda_codec *codec) if (!cfg->speaker_outs) continue; if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { - snd_hda_jack_detect_enable(codec, nid, HP_EVENT); + snd_hda_jack_detect_enable_callback(codec, nid, HP_EVENT, cs_automute); spec->hp_detect = 1; } } @@ -1046,7 +1046,7 @@ static void init_output(struct hda_codec *codec)
/* SPDIF is enabled on presence detect for CS421x */ if (spec->hp_detect || spec->spdif_detect) - cs_automute(codec); + cs_automute(codec, NULL); }
static void init_input(struct hda_codec *codec) @@ -1070,13 +1070,13 @@ static void init_input(struct hda_codec *codec) AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(spec->adc_idx[i])); if (spec->mic_detect && spec->automic_idx == i) - snd_hda_jack_detect_enable(codec, pin, MIC_EVENT); + snd_hda_jack_detect_enable_callback(codec, pin, MIC_EVENT, cs_automic); } /* CS420x has multiple ADC, CS421x has single ADC */ if (spec->vendor_nid == CS420X_VENDOR_NID) { change_cur_input(codec, spec->cur_input, 1); if (spec->mic_detect) - cs_automic(codec); + cs_automic(codec, NULL);
coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */ if (is_active_pin(codec, CS_DMIC2_PIN_NID)) @@ -1089,7 +1089,7 @@ static void init_input(struct hda_codec *codec) cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); } else { if (spec->mic_detect) - cs_automic(codec); + cs_automic(codec, NULL); else { spec->cur_adc = spec->adc_nid[spec->cur_input]; cs_update_input_select(codec); @@ -1246,25 +1246,12 @@ static void cs_free(struct hda_codec *codec) kfree(codec->spec); }
-static void cs_unsol_event(struct hda_codec *codec, unsigned int res) -{ - switch (snd_hda_jack_get_action(codec, res >> 26)) { - case HP_EVENT: - cs_automute(codec); - break; - case MIC_EVENT: - cs_automic(codec); - break; - } - snd_hda_jack_report_sync(codec); -} - static const struct hda_codec_ops cs_patch_ops = { .build_controls = cs_build_controls, .build_pcms = cs_build_pcms, .init = cs_init, .free = cs_free, - .unsol_event = cs_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, };
static int cs_parse_auto_config(struct hda_codec *codec) @@ -1674,7 +1661,7 @@ static void init_cs421x_digital(struct hda_codec *codec) if (!cfg->speaker_outs) continue; if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { - snd_hda_jack_detect_enable(codec, nid, SPDIF_EVENT); + snd_hda_jack_detect_enable_callback(codec, nid, SPDIF_EVENT, cs_automute); spec->spdif_detect = 1; } } @@ -1889,21 +1876,6 @@ static int cs421x_build_controls(struct hda_codec *codec) return 0; }
-static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res) -{ - switch (snd_hda_jack_get_action(codec, res >> 26)) { - case HP_EVENT: - case SPDIF_EVENT: - cs_automute(codec); - break; - - case MIC_EVENT: - cs_automic(codec); - break; - } - snd_hda_jack_report_sync(codec); -} - static int parse_cs421x_input(struct hda_codec *codec) { struct cs_spec *spec = codec->spec; @@ -1977,7 +1949,7 @@ static struct hda_codec_ops cs421x_patch_ops = { .build_pcms = cs_build_pcms, .init = cs421x_init, .free = cs_free, - .unsol_event = cs421x_unsol_event, + .unsol_event = snd_hda_jack_unsol_event, #ifdef CONFIG_PM .suspend = cs421x_suspend, #endif
At Mon, 8 Oct 2012 15:44:13 +0200, David Henningsson wrote:
From what I can conclude all GPIO handling was removed in 2009.
Remove dead code remnants.
Signed-off-by: David Henningsson david.henningsson@canonical.com
OK, applied all these now. Thanks.
Takashi
sound/pci/hda/patch_via.c | 47 --------------------------------------------- 1 file changed, 47 deletions(-)
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 5a45a91..430cb33 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c @@ -299,7 +299,6 @@ static enum VIA_HDA_CODEC get_codec_type(struct hda_codec *codec)
#define VIA_JACK_EVENT 0x20 #define VIA_HP_EVENT 0x01 -#define VIA_GPIO_EVENT 0x02 #define VIA_LINE_EVENT 0x03
enum { @@ -1685,50 +1684,6 @@ static void via_hp_automute(struct hda_codec *codec) via_line_automute(codec, present); }
-static void via_gpio_control(struct hda_codec *codec) -{
- unsigned int gpio_data;
- unsigned int vol_counter;
- unsigned int vol;
- unsigned int master_vol;
- struct via_spec *spec = codec->spec;
- gpio_data = snd_hda_codec_read(codec, codec->afg, 0,
AC_VERB_GET_GPIO_DATA, 0) & 0x03;
- vol_counter = (snd_hda_codec_read(codec, codec->afg, 0,
0xF84, 0) & 0x3F0000) >> 16;
- vol = vol_counter & 0x1F;
- master_vol = snd_hda_codec_read(codec, 0x1A, 0,
AC_VERB_GET_AMP_GAIN_MUTE,
AC_AMP_GET_INPUT);
- if (gpio_data == 0x02) {
/* unmute line out */
snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0],
PIN_OUT);
if (vol_counter & 0x20) {
/* decrease volume */
if (vol > master_vol)
vol = master_vol;
snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT,
0, HDA_AMP_VOLMASK,
master_vol-vol);
} else {
/* increase volume */
snd_hda_codec_amp_stereo(codec, 0x1A, HDA_INPUT, 0,
HDA_AMP_VOLMASK,
((master_vol+vol) > 0x2A) ? 0x2A :
(master_vol+vol));
}
- } else if (!(gpio_data & 0x02)) {
/* mute line out */
snd_hda_set_pin_ctl(codec, spec->autocfg.line_out_pins[0], 0);
- }
-}
/* unsolicited event for jack sensing */ static void via_unsol_event(struct hda_codec *codec, unsigned int res) @@ -1743,8 +1698,6 @@ static void via_unsol_event(struct hda_codec *codec,
if (res == VIA_HP_EVENT || res == VIA_LINE_EVENT) via_hp_automute(codec);
- else if (res == VIA_GPIO_EVENT)
snd_hda_jack_report_sync(codec);via_gpio_control(codec);
}
-- 1.7.9.5
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
participants (2)
-
David Henningsson
-
Takashi Iwai