/* Filter out keypresses when 4 pole jack not detected */ if (gpiod_get_value_cansleep(priv->gpio_headset_key) &&
aries_headset.status & SND_JACK_MICROPHONE) return SND_JACK_BTN_0;
/** * We have an odd setup - the SPKMODE pin is pulled up so * we only have access to the left side SPK configs, * but SPKOUTR isn't bridged so when playing back in * stereo, we only get the left hand channel. The only * option we're left with is to force the AIF into mono * mode.
*/ switch (event) { case SND_SOC_DAPM_POST_PMU:
ret = snd_soc_component_update_bits(component,
WM8994_AIF1_DAC1_FILTERS_1,
WM8994_AIF1DAC1_MONO, WM8994_AIF1DAC1_MONO); break; case SND_SOC_DAPM_PRE_PMD:
ret = snd_soc_component_update_bits(component,
WM8994_AIF1_DAC1_FILTERS_1,
WM8994_AIF1DAC1_MONO, 0); break;
}
return ret;
}
staticint aries_main_bias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event)
{ struct snd_soc_card *card = w->dapm->card; struct aries_wm8994_data *priv = snd_soc_card_get_drvdata(card); int ret = 0;
switch (event) { case SND_SOC_DAPM_PRE_PMU:
ret = regulator_enable(priv->reg_main_micbias); break; case SND_SOC_DAPM_POST_PMD:
ret = regulator_disable(priv->reg_main_micbias); break;
}
return ret;
}
staticint aries_headset_bias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event)
{ struct snd_soc_card *card = w->dapm->card; struct aries_wm8994_data *priv = snd_soc_card_get_drvdata(card); int ret = 0;
switch (event) { case SND_SOC_DAPM_PRE_PMU:
ret = regulator_enable(priv->reg_headset_micbias); break; case SND_SOC_DAPM_POST_PMD:
ret = regulator_disable(priv->reg_headset_micbias); break;
}
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM;
snd_soc_card_set_drvdata(card, priv);
match = of_match_node(samsung_wm8994_of_match, np);
priv->variant = match->data;
/* Remove FM widget if not present */ if (!priv->variant->has_fm_radio)
card->num_dapm_widgets--;
priv->reg_main_micbias = devm_regulator_get(dev, "main-micbias"); if (IS_ERR(priv->reg_main_micbias)) {
dev_err(dev, "Failed to get main micbias regulator\n"); return PTR_ERR(priv->reg_main_micbias);
}
priv->reg_headset_micbias = devm_regulator_get(dev, "headset-micbias"); if (IS_ERR(priv->reg_headset_micbias)) {
dev_err(dev, "Failed to get headset micbias regulator\n"); return PTR_ERR(priv->reg_headset_micbias);
}
priv->gpio_earpath_sel = devm_gpiod_get(dev, "earpath-sel",
GPIOD_OUT_LOW); if (IS_ERR(priv->gpio_earpath_sel)) {
dev_err(dev, "Failed to get earpath selector gpio"); return PTR_ERR(priv->gpio_earpath_sel);
}
extcon_np = of_parse_phandle(np, "extcon", 0);
priv->usb_extcon = extcon_find_edev_by_node(extcon_np);
of_node_put(extcon_np); if (IS_ERR(priv->usb_extcon)) return dev_err_probe(dev, PTR_ERR(priv->usb_extcon), "Failed to get extcon device");
priv->adc = devm_iio_channel_get(dev, "headset-detect"); if (IS_ERR(priv->adc)) return dev_err_probe(dev, PTR_ERR(priv->adc), "Failed to get ADC channel");
ret = iio_get_channel_type(priv->adc, &channel_type); if (ret) return dev_err_probe(dev, ret, "Failed to get ADC channel type"); if (channel_type != IIO_VOLTAGE) return -EINVAL;
priv->gpio_headset_key = devm_gpiod_get(dev, "headset-key",
GPIOD_IN); if (IS_ERR(priv->gpio_headset_key)) {
dev_err(dev, "Failed to get headset key gpio"); return PTR_ERR(priv->gpio_headset_key);
}
priv->gpio_headset_detect = devm_gpiod_get(dev, "headset-detect", GPIOD_IN); if (IS_ERR(priv->gpio_headset_detect)) {
dev_err(dev, "Failed to get headset detect gpio"); return PTR_ERR(priv->gpio_headset_detect);
}
/* Update card-name if provided through DT, else use default name */
snd_soc_of_parse_card_name(card, "model");
ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); if (ret < 0) { /* Backwards compatible way */
ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing"); if (ret < 0) {
dev_err(dev, "Audio routing invalid/unspecified\n"); return ret;
}
}
cpu = of_get_child_by_name(dev->of_node, "cpu"); if (!cpu) return -EINVAL;
codec = of_get_child_by_name(dev->of_node, "codec"); if (!codec) {
ret = -EINVAL; goto out;
}
for_each_card_prelinks(card, i, dai_link) {
dai_link->codecs->of_node = of_parse_phandle(codec, "sound-dai", 0); if (!dai_link->codecs->of_node) {
ret = -EINVAL; goto out;
}
}
/* Set CPU and platform of_node for main DAI */
aries_dai[0].cpus->of_node = of_parse_phandle(cpu, "sound-dai", 0); if (!aries_dai[0].cpus->of_node) {
ret = -EINVAL; goto out;
}
/* Set CPU of_node for BT DAI */
aries_dai[2].cpus->of_node = of_parse_phandle(cpu, "sound-dai", 1); if (!aries_dai[2].cpus->of_node) {
ret = -EINVAL; goto out;
}
ret = devm_snd_soc_register_component(dev, &aries_component,
aries_ext_dai, ARRAY_SIZE(aries_ext_dai)); if (ret < 0) {
dev_err(dev, "Failed to register component: %d\n", ret); goto out;
}
ret = devm_snd_soc_register_card(dev, card); if (ret)
dev_err(dev, "snd_soc_register_card() failed:%d\n", ret);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.