Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751543AbdGZQbh (ORCPT ); Wed, 26 Jul 2017 12:31:37 -0400 Received: from mail-wr0-f180.google.com ([209.85.128.180]:36880 "EHLO mail-wr0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750883AbdGZQbd (ORCPT ); Wed, 26 Jul 2017 12:31:33 -0400 From: Srinivas Kandagatla Subject: Re: [PATCH v1 3/3] ASoC: qcom: apq8016-sbc: enable jack detection To: Damien Riegel , alsa-devel@alsa-project.org Cc: linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Patrick Lai , Banajit Goswami , kernel@savoirfairelinux.com References: <20170725175126.26578-1-damien.riegel@savoirfairelinux.com> <20170725175126.26578-4-damien.riegel@savoirfairelinux.com> Message-ID: <009fc5d3-9ee2-c153-f208-df10b62d7467@linaro.org> Date: Wed, 26 Jul 2017 17:31:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170725175126.26578-4-damien.riegel@savoirfairelinux.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2108 Lines: 67 On 25/07/17 18:51, Damien Riegel wrote: > Now that the pm8916 audio codec has support for jack detection, let the > sound card driver use it. > > Signed-off-by: Damien Riegel > --- > sound/soc/qcom/apq8016_sbc.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c > index d084d7468299..5f03f6249397 100644 > --- a/sound/soc/qcom/apq8016_sbc.c > +++ b/sound/soc/qcom/apq8016_sbc.c > @@ -19,11 +19,14 @@ > #include > #include > #include > +#include > #include > #include > #include > #include > > +#include "../codecs/msm8916-wcd-analog.h" > + > struct apq8016_sbc_data { > void __iomem *mic_iomux; > void __iomem *spkr_iomux; > @@ -35,13 +38,26 @@ struct apq8016_sbc_data { > #define MIC_CTRL_TLMM_SCLK_EN BIT(1) > #define SPKR_CTL_PRI_WS_SLAVE_SEL_11 (BIT(17) | BIT(16)) > > +static struct snd_soc_jack apq8016_jack; > + > static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) > { > struct snd_soc_dai *cpu_dai = rtd->cpu_dai; > struct snd_soc_card *card = rtd->card; > + struct snd_soc_codec *codec = rtd->codec; This driver uses multicodec, so this will not work to start with. Also this function is used for different codec devices on the SOC, so we should take care that we are might be talking to 3 different possible codecs. > struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card); > int rval = 0; > > + if (!apq8016_jack.jack) { > + rval = snd_soc_card_jack_new(card, "headset", > + SND_JACK_MECHANICAL, > + &apq8016_jack, NULL, 0); > + if (rval) > + return rval; > + > + pm8916_wcd_analog_jack_detect(codec, &apq8016_jack); We already have an api to do this snd_soc_codec_set_jack() > + } > + > switch (cpu_dai->id) { > case MI2S_PRIMARY: > writel(readl(pdata->spkr_iomux) | SPKR_CTL_PRI_WS_SLAVE_SEL_11, >