Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1877432imu; Fri, 14 Dec 2018 02:04:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/U8b6q0ajk/zTWM1M8doS7SNGEjutjOJqldAqhO/cRV0h28/XdFH/zxT8ZE/hIdWSbjfYNr X-Received: by 2002:a62:6f88:: with SMTP id k130mr2209717pfc.234.1544781855766; Fri, 14 Dec 2018 02:04:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544781855; cv=none; d=google.com; s=arc-20160816; b=0ZWesc09dbDqJNaixnDX3kNC/t4QenJdtYGAcg5LltkYcN7BkrknD+XnixrehiSIXf WI/Z2TRiAjB/DveeCthNFknrTW70qvtM+ryf9NQp5oWGOW8mx3JEQ2FhGZDTO9x4quI0 d2s0jfdK9UlQvEujEDoQyqOlgS6/kOxyrnIpRrNzmTQ9AMU23iVh9W+D173AndzM9RhY LyKdr8bym9I6Ew9X84y7eizwqmlYsPZiBffr+30819+b7eBWqh+UWNXVq4UioJ099q+N qE23ENMfYFFPp0BI3O5WgQRq/4EK4DK/QKHbBq9CEVHc+GniHGJYMMl1j0+DLy/8Z/av tbug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature; bh=kP3aN9dDkI3BR+RKuQy2t1bBlh4SW3YRWkYS1LsiQSQ=; b=CxVkuZ/Yi7Ukbdy0S62JnodnPVF5oWasK6xXDI0a88tP/2kAOtd84ie/8rcuM9lowb Q1YIvz9PFb7ZCWRkxwnOhFz9oxhiqMtLNlmrJHMyOwF+Njz1D+NPpK97Teucxasg+Buf EoP3Bxc2bC08xIMvTWVCZpDMJ2y9JbNtWvUvNj5nrHuww/3iRPO7qdBRLYOh8cBYZB2s GZ1N8Lc1Pgz2RLShNp1QXSmsjqhWlF+kkieB2r49ociejOR5lRK135wAR6J0M3BStBTA l1use359fRcxK1wXZryhEQhnzm19JcwKROUTdyEwPKTHq9MwBv5qid1ytwCwCtkpWMXH OsKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=bwUa5lzR; dkim=pass header.i=@codeaurora.org header.s=default header.b=Pq92H0Bf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22si4017054pfa.6.2018.12.14.02.04.00; Fri, 14 Dec 2018 02:04:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=bwUa5lzR; dkim=pass header.i=@codeaurora.org header.s=default header.b=Pq92H0Bf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729067AbeLNKB7 (ORCPT + 99 others); Fri, 14 Dec 2018 05:01:59 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:34244 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726494AbeLNKB6 (ORCPT ); Fri, 14 Dec 2018 05:01:58 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D752660908; Fri, 14 Dec 2018 10:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1544781717; bh=MDdzNnCyavSco/A4gQtzIpTyw0zQ4CnT3d5VBHUA+Yc=; h=From:To:Cc:Subject:Date:From; b=bwUa5lzRaJNRB6xLyf2x5caNUju6q3Jgm8TW5egS7ZqB1dc2JFW2KlwuF+iKd6q+y 0M7IflC1EpwDIAb85yE5sqYTkKWCYym9kX23UZJnWhSKzLutQZxnA79GKF+EtWXvSj mXwsaInqMzj+JFxx7ld3LfuynxRi37cVgBi8kAmA= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from rohkumar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rohitkr@codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8189D60722; Fri, 14 Dec 2018 10:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1544781716; bh=MDdzNnCyavSco/A4gQtzIpTyw0zQ4CnT3d5VBHUA+Yc=; h=From:To:Cc:Subject:Date:From; b=Pq92H0Bfy5tonGDXYgd+A+BzHshaJ/ea3elCs/X9QyGVo6xe/PC1PU/skOsVc0l/z GVOOFm9NTVksTN25kQRxZ1Ib79v5FC5SUyOnbRsRv5C6NShflMkRGC1xdvcickSkLo Bi2j1ADDEhtOwRybokrsXdR/SEOqWYofnxsAHTtc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8189D60722 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=rohitkr@codeaurora.org From: Rohit kumar To: plai@codeaurora.org, bgoswami@codeaurora.org, asishb@codeaurora.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, rohkumar@qti.qualcomm.com, srinivas.kandagatla@linaro.org Cc: Rohit kumar Subject: [PATCH] ASoC: sdm845: set jack only for a specific backend Date: Fri, 14 Dec 2018 15:31:43 +0530 Message-Id: <1544781703-9585-1-git-send-email-rohitkr@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Headset codec is connected over PRIMARY_MI2S interface. Call set_jack for codec associated with Primary Mi2s interface. Also, set_jack to NULL when jack is freed. Signed-off-by: Rohit kumar --- sound/soc/qcom/sdm845.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c index 1db8ef66..6f66a58 100644 --- a/sound/soc/qcom/sdm845.c +++ b/sound/soc/qcom/sdm845.c @@ -158,17 +158,24 @@ static int sdm845_snd_hw_params(struct snd_pcm_substream *substream, return ret; } +static void sdm845_jack_free(struct snd_jack *jack) +{ + struct snd_soc_component *component = jack->private_data; + + snd_soc_component_set_jack(component, NULL, NULL); +} + 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 snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct sdm845_snd_data *pdata = snd_soc_card_get_drvdata(card); - int i, rval; + struct snd_jack *jack; + int rval; if (!pdata->jack_setup) { - struct snd_jack *jack; - rval = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_HEADPHONE | @@ -190,16 +197,22 @@ static int sdm845_dai_init(struct snd_soc_pcm_runtime *rtd) pdata->jack_setup = true; } - for (i = 0 ; i < dai_link->num_codecs; i++) { - struct snd_soc_dai *dai = rtd->codec_dais[i]; + switch (cpu_dai->id) { + case PRIMARY_MI2S_RX: + jack = pdata->jack.jack; + component = codec_dai->component; - component = dai->component; - rval = snd_soc_component_set_jack( - component, &pdata->jack, NULL); + jack->private_data = component; + jack->private_free = sdm845_jack_free; + 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; } + break; + default: + break; } return 0; -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc., is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.