alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: Intel: Boards: Support headset button function for nau88l25max and nau88l25ssm
@ 2020-05-07 22:03 Radoslaw Biernacki
  2020-05-08 14:45 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 2+ messages in thread
From: Radoslaw Biernacki @ 2020-05-07 22:03 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Liam Girdwood, Jie Yang, Jaroslav Kysela,
	Takashi Iwai
  Cc: Chinyue Chen, alsa-devel, Radoslaw Biernacki, linux-kernel,
	Ben Zhang, Marcin Wojtas, Benson Leung, Alex Levin

Map the buttons from the Android reference headset to
KEY_PLAYPAUSE, KEY_VOICECOMMAND, KEY_VOLUMEUP, and KEY_VOLUMEDOWN.
KEY_PLAYPAUSE is used instead of KEY_MEDIA for BTN_0 as it is more
logical and have much broader userspace support. Like Chrome OS
use it to play/pause of video and audio. KEY_PLAYPAUSE is also
supported by Android (USB headset spec requires KEY_PLAYPAUSE
for BTN_0.)
https://source.android.com/devices/accessories/headset/usb-headset-spec

Signed-off-by: Chinyue Chen <chinyue@chromium.org>
Signed-off-by: Benson Leung <bleung@chromium.org>
Signed-off-by: Radoslaw Biernacki <rad@semihalf.com>
---
 sound/soc/intel/boards/skl_nau88l25_max98357a.c | 7 +++++++
 sound/soc/intel/boards/skl_nau88l25_ssm4567.c   | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
index d7b8154c43a4..103ea94c3bd1 100644
--- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c
+++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c
@@ -6,6 +6,7 @@
  * Copyright (C) 2015, Intel Corporation. All rights reserved.
  */
 
+#include <linux/input.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <sound/core.h>
@@ -158,6 +159,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
 {
 	int ret;
 	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
+	struct snd_soc_jack *jack;
 
 	/*
 	 * Headset buttons map to the google Reference headset.
@@ -172,6 +174,11 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
 		return ret;
 	}
 
+	jack = &skylake_headset;
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
 	nau8825_enable_jack_detect(component, &skylake_headset);
 
 	snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");
diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
index 4b317bcf6ea0..1528e72c3a11 100644
--- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
+++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c
@@ -10,6 +10,7 @@
  *   Copyright (C) 2015, Intel Corporation. All rights reserved.
  */
 
+#include <linux/input.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <sound/core.h>
@@ -177,6 +178,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
 {
 	int ret;
 	struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component;
+	struct snd_soc_jack *jack;
 
 	/*
 	 * 4 buttons here map to the google Reference headset
@@ -191,6 +193,11 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd)
 		return ret;
 	}
 
+	jack = &skylake_headset;
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
+	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
 	nau8825_enable_jack_detect(component, &skylake_headset);
 
 	snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC");

base-commit: f8729a41aa17f5eb5291a0e78926154e948bb4ad
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: Intel: Boards: Support headset button function for nau88l25max and nau88l25ssm
  2020-05-07 22:03 [PATCH] ASoC: Intel: Boards: Support headset button function for nau88l25max and nau88l25ssm Radoslaw Biernacki
@ 2020-05-08 14:45 ` Pierre-Louis Bossart
  0 siblings, 0 replies; 2+ messages in thread
From: Pierre-Louis Bossart @ 2020-05-08 14:45 UTC (permalink / raw)
  To: Radoslaw Biernacki, Liam Girdwood, Jie Yang, Jaroslav Kysela,
	Takashi Iwai
  Cc: Chinyue Chen, alsa-devel, linux-kernel, Ben Zhang, Marcin Wojtas,
	Benson Leung, Alex Levin



On 5/7/20 5:03 PM, Radoslaw Biernacki wrote:
> Map the buttons from the Android reference headset to
> KEY_PLAYPAUSE, KEY_VOICECOMMAND, KEY_VOLUMEUP, and KEY_VOLUMEDOWN.
> KEY_PLAYPAUSE is used instead of KEY_MEDIA for BTN_0 as it is more
> logical and have much broader userspace support. Like Chrome OS
> use it to play/pause of video and audio. KEY_PLAYPAUSE is also
> supported by Android (USB headset spec requires KEY_PLAYPAUSE
> for BTN_0.)
> https://source.android.com/devices/accessories/headset/usb-headset-spec
> 
> Signed-off-by: Chinyue Chen <chinyue@chromium.org>
> Signed-off-by: Benson Leung <bleung@chromium.org>
> Signed-off-by: Radoslaw Biernacki <rad@semihalf.com>

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-08 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 22:03 [PATCH] ASoC: Intel: Boards: Support headset button function for nau88l25max and nau88l25ssm Radoslaw Biernacki
2020-05-08 14:45 ` Pierre-Louis Bossart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).