Skip to content

Commit

Permalink
ASoC: tlv320aic31xx: Add button press detection
Browse files Browse the repository at this point in the history
This device can optionally detect headset or microphone button presses.
Add support for this by passing this event to the jack layer.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Andrew F. Davis authored and Mark Brown committed Apr 2, 2019
1 parent ebf3326 commit 90f0202
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 15 additions & 2 deletions sound/soc/codecs/tlv320aic31xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,10 +1423,21 @@ static irqreturn_t aic31xx_irq(int irq, void *data)
dev_err(dev, "Short circuit on Left output is detected\n");
if (value & AIC31XX_HPRSCDETECT)
dev_err(dev, "Short circuit on Right output is detected\n");
if (value & AIC31XX_HSPLUG) {
if (value & (AIC31XX_HSPLUG | AIC31XX_BUTTONPRESS)) {
unsigned int val;
int status = 0;

ret = regmap_read(aic31xx->regmap, AIC31XX_INTRDACFLAG2,
&val);
if (ret) {
dev_err(dev, "Failed to read interrupt mask: %d\n",
ret);
goto exit;
}

if (val & AIC31XX_BUTTONPRESS)
status |= SND_JACK_BTN_0;

ret = regmap_read(aic31xx->regmap, AIC31XX_HSDETECT, &val);
if (ret) {
dev_err(dev, "Failed to read headset type: %d\n", ret);
Expand All @@ -1451,7 +1462,8 @@ static irqreturn_t aic31xx_irq(int irq, void *data)
}
if (value & ~(AIC31XX_HPLSCDETECT |
AIC31XX_HPRSCDETECT |
AIC31XX_HSPLUG))
AIC31XX_HSPLUG |
AIC31XX_BUTTONPRESS))
dev_err(dev, "Unknown DAC interrupt flags: 0x%08x\n", value);

read_overflow:
Expand Down Expand Up @@ -1564,6 +1576,7 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c,

regmap_write(aic31xx->regmap, AIC31XX_INT1CTRL,
AIC31XX_HSPLUGDET |
AIC31XX_BUTTONPRESSDET |
AIC31XX_SC |
AIC31XX_ENGINE);

Expand Down
3 changes: 2 additions & 1 deletion sound/soc/codecs/tlv320aic31xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#define DAC31XX_BIT BIT(3)

#define AIC31XX_JACK_MASK (SND_JACK_HEADPHONE | \
SND_JACK_HEADSET)
SND_JACK_HEADSET | \
SND_JACK_BTN_0)

enum aic31xx_type {
AIC3100 = 0,
Expand Down

0 comments on commit 90f0202

Please sign in to comment.