From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Cheng-Yi Chiang <cychiang@chromium.org>, linux-kernel@vger.kernel.org
Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org,
tzungbi@chromium.org, Mark Brown <broonie@kernel.org>,
Rohit kumar <rohitkr@codeaurora.org>,
dgreid@chromium.org
Subject: Re: [alsa-devel] [PATCH 2/4] ASoC: qcom: sdm845: Create and setup jack in init callback
Date: Tue, 27 Nov 2018 09:17:16 +0000 [thread overview]
Message-ID: <3036c1c3-84a6-0306-1aff-434e1087f6ad@linaro.org> (raw)
In-Reply-To: <20181124110948.209019-2-cychiang@chromium.org>
On 24/11/18 11:09, Cheng-Yi Chiang wrote:
> Add a callback for init ops on dai_link to create and setup jack.
>
> Signed-off-by: Rohit kumar <rohitkr@codeaurora.org>
> Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> sound/soc/qcom/sdm845.c | 57 +++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 55 insertions(+), 2 deletions(-)
>
> diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c
> index 95d8d4422dae0..43c03f8e8cdc2 100644
> --- a/sound/soc/qcom/sdm845.c
> +++ b/sound/soc/qcom/sdm845.c
> @@ -8,6 +8,8 @@
> #include <linux/of_device.h>
> #include <sound/pcm.h>
> #include <sound/pcm_params.h>
> +#include <sound/jack.h>
> +#include <uapi/linux/input-event-codes.h>
> #include "common.h"
> #include "qdsp6/q6afe.h"
>
> @@ -17,6 +19,8 @@
> #define MI2S_BCLK_RATE 1536000
>
> struct sdm845_snd_data {
> + struct snd_soc_jack jack;
> + bool jack_setup;
> struct snd_soc_card *card;
> uint32_t pri_mi2s_clk_count;
> uint32_t sec_mi2s_clk_count;
> @@ -100,6 +104,54 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream,
> return ret;
> }
>
> +static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd)
> +{
> + struct snd_soc_component *component;
> + struct snd_soc_dai_link *dai_link = rtd->dai_link;
> + struct snd_soc_card *card = rtd->card;
> + struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card);
> + int i, rval;
> +
> + if (!pdata->jack_setup) {
> + struct snd_jack *jack;
> +
> + rval = snd_soc_card_jack_new(card, "Headset Jack",
> + SND_JACK_HEADSET |
> + SND_JACK_HEADPHONE |
> + SND_JACK_BTN_0 | SND_JACK_BTN_1 |
> + SND_JACK_BTN_2 | SND_JACK_BTN_3,
> + &pdata->jack, NULL, 0);
> +
> + if (rval < 0) {
> + dev_err(card->dev, "Unable to add Headphone Jack\n");
> + return rval;
> + }
> +
> + jack = pdata->jack.jack;
> +
> + snd_jack_set_key(jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
> + snd_jack_set_key(jack, SND_JACK_BTN_1, KEY_VOICECOMMAND);
> + snd_jack_set_key(jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
> + snd_jack_set_key(jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
> + pdata->jack_setup = true;
> + }
> +
> + for (i = 0 ; i < dai_link->num_codecs; i++) {
> + struct snd_soc_dai *dai = rtd->codec_dais[i];
> +
> + component = dai->component;
> + rval = snd_soc_component_set_jack(
> + component, &pdata->jack, NULL);
> + if (rval != 0 && rval != -ENOTSUPP) {
> + dev_warn(card->dev, "Failed to set jack: %d\n", rval);
> + return rval;
> + }
> + }
> +
> + return 0;
> +}
> +
> +
> static int sdm845_snd_startup(struct snd_pcm_substream *substream)
> {
> unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS;
> @@ -220,7 +272,7 @@ static const struct snd_soc_dapm_widget sdm845_snd_widgets[] = {
> SND_SOC_DAPM_MIC("Int Mic", NULL),
> };
>
> -static void sdm845_add_be_ops(struct snd_soc_card *card)
> +static void sdm845_add_ops(struct snd_soc_card *card)
> {
> struct snd_soc_dai_link *link;
> int i;
> @@ -230,6 +282,7 @@ static void sdm845_add_be_ops(struct snd_soc_card *card)
> link->ops = &sdm845_be_ops;
> link->be_hw_params_fixup = sdm845_be_hw_params_fixup;
> }
> + link->init = sdm845_dai_init;
> }
> }
>
> @@ -264,7 +317,7 @@ static int sdm845_snd_platform_probe(struct platform_device *pdev)
> data->card = card;
> snd_soc_card_set_drvdata(card, data);
>
> - sdm845_add_be_ops(card);
> + sdm845_add_ops(card);
> ret = snd_soc_register_card(card);
> if (ret) {
> dev_err(dev, "Sound card registration failed\n");
>
next prev parent reply other threads:[~2018-11-27 9:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-24 11:09 [PATCH 1/4] ASoC: qcom: sdm845: Add board specific dapm widgets Cheng-Yi Chiang
2018-11-24 11:09 ` [PATCH 2/4] ASoC: qcom: sdm845: Create and setup jack in init callback Cheng-Yi Chiang
2018-11-27 9:17 ` Srinivas Kandagatla [this message]
2018-11-24 11:09 ` [PATCH 3/4] ASoC: qcom: sdm845: Add codec related configuration for sdm845 Cheng-Yi Chiang
2018-11-27 9:32 ` [alsa-devel] " Srinivas Kandagatla
2018-11-28 10:56 ` Cheng-yi Chiang
2018-11-24 11:09 ` [PATCH 4/4] ASoC: qcom: Kconfig: select config for codec Cheng-Yi Chiang
2018-11-27 9:17 ` [alsa-devel] " Srinivas Kandagatla
2018-11-27 9:17 ` [alsa-devel] [PATCH 1/4] ASoC: qcom: sdm845: Add board specific dapm widgets Srinivas Kandagatla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3036c1c3-84a6-0306-1aff-434e1087f6ad@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cychiang@chromium.org \
--cc=dgreid@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=rohitkr@codeaurora.org \
--cc=tzungbi@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).