unsigned int alt_switch: 1;
unsigned int hp_detect: 1;
- unsigned int gpio_mask, gpio_data;
+ /* gpio lines */
+ unsigned int gpio_mask;
+ unsigned int gpio_dir;
+ unsigned int gpio_data;
+ unsigned int gpio_mute;
+
+ /* analog loopback */
unsigned char aloopback_mask;
unsigned char aloopback_shift;
*/
static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
- unsigned int data)
+ unsigned int dir_mask, unsigned int data)
{
unsigned int gpiostate, gpiomask, gpiodir;
gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
AC_VERB_GET_GPIO_DATA, 0);
- gpiostate = (gpiostate & ~mask) | (data & mask);
+ gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
AC_VERB_GET_GPIO_MASK, 0);
gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
AC_VERB_GET_GPIO_DIRECTION, 0);
- gpiodir |= mask;
+ gpiodir |= dir_mask;
/* Configure GPIOx as CMOS */
snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
AC_PINCTL_IN_EN);
- stac_gpio_set(codec, spec->gpio_mask, spec->gpio_data);
+ stac_gpio_set(codec, spec->gpio_mask,
+ spec->gpio_dir, spec->gpio_data);
return 0;
}
int i, presence;
presence = 0;
+ if (spec->gpio_mute)
+ presence = !(snd_hda_codec_read(codec, codec->afg, 0,
+ AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
+
for (i = 0; i < cfg->hp_outs; i++) {
- presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
if (presence)
break;
+ presence = get_hp_pin_presence(codec, cfg->hp_pins[i]);
}
if (presence) {
stac92xx_set_config_regs(codec);
snd_hda_sequence_write(codec, spec->init);
- stac_gpio_set(codec, spec->gpio_mask, spec->gpio_data);
+ stac_gpio_set(codec, spec->gpio_mask,
+ spec->gpio_dir, spec->gpio_data);
snd_hda_codec_resume_amp(codec);
snd_hda_codec_resume_cache(codec);
/* invoke unsolicited event to reset the HP state */
spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
spec->dinput_mux = &stac92hd73xx_dmux;
/* GPIO0 High = Enable EAPD */
- spec->gpio_mask = spec->gpio_data = 0x000001;
+ spec->gpio_mask = spec->gpio_dir = 0x1;
+ spec->gpio_data = 0x01;
spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
spec->pwr_nids = stac92hd73xx_pwr_nids;
spec->aloopback_mask = 0x20;
spec->aloopback_shift = 0;
- spec->gpio_mask = spec->gpio_data = 0x00000001; /* GPIO0 High = EAPD */
+ /* GPIO0 High = EAPD */
+ spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0x1;
spec->mux_nids = stac92hd71bxx_mux_nids;
spec->adc_nids = stac92hd71bxx_adc_nids;
stac922x_models,
stac922x_cfg_tbl);
if (spec->board_config == STAC_INTEL_MAC_V3) {
- spec->gpio_mask = spec->gpio_data = 0x03;
+ spec->gpio_mask = spec->gpio_dir = 0x03;
+ spec->gpio_data = 0x03;
/* Intel Macs have all same PCI SSID, so we need to check
* codec SSID to distinguish the exact models
*/
case STAC_D965_3ST:
case STAC_D965_5ST:
/* GPIO0 High = Enable EAPD */
- spec->gpio_mask = spec->gpio_data = 0x00000001;
+ spec->gpio_mask = spec->gpio_dir = 0x01;
+ spec->gpio_data = 0x01;
spec->num_dmics = 0;
spec->init = d965_core_init;
/* fallthru */
case STAC_DELL_3ST:
/* GPIO2 High = Enable EAPD */
- spec->gpio_mask = spec->gpio_data = 0x00000004;
+ spec->gpio_mask = spec->gpio_dir = 0x04;
+ spec->gpio_data = 0x04;
spec->dmic_nids = stac927x_dmic_nids;
spec->num_dmics = STAC927X_NUM_DMICS;
break;
default:
/* GPIO0 High = Enable EAPD */
- spec->gpio_mask = spec->gpio_data = 0x00000001;
+ spec->gpio_mask = spec->gpio_dir = 0x1;
+ spec->gpio_data = 0x01;
spec->num_dmics = 0;
spec->init = stac927x_core_init;
stac92xx_set_config_reg(codec, 0x1f, 0x01441030);
stac92xx_set_config_reg(codec, 0x20, 0x1c410030);
- spec->gpio_mask = 0x0000000b;
+ /* Enable unsol response for GPIO4/Dock HP connection */
+ snd_hda_codec_write(codec, codec->afg, 0,
+ AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
+ snd_hda_codec_write_cache(codec, codec->afg, 0,
+ AC_VERB_SET_UNSOLICITED_ENABLE,
+ (AC_USRSP_EN | STAC_HP_EVENT));
+
+ spec->gpio_dir = 0x0b;
+ spec->gpio_mask = 0x1b;
+ spec->gpio_mute = 0x10;
/* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
- * GPIO3 High = DRM
+ * GPIO3 Low = DRM
*/
- spec->gpio_data = 0x00000009;
+ spec->gpio_data = 0x01;
break;
default:
/* GPIO0 High = EAPD */
- spec->gpio_mask = spec->gpio_data = 0x00000001;
+ spec->gpio_mask = spec->gpio_dir = 0x1;
+ spec->gpio_data = 0x01;
break;
}