lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 8 Nov 2017 18:27:41 -0600
From:   "Andrew F. Davis" <afd@...com>
To:     Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Benoît Cousson <bcousson@...libre.com>,
        Tony Lindgren <tony@...mide.com>
CC:     <alsa-devel@...a-project.org>, <devicetree@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, "Andrew F . Davis" <afd@...com>
Subject: [PATCH 17/17] NOT FOR MERGING: Add demo jack detection policy for testing

---
 sound/soc/codecs/tlv320aic31xx.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c
index 46cd132e93ef..12daba8f60cd 100644
--- a/sound/soc/codecs/tlv320aic31xx.c
+++ b/sound/soc/codecs/tlv320aic31xx.c
@@ -1192,9 +1192,24 @@ static int aic31xx_set_bias_level(struct snd_soc_codec *codec,
 	return 0;
 }
 
+/* On a headphone jack event (headphones are inserted or removed from the
+ * the headphone jack) we disable the "Speaker External" widget and enable
+ * the "Headphone Jack" widget, on removal the opposite will occur. These
+ * widgets should be defined by, and their audio policy determined by, the
+ * parent sound card as only it can know how this CODEC is integrated into
+ * the bigger picture sound card device. Unfortunately the generic
+ * "simple-card" used to instantiate many of these CODECs on boards does
+ * not support this yet, so we do it here in the CODEC as an example.
+ */
+static struct snd_soc_jack_pin aic31xx_jack_pins[] = {
+	{ .pin = "Speaker External", .mask = SND_JACK_HEADPHONE, .invert = true, },
+	{ .pin = "Headphone Jack", .mask = SND_JACK_HEADPHONE, },
+};
+
 static int aic31xx_codec_probe(struct snd_soc_codec *codec)
 {
 	struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec);
+	struct snd_soc_card *card = codec->component.card;
 	int i, ret;
 
 	dev_dbg(aic31xx->dev, "## %s\n", __func__);
@@ -1226,6 +1241,17 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec)
 	if (ret)
 		return ret;
 
+	aic31xx->jack = devm_kzalloc(aic31xx->dev, sizeof(*aic31xx->jack), GFP_KERNEL);
+	if (!aic31xx->jack)
+		return -ENOMEM;
+	ret = snd_soc_card_jack_new(card, "Headphone Jack", AIC31XX_JACK_MASK,
+				    aic31xx->jack, aic31xx_jack_pins,
+				    ARRAY_SIZE(aic31xx_jack_pins));
+	if (ret) {
+		dev_err(codec->dev, "Cannot create jack\n");
+		return ret;
+	}
+
 	return 0;
 }
 
-- 
2.15.0

Powered by blists - more mailing lists