From patchwork Wed Jul 26 00:35:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 108721 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp198442qge; Tue, 25 Jul 2017 17:35:31 -0700 (PDT) X-Received: by 10.84.140.3 with SMTP id 3mr23811138pls.374.1501029331542; Tue, 25 Jul 2017 17:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501029331; cv=none; d=google.com; s=arc-20160816; b=CQFS8AEoyX6Ltzt2aFCnqEUIuJ7vPkw4muPY7mHHfwiKNVZ0vztLFDtN/W0mfvq6Ml fQvckFy/hU+bojNUpNYHcpwPi7aIgi5l31pAxvXFh9+J4DZr9TyNEveaIYTMRDVmINEm d74V1FC5mWJLDY/IVes/uE5sV3WlhgqGuDhPKvnYqhGQ5lk5L3AEC4131ISur50s/e71 sEhTfvSAXc0gfSXZfs9nexF7s10hs1QiXrvP2YxGXXMY6HN46lHHq7YFJm5ZhXYhyWrA jmryTux4foAktyD1+i7l4PSAARVd1zAzBBfZKrFZkf3odx+YZZjewwxELKGXxBjLqaIZ LsRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=TR9zC317Kp7gqGfgz4u66mf0tfjnT4mjZLI3ecSmdzw=; b=t2Tl0pTr5XHxS4VsjOt5gKI0cVbKsia0lzHkba/i4sqv6an1V89kxQa9CDBuYV3QAM w9RZo6tvCVkfQJr5EKzVHu+PBWHqbBAomTlOIhFKp6h+scMt3E/k6xcxVLEgWjqjqfBE 2o6SqyIWbfz3M54KCQQh611tItkumaMKoIbuW3NQLWdFt1SCzu/XMWaCvUEObV3pS/jt gf5ydTGmjRrDRB/W2LMXJQwuN5Bf2RxSfTt73vVZQvEj+nLzsmDsBOMZAQsJNRu8cDtp +hrYncuKdukhenGCCKG0qM9/B6G69gvNGTFW1KRYUeBuUIwj2d2yuqIGv2EASXQSUojM 4dFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=HdBox3oQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si8931433pgc.125.2017.07.25.17.35.31; Tue, 25 Jul 2017 17:35:31 -0700 (PDT) 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=@linaro.org header.b=HdBox3oQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751817AbdGZAf2 (ORCPT + 26 others); Tue, 25 Jul 2017 20:35:28 -0400 Received: from mail-it0-f46.google.com ([209.85.214.46]:35959 "EHLO mail-it0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751625AbdGZAf0 (ORCPT ); Tue, 25 Jul 2017 20:35:26 -0400 Received: by mail-it0-f46.google.com with SMTP id v205so42837968itf.1 for ; Tue, 25 Jul 2017 17:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TR9zC317Kp7gqGfgz4u66mf0tfjnT4mjZLI3ecSmdzw=; b=HdBox3oQT6jtW9qBuWA3KzLnjgwsZasJolu54Gzmnw+p3n6QrwEvgdo/yRf0B0555D ATYrtpNai38vAZMYNuXV5GFL5bfNPGyA7KuM7roBMrCC1vzR6mfzYfUbYxax1nvTyYJ+ oWrqGwSC3Uohw75CIMNXyAAYShrVhnAD+HShE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TR9zC317Kp7gqGfgz4u66mf0tfjnT4mjZLI3ecSmdzw=; b=c+KU2f3mXYzcTYKoxGkrHRcCKJmkfDVTRtRcQTs1jTvvgkl3K0hsEfTMgDn7zKXjjf T6TR8JF6BHTiIbIrhE0KBjmIpMb46OzzT97KGIrewwg1KLHk0UV2ddB9ySXNIyWUIV5b +I2ZclKDoq0IiNne/nWE4QQGr0lbvI/UoOwFraQ6oCJazgDSjyrZ7M7EqI2QI3LZl0aE 98H9IzzhgO+Yc6oYIyD/w49aijoIYiacRGguehnFOoUTnng6KIgsPE4hrPRl4Z3Ol539 GTOZsCTGcuJnC3InVGqYXTms0Tu82e2H6vs/++gPPvOUS1czTF7l9OyWwxBlERrs49xL t45A== X-Gm-Message-State: AIVw110I+bQ/PrgluXu08myZuoMQ0+MlZ1MdjUEe4SyEanaWMvRTqgOs i0X2gOQ/GJ3R5nP7 X-Received: by 10.36.94.129 with SMTP id h123mr8053373itb.110.1501029325628; Tue, 25 Jul 2017 17:35:25 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id l69sm5097373ioi.49.2017.07.25.17.35.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:25 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1 1/6] ASoC: jack: fix snd_soc_codec_set_jack return error Date: Wed, 26 Jul 2017 02:35:07 +0200 Message-Id: <20170726003512.18965-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla This patch changes the error code returned by snd_soc_codec_set_jack() from -EINVAL to -ENOTSUPP. The reason to do this is to make the caller aware that the underlying codec does not support this callback. This can make the caller write the code to handle this case properly. Other reason is that -EINVAL is not the correct error to return in this case anyway. Signed-off-by: Srinivas Kandagatla --- sound/soc/soc-jack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.3 diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 7daf21f..42ca9f1 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -36,7 +36,7 @@ int snd_soc_codec_set_jack(struct snd_soc_codec *codec, if (codec->driver->set_jack) return codec->driver->set_jack(codec, jack, data); else - return -EINVAL; + return -ENOTSUPP; } EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack); From patchwork Wed Jul 26 00:35:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 108722 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp198489qge; Tue, 25 Jul 2017 17:35:35 -0700 (PDT) X-Received: by 10.84.197.3 with SMTP id m3mr22959581pld.47.1501029334990; Tue, 25 Jul 2017 17:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501029334; cv=none; d=google.com; s=arc-20160816; b=o75Lzesxdp+rhfinhCjgFoOvQnT6lejm6Ryzs01wpEQZ+Bb8DSPE+t/o2QXK8+WgdA g34C+GHLzHYRKjPdN5XQkrAizzL5yn9sS+jjO8UwuPbVPCAlU3HfgMFaEP3FQBqEN6aU ecngd+D1j9thT5VlZFJJSwCZsUzp2LZQHSPxyfjJZNC6lY+eK8HaFWayzPQdIxIDEMzZ nSUxl/inlmGAOV64klD4EkHDKVOUCbvRjN30hwOdqHzyXjLck/RqvpQYwdDbmpF5EIat oTT1qISGo3p5BtoAAZo1Rr4l+D1vQaIbmiC8+W2idR4iniykr6WN7pq5++BVbHGHRjNQ 3hWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=M7J7leBNufaADzHnHG+fCjJkbKOJuFQemnPo08vwkCw=; b=LJ3gkQjKtxrsPbtqu36zwHmVEAShNsRq5sLGGBe63refppP5VIRWjhwBzZwiZpKs1y lMpcd7Ew6yZOrhy+4zzc2pSowoKrBTTPcJY3suS6O8GNJSwPjULl4bJhufGXZhIYVZQ+ 8W38wXJwfaXkheur5DbpkvsQu9rx5tXkDCSEegVm8P0w9bqJQKLGg0S9bcSn6QTIN9de g22ODFf/A/P5lbD8GUIzcjVN+AunAiK205CIpuTYKq8VoT2PDg5TllQpHoAUXKjMxzGb DKJDV/pZebQfj6rtr9r6H65rECS/4hyzpbny/0C+TsN7bSwC17ax3L4lMnT1Xc5HUXq1 t/Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=eOQR7yGj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si8931433pgc.125.2017.07.25.17.35.34; Tue, 25 Jul 2017 17:35:34 -0700 (PDT) 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=@linaro.org header.b=eOQR7yGj; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751846AbdGZAfa (ORCPT + 26 others); Tue, 25 Jul 2017 20:35:30 -0400 Received: from mail-it0-f53.google.com ([209.85.214.53]:35230 "EHLO mail-it0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbdGZAf2 (ORCPT ); Tue, 25 Jul 2017 20:35:28 -0400 Received: by mail-it0-f53.google.com with SMTP id h199so59604302ith.0 for ; Tue, 25 Jul 2017 17:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=M7J7leBNufaADzHnHG+fCjJkbKOJuFQemnPo08vwkCw=; b=eOQR7yGj9xohzlP/m1tdfi2HdOBN9we61fl8B4k9Tjje6aeSBVaqmLPdoTny5DV7K8 Yuf7wl7gZ6TvHoMw8pqlPyXDZF0qn/sUoy8+imlyGwQetopCXosSlRmybbJ8+U+Osk4l 5v4xCrdg+UFsvRib3xLLM6ZeBX2qY2R2pOcsg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=M7J7leBNufaADzHnHG+fCjJkbKOJuFQemnPo08vwkCw=; b=LiXmoVnuPHU3PpEFW9wV4pbiNLf2bvwg+rgEKLJnyjIYp5nVcRamvuyMQFB938vfZ0 eTSJKJ0tl161ejwlI0cNPSsNZyAiAVsnS4UcTkCiPt51Y775QX37aycvj/QvrWmmyFmJ 97vh0NkbA6URmJn0Clvd55t9LQzg3G80wMakSBdGMEtH8Bt+aUtx57DDiFRMKOwv+EEv 2FIYz574QCIIbgyphHdUWwQlDvUuSut9co8195WQTAZafmksDD2vB4D3WzMXm7vFo3JF PpjouDMZHvuDSihID4CxOWA5bQop4G/uHWYqR0pPeP6HvwLpJXbr1NdREyO3ChLohunt D0ug== X-Gm-Message-State: AIVw110SYtxlgq7peVUtzG/CRm3URrhW4vVMdUTrD9zMnNcrUhbsW5qF YkY7vDE9vgn5YkXK X-Received: by 10.36.30.10 with SMTP id 10mr13397329itt.8.1501029327658; Tue, 25 Jul 2017 17:35:27 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id l69sm5097373ioi.49.2017.07.25.17.35.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:27 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Damien Riegel Subject: [PATCH v1 2/6] ASoC: codecs: msm8916-analog: fix DIG_CLK_CTL_RXD3_CLK_EN define Date: Wed, 26 Jul 2017 02:35:08 +0200 Message-Id: <20170726003512.18965-3-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Damien Riegel The wrong bit is assigned to DIG_CLK_CTL_RXD3_CLK_EN, change it for the correct one. Signed-off-by: Damien Riegel Acked-by: Srinivas Kandagatla --- sound/soc/codecs/msm8916-wcd-analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.3 diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index a788029..5710fd4 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -36,7 +36,7 @@ #define CDC_D_CDC_DIG_CLK_CTL (0xf04A) #define DIG_CLK_CTL_RXD1_CLK_EN BIT(0) #define DIG_CLK_CTL_RXD2_CLK_EN BIT(1) -#define DIG_CLK_CTL_RXD3_CLK_EN BIT(3) +#define DIG_CLK_CTL_RXD3_CLK_EN BIT(2) #define DIG_CLK_CTL_TXD_CLK_EN BIT(4) #define DIG_CLK_CTL_NCP_CLK_EN_MASK BIT(6) #define DIG_CLK_CTL_NCP_CLK_EN BIT(6) From patchwork Wed Jul 26 00:35:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 108726 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp199383qge; Tue, 25 Jul 2017 17:36:53 -0700 (PDT) X-Received: by 10.101.85.14 with SMTP id f14mr21540839pgr.45.1501029413697; Tue, 25 Jul 2017 17:36:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501029413; cv=none; d=google.com; s=arc-20160816; b=fUTJYorzlOE/IFRyK/YnmXmpteMXxhYcWBR9l40fToKSmHj3pvdEXWaosb0KvWvzeX ArFGA+6jCyZaxulm0x60xE4fIDfvuyg/Vja/iEm34+x43QpzTeXeZTybBBYaaZfeRaRT OxfTShWkshjqLlMnlrqPembKCuZzvl5y4qf2i+srp3P5WEyI62uxs0T1gSI5doZJlhxT rRRRunUNB1tVeS+LMmhd7qr0cUXdCbWZ82NWjOMlwshbfmjRC9OlLqAD4wMTvdfRreHS Qm64e3NRG1zjMG8JQ1JL14vZu8JQtPLADddFcL80R7YmUrJGtNcdQrDkrGwWKV1NH7zv zpLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=mfGaft69n+criO1Q5biwXmSJRMtJB6GBLBsprFxzyVo=; b=FmjOopL2W1z9ddYQYWMjwdJnQXprpefh/ls6gtzwYZDWmEpqa/e67yCgnp3iKtQ33Y NHMqA1iqjt2TKt7XRBtOei3dxzWohHlQgdwf58z4o5ECriA7KV3QnbIi3CohpW+v9LUQ o9vxlm4h5NeRxNeutAN2ZPxGxp2RmsJXOarLaIwrwD2TZlo9NjInj5daqyFn5wvHz3nf Ycb44wx69zSpciI2rzHd1LcPLK19vEAS48elkdG3af/mE00omP0kJWS4GB6lluSvke6F WGv4M96rVCHejB1yy5Gr7pTS5LANBKDUHbb1RwaJlpd8E/DnxFpXVIO2PJ+xAhWk8hJ8 wVoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=DKZmPnJJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si7178459plt.612.2017.07.25.17.36.53; Tue, 25 Jul 2017 17:36:53 -0700 (PDT) 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=@linaro.org header.b=DKZmPnJJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751717AbdGZAgv (ORCPT + 26 others); Tue, 25 Jul 2017 20:36:51 -0400 Received: from mail-io0-f180.google.com ([209.85.223.180]:38813 "EHLO mail-io0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751758AbdGZAfa (ORCPT ); Tue, 25 Jul 2017 20:35:30 -0400 Received: by mail-io0-f180.google.com with SMTP id g13so61994871ioj.5 for ; Tue, 25 Jul 2017 17:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mfGaft69n+criO1Q5biwXmSJRMtJB6GBLBsprFxzyVo=; b=DKZmPnJJYyIi64DKw3CmmFMVweUhVT+FL2/inoCe7jHsWdkOVMtqBfwBHf4CBlH2Cs rchd+bmrbIPm0zAdK5Jr8zXG8Jqn/IcrC4U+8L6Knu6lc8ijO1aeRrH1LbdPi/d04BkC LErmEYWIbPChufGWAIEgAi6YMY2vKYMxdpXP0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mfGaft69n+criO1Q5biwXmSJRMtJB6GBLBsprFxzyVo=; b=Fx6f4gzHP7QH0VXHCnD+Ye9lq0ZtFaOCxRxtWYs1ERv9sC8jJicSY5/QdHgogxN3Nm BIW/8sVaB2Ovq25ZkKOstJOS9uZBc78pfgyWzSigX5lps2VrIGHsSojCz1MIf6FN07eE jDIDjhE3+RNd4LRhAhsjIvZ0d29XoqH7D8Z4LjyYfHl+HOBoi6opPPkMT19OK7gvypTj JRTjp7GZUzf6DxSqkhu2M2DopxhUI2riqrJt6dbuzqUVEFVwJtsBGn1atl1gQ1/4zUfd DYD1sdiQGD+mM2k/JN7Z8+4gHEk+4x2pMRnaBZ1ta5Q2hiQ15chppdoHXizjAwIWtdkj Q/+Q== X-Gm-Message-State: AIVw111+hMBQt15u9OYvA0p4HzNrePUbnF5/Qbw0bQItORV95EL/jMqF qlQclAud6/1V2PziZXKMIw== X-Received: by 10.107.5.72 with SMTP id 69mr20380591iof.153.1501029329531; Tue, 25 Jul 2017 17:35:29 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id l69sm5097373ioi.49.2017.07.25.17.35.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:29 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1 3/6] ASoC: codecs: msm8916-wcd-analog: move codec reset to probe Date: Wed, 26 Jul 2017 02:35:09 +0200 Message-Id: <20170726003512.18965-4-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla This patch move the codec reset code from dai ops to codec probe, so that the codec is not held in reset when headset detection block is still active. Without this patch the codec block will be in reset as long as its not actively used, which means headset events will not be functional if the codec dai is not actively used. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/msm8916-wcd-analog.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) -- 2.9.3 diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 5710fd4..6606954 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -536,6 +536,9 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) snd_soc_write(codec, wcd_reg_defaults_2_0[reg].reg, wcd_reg_defaults_2_0[reg].def); + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + RST_CTL_DIG_SW_RST_N_MASK, + RST_CTL_DIG_SW_RST_N_REMOVE_RESET); return 0; } @@ -543,6 +546,9 @@ static int pm8916_wcd_analog_remove(struct snd_soc_codec *codec) { struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + RST_CTL_DIG_SW_RST_N_MASK, 0); + return regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); } @@ -736,28 +742,6 @@ static struct regmap *pm8916_get_regmap(struct device *dev) return dev_get_regmap(dev->parent, NULL); } -static int pm8916_wcd_analog_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - snd_soc_update_bits(dai->codec, CDC_D_CDC_RST_CTL, - RST_CTL_DIG_SW_RST_N_MASK, - RST_CTL_DIG_SW_RST_N_REMOVE_RESET); - - return 0; -} - -static void pm8916_wcd_analog_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - snd_soc_update_bits(dai->codec, CDC_D_CDC_RST_CTL, - RST_CTL_DIG_SW_RST_N_MASK, 0); -} - -static struct snd_soc_dai_ops pm8916_wcd_analog_dai_ops = { - .startup = pm8916_wcd_analog_startup, - .shutdown = pm8916_wcd_analog_shutdown, -}; - static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { [0] = { .name = "pm8916_wcd_analog_pdm_rx", @@ -769,7 +753,6 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { .channels_min = 1, .channels_max = 3, }, - .ops = &pm8916_wcd_analog_dai_ops, }, [1] = { .name = "pm8916_wcd_analog_pdm_tx", @@ -781,7 +764,6 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { .channels_min = 1, .channels_max = 4, }, - .ops = &pm8916_wcd_analog_dai_ops, }, }; From patchwork Wed Jul 26 00:35:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 108723 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp198518qge; Tue, 25 Jul 2017 17:35:38 -0700 (PDT) X-Received: by 10.99.111.132 with SMTP id k126mr20743818pgc.76.1501029337654; Tue, 25 Jul 2017 17:35:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501029337; cv=none; d=google.com; s=arc-20160816; b=nxvgAPMKQldC84s9cTFPlKGxmys7qTCLe0QgDQL5tLYA/akCXbKObjFoMyXS/NeSdQ dQqCBkr9FYiUSbfJKiaB9dRCo9aVhLHEdTGuj1WyPpbx4gtOR2WW7je4Bbr/iLY1HPMo JLb5cHAiwQKCnSbYiaJQbo+mOOwH1uZSQxwlGTu07CGt6dxQrxCF4HJzebJamZ99S4qu FYTAjTpBPKUhoS78aF2Q+NDeZngriYUUOHKgvU88o+pdNWjyWxtjG+llL9xCmQQL5/Qa yEa6uowX/8stdWLWqvTDrA8yKVg5qes72vvbsedBW6o/SQh0yUAarBC/WazbS641YHkn UBpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=rt9fWE+6UYKfu5AiB9lM/68lhanDVbAogcqEd8ZgIN8=; b=waJHV/nlW3lMgJ1EDCz4UMy1CnyRl+eSsuiix+kgwkCpu6/15sVmKwMPpfxGMkuSQ7 /7RmcDz6KE1tDZ0JaJJtjU9hXmvYVBFe/SQ0XCxrPegaDqeZWn6dB9p0XiOi2hWf+kg2 hO10atGCgfE/97v1JSZnytwpKTJ+SLWt1EyfbH7F0GmMT5CmiwMJeYkeKRIp1LTWAAKz UV0z8sSnQEQPnzy4MZqQXtZaV3bUTO0ax+DTM7e+kFIVQkwaecJHgD9SoxrPEb8HdyGW b9VEM4f2F/vZ3SHzvqJYU88/2SwYnhiiGtrTN4Hd7NYo/VaS4D7Nhw0oHi7dlItZ1AcG NfwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=ReiKoQhy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si8888327pge.35.2017.07.25.17.35.37; Tue, 25 Jul 2017 17:35:37 -0700 (PDT) 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=@linaro.org header.b=ReiKoQhy; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751879AbdGZAfe (ORCPT + 26 others); Tue, 25 Jul 2017 20:35:34 -0400 Received: from mail-io0-f178.google.com ([209.85.223.178]:35505 "EHLO mail-io0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbdGZAfc (ORCPT ); Tue, 25 Jul 2017 20:35:32 -0400 Received: by mail-io0-f178.google.com with SMTP id m88so53437213iod.2 for ; Tue, 25 Jul 2017 17:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rt9fWE+6UYKfu5AiB9lM/68lhanDVbAogcqEd8ZgIN8=; b=ReiKoQhy+DUCwIjbhXHQ0xEPCiw7fnfa3M6fJhZsydv4rHM6jQa+PxkpZBg3vqnb/f IAETYdebnW3DRMmNaLion9G/hrvaOicmrxhejEJZhJEhqtOfQ65WneCYqVMFr5w8fHaK MPVKUm4NIXzpexV1+avVTDJLDqAZph4kojRwQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rt9fWE+6UYKfu5AiB9lM/68lhanDVbAogcqEd8ZgIN8=; b=Krb4FpB61iGJ3DfLqTvvg6/RIL7IJSLJmNHh7x3q6Ii1BF5x/2QX3UxdAxkvS47xtv JejESvJMq+kYraC8uRIs6QuFRkXhU/0al1NCXbD8png1L342zF54XtSK+YYKh18TQYG6 Vxp5S9TOqsLFfUMewMNbtnH0646vF6LvlHiMUbIVwm8udr6R6XJUp+yEDHAGzuPKjdqf 7JRVoCJugUKlJPBRdcusJKXHYnVQmEBdVvz6KFQk9+1pnbAzLtceYuL/YD8+APUIPKzH q+T9bpiDqSjG2+8XfTFB7fRi3SEUYzrTybq7icirJF9ae7/gmGw0gMyetPxGKsS185S+ NmCQ== X-Gm-Message-State: AIVw111nTc5YmzZz1RFjSMOLCvTykGEdivNJk1X5eNJ06QoIqzXXv1u4 KC5yn9M7CmPP6hf+ X-Received: by 10.107.23.4 with SMTP id 4mr20502834iox.110.1501029331416; Tue, 25 Jul 2017 17:35:31 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id l69sm5097373ioi.49.2017.07.25.17.35.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:31 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1 4/6] ASoC: codecs: msm8916-wcd-analog: set default micbias voltage to 1.8 Date: Wed, 26 Jul 2017 02:35:10 +0200 Message-Id: <20170726003512.18965-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla This patch sets the default internal micbias voltage to 1.8v. This default value is required for mbhc buttons to work. Also adds dt bindings to allow the board level file to specify the required default micbias value. Signed-off-by: Srinivas Kandagatla --- .../bindings/sound/qcom,msm8916-wcd-analog.txt | 1 + sound/soc/codecs/msm8916-wcd-analog.c | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) -- 2.9.3 diff --git a/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt b/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt index ccb401c..05b67a1 100644 --- a/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt +++ b/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt @@ -33,6 +33,7 @@ Required properties - vdd-micbias-supply: phandle of VDD_MICBIAS supply's regulator DT node. Optional Properties: +- qcom,micbias-lvl: Voltage (mV) for Mic Bias - qcom,micbias1-ext-cap: boolean, present if micbias1 has external capacitor connected. - qcom,micbias2-ext-cap: boolean, present if micbias2 has external capacitor diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 6606954..69df0ee 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -93,8 +93,13 @@ #define MICB_1_EN_TX3_GND_SEL_TX_GND 0 #define CDC_A_MICB_1_VAL (0xf141) +#define MICB_DEFAULT_VAL 1800 +#define MICB_MIN_VAL 1600 +#define MICB_STEP_SIZE 50 +#define MICB_VOLTAGE_REGVAL(v) ((v - MICB_MIN_VAL)/MICB_STEP_SIZE) #define MICB_1_VAL_MICB_OUT_VAL_MASK GENMASK(7, 3) #define MICB_1_VAL_MICB_OUT_VAL_V2P70V ((0x16) << 3) +#define MICB_1_VAL_MICB_OUT_VAL_V1P80V ((0x4) << 3) #define CDC_A_MICB_1_CTL (0xf142) #define MICB_1_CTL_CFILT_REF_SEL_MASK BIT(1) @@ -225,6 +230,7 @@ struct pm8916_wcd_analog_priv { struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; unsigned int micbias1_cap_mode; unsigned int micbias2_cap_mode; + unsigned int micbias_mv; }; static const char *const adc2_mux_text[] = { "ZERO", "INP2", "INP3" }; @@ -265,18 +271,16 @@ static const struct snd_kcontrol_new pm8916_wcd_analog_snd_controls[] = { static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) { + struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL | MICB_1_CTL_EXT_PRECHARG_EN_ENABLE); - snd_soc_write(codec, CDC_A_MICB_1_VAL, MICB_1_VAL_MICB_OUT_VAL_V2P70V); - /* - * Special headset needs MICBIAS as 2.7V so wait for - * 50 msec for the MICBIAS to reach 2.7 volts. - */ - msleep(50); + snd_soc_write(codec, CDC_A_MICB_1_VAL, + MICB_VOLTAGE_REGVAL(wcd->micbias_mv)); snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0); @@ -795,6 +799,10 @@ static int pm8916_wcd_analog_parse_dt(struct device *dev, else priv->micbias2_cap_mode = MICB_1_EN_NO_EXT_BYP_CAP; + if (of_property_read_u32(dev->of_node, "qcom,micbias-lvl", + &priv->micbias_mv)) + priv->micbias_mv = MICB_DEFAULT_VAL; + return 0; } From patchwork Wed Jul 26 00:35:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 108725 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp198906qge; Tue, 25 Jul 2017 17:36:13 -0700 (PDT) X-Received: by 10.99.114.25 with SMTP id n25mr20943811pgc.290.1501029373094; Tue, 25 Jul 2017 17:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501029373; cv=none; d=google.com; s=arc-20160816; b=OUvLwsY6SBsYJKL4yaHReuS9BWE0/WcaEvW7UsnN5J9R6DFn8X5o/6mRo5gu38Kuz7 Xlnu0WlbNESk3zzqp095on00H8LTxPC8UKiQhFn1TLdIkmAP3lKmFdQfRj09rgda8JGy CNNVHkm1sBv0TP0NKc1FAEmhCOBn1S3VO62Fq8H6K+eXaz9UAuGbMa5BmylJ19uP/1WR 2rfqjChHqABgV45tDc8zf6yO22X2onp80XX8eRi8OeDZbRxKPE88+pG1kiI+K+QKRs5Y fnDjjpvlw2df9YWHjcANvjZXY0hpXZLcyyREbJM0A3J/axeaZ0PQuWG1g5YKDgpem0oi ZLCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=aq6urxvaDJ9th4viAipn2UP6zU2R7HWMBv+amaM6bEw=; b=c3WGvdINvTMZMH9uCFc9ldzbfruiQT0jaant60Ik5LeRu6sX7RkNNMkoYPTb4LIVfW RkEhcYcU+VGBVOtO4XMw04rGlNy9dHvHHusQYMvr1SAZOb6giGE0ary4BRZ1fKjK4MC/ EuimlfHrLwFlL1p3QK7o6+mbfzKR0fv4ouPW1PPEmaWdb3liRVMgfxsSoO1ywVZtKVU5 AE2+la0xNZ40N03BV7QsEQ8dN3wT+Y+TstFW9wClH4ExjdesxSqzWt3nczlBRDGZfXxq dnsxCx6wPbGwkQQYoVajxpGPD3Jk/2fjEmlBUdFGQlrjg+4HsV+2NzEdpBJOP0vlPakz hkJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=HT2dKo3Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si8770395pgj.524.2017.07.25.17.36.12; Tue, 25 Jul 2017 17:36:13 -0700 (PDT) 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=@linaro.org header.b=HT2dKo3Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751899AbdGZAfk (ORCPT + 26 others); Tue, 25 Jul 2017 20:35:40 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:33449 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751869AbdGZAfe (ORCPT ); Tue, 25 Jul 2017 20:35:34 -0400 Received: by mail-io0-f170.google.com with SMTP id j32so41507532iod.0 for ; Tue, 25 Jul 2017 17:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aq6urxvaDJ9th4viAipn2UP6zU2R7HWMBv+amaM6bEw=; b=HT2dKo3QxeEpt4BBbGTiLEHzcC6SItrpnLMZTRsh5CusVnDDHLjwNYJtJWOAcsbj+G hAbjvHliQsAzlFRJyYmc5rc6M5p9kPlBE6lREJdzCgmfcg2hI+1o4DdW7Y1gjvpGi/A3 6PzQo9SGCvKOSrS4YUhWbolH1klkFtWqHI4ro= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aq6urxvaDJ9th4viAipn2UP6zU2R7HWMBv+amaM6bEw=; b=E15bh9Jed+m+bN85z2oMrQJUm+eybf7x9wT33jmf86z4KuOHrPO6XNFKTuuSuD6MP9 K5LSOrrn0kp2jpKV+jstJSVGN6VcwCSuKwxg6FxCU9r6Zj4imZgTUMzwjWSUi4E1SnMl QH4q/PX2paL/15vwY7tFD0iompTSGX6rJ5fsaIT5Lz0T74UdRvCu11V47IrPKJRV2Uqa ltldpmjxi0QByYAr5CSMkIM14Yx1lkZebY4uH14m3pFK973W5eosjvhI0ZyQ9jJVhgvb hLR3ocEo6Hh0pE8IAcwWrxvOV/9TTAN7PjvADBbCrZuH/6l5F7hKZPDDyJJMv1o5KACe Znag== X-Gm-Message-State: AIVw112GNFsDWWh4YSRrhlIKu7rOQZUaCurSeomlv+5btOkPqyaZPXRT 2z84xvf/mNdvo65E X-Received: by 10.107.168.37 with SMTP id r37mr18509989ioe.274.1501029333538; Tue, 25 Jul 2017 17:35:33 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id l69sm5097373ioi.49.2017.07.25.17.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:33 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1 5/6] ASoC: codecs: msm8916-wcd-analog: add MBHC support Date: Wed, 26 Jul 2017 02:35:11 +0200 Message-Id: <20170726003512.18965-6-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla MBHC (MultiButton Headset Control) support is available in pm8921 in two blocks, one to detect mechanical headset insertion and removal and other block to support headset type detection and 5 button detection and othe features like impedance calculation. This patch adds support to: 1> Support to NC and NO type of headset Jacks. 2> Mechanical insertion and detection of headset jack. 3> Detect a 3 pole Headphone and a 4 pole Headset. 4> Detect 5 buttons. Tested it on DB410c with Audio Mezz board with 4 pole and 3 pole headset/headphones. Signed-off-by: Srinivas Kandagatla --- .../bindings/sound/qcom,msm8916-wcd-analog.txt | 8 + sound/soc/codecs/msm8916-wcd-analog.c | 323 +++++++++++++++++++++ sound/soc/codecs/msm8916-wcd.h | 12 + 3 files changed, 343 insertions(+) create mode 100644 sound/soc/codecs/msm8916-wcd.h -- 2.9.3 diff --git a/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt b/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt index 05b67a1..c46401c 100644 --- a/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt +++ b/Documentation/devicetree/bindings/sound/qcom,msm8916-wcd-analog.txt @@ -34,6 +34,14 @@ Required properties Optional Properties: - qcom,micbias-lvl: Voltage (mV) for Mic Bias +- qcom,hphl-jack-type-normally-open: boolean, present if hphl pin on jack is a + NO (Normally Open). If not specified, then + its assumed that hphl pin on jack is NC + (Normally Closed). +- qcom,gnd-jack-type-normally-open: boolean, present if gnd pin on jack is + NO (Normally Open). If not specified, then + its assumed that gnd pin on jack is NC + (Normally Closed). - qcom,micbias1-ext-cap: boolean, present if micbias1 has external capacitor connected. - qcom,micbias2-ext-cap: boolean, present if micbias2 has external capacitor diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 69df0ee..4db2349 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -12,9 +12,21 @@ #include #include #include +#include +#include "msm8916-wcd.h" #define CDC_D_REVISION1 (0xf000) #define CDC_D_PERPH_SUBTYPE (0xf005) +#define CDC_D_INT_EN_SET (0x015) +#define CDC_D_INT_EN_CLR (0x016) +#define MBHC_SWITCH_INT BIT(7) +#define MBHC_MIC_ELECTRICAL_INS_REM_DET BIT(6) +#define MBHC_BUTTON_PRESS_DET BIT(5) +#define MBHC_BUTTON_RELEASE_DET BIT(4) +#define CDC_DEF_INT_MASK (MBHC_SWITCH_INT | \ + MBHC_MIC_ELECTRICAL_INS_REM_DET | \ + MBHC_BUTTON_PRESS_DET | \ + MBHC_BUTTON_RELEASE_DET) #define CDC_D_CDC_RST_CTL (0xf046) #define RST_CTL_DIG_SW_RST_N_MASK BIT(7) #define RST_CTL_DIG_SW_RST_N_RESET 0 @@ -37,6 +49,8 @@ #define DIG_CLK_CTL_RXD1_CLK_EN BIT(0) #define DIG_CLK_CTL_RXD2_CLK_EN BIT(1) #define DIG_CLK_CTL_RXD3_CLK_EN BIT(2) +#define DIG_CLK_CTL_D_MBHC_CLK_EN_MASK BIT(3) +#define DIG_CLK_CTL_D_MBHC_CLK_EN BIT(3) #define DIG_CLK_CTL_TXD_CLK_EN BIT(4) #define DIG_CLK_CTL_NCP_CLK_EN_MASK BIT(6) #define DIG_CLK_CTL_NCP_CLK_EN BIT(6) @@ -133,8 +147,51 @@ #define MICB_1_INT_TX3_INT_PULLUP_EN_TX1N_TO_GND 0 #define CDC_A_MICB_2_EN (0xf144) +#define CDC_A_MICB_2_EN_ENABLE BIT(7) +#define CDC_A_MICB_2_PULL_DOWN_EN_MASK BIT(5) +#define CDC_A_MICB_2_PULL_DOWN_EN BIT(5) #define CDC_A_TX_1_2_ATEST_CTL_2 (0xf145) #define CDC_A_MASTER_BIAS_CTL (0xf146) +#define CDC_A_MBHC_DET_CTL_1 (0xf147) +#define CDC_A_MBHC_DET_CTL_L_DET_EN BIT(7) +#define CDC_A_MBHC_DET_CTL_GND_DET_EN BIT(6) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION BIT(5) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_REMOVAL (0) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK BIT(5) +#define CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT (5) +#define CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO BIT(4) +#define CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_MANUAL BIT(3) +#define CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_MASK GENMASK(4, 3) +#define CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN BIT(2) +#define CDC_A_MBHC_DET_CTL_2 (0xf150) +#define CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 (BIT(7) | BIT(6)) +#define CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD BIT(5) +#define CDC_A_PLUG_TYPE_MASK GENMASK(4, 3) +#define CDC_A_HPHL_PLUG_TYPE_NO BIT(4) +#define CDC_A_GND_PLUG_TYPE_NO BIT(3) +#define CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN_MASK BIT(0) +#define CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN BIT(0) +#define CDC_A_MBHC_FSM_CTL (0xf151) +#define CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN BIT(7) +#define CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK BIT(7) +#define CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA (0x3 << 4) +#define CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK GENMASK(6, 4) +#define CDC_A_MBHC_DBNC_TIMER (0xf152) +#define CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS BIT(3) +#define CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS (0x9 << 4) +#define CDC_A_MBHC_BTN0_ZDET_CTL_0 (0xf153) +#define CDC_A_MBHC_BTN1_ZDET_CTL_1 (0xf154) +#define CDC_A_MBHC_BTN2_ZDET_CTL_2 (0xf155) +#define CDC_A_MBHC_BTN3_CTL (0xf156) +#define CDC_A_MBHC_BTN4_CTL (0xf157) +#define CDC_A_MBHC_BTN_VREF_FINE_SHIFT (2) +#define CDC_A_MBHC_BTN_VREF_FINE_MASK GENMASK(4, 2) +#define CDC_A_MBHC_BTN_VREF_COARSE_MASK GENMASK(7, 5) +#define CDC_A_MBHC_BTN_VREF_COARSE_SHIFT (5) +#define CDC_A_MBHC_BTN_VREF_MASK (CDC_A_MBHC_BTN_VREF_COARSE_MASK | \ + CDC_A_MBHC_BTN_VREF_FINE_MASK) +#define CDC_A_MBHC_RESULT_1 (0xf158) +#define CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK GENMASK(4, 0) #define CDC_A_TX_1_EN (0xf160) #define CDC_A_TX_2_EN (0xf161) #define CDC_A_TX_1_2_TEST_CTL_1 (0xf162) @@ -226,8 +283,18 @@ static const char * const supply_names[] = { struct pm8916_wcd_analog_priv { u16 pmic_rev; u16 codec_version; + int mbhc_sw_irq; + int mbhc_btn_press_irq; + int mbhc_btn_release_irq; + /* special event to detect accessory type */ + bool mbhc_btn0_pressed; struct clk *mclk; + struct snd_soc_codec *codec; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; + struct snd_soc_jack *jack; + bool hphl_jack_type_normally_open; + bool gnd_jack_type_normally_open; + struct msm8916_wcd_mbhc_data mbhc_data; unsigned int micbias1_cap_mode; unsigned int micbias2_cap_mode; unsigned int micbias_mv; @@ -365,6 +432,92 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct wcd->micbias1_cap_mode); } +static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) +{ + struct snd_soc_codec *codec = wcd->codec; + u32 plug_type = 0; + + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, + CDC_A_MBHC_DET_CTL_L_DET_EN | + CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION | + CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO | + CDC_A_MBHC_DET_CTL_MBHC_BIAS_EN); + + if (wcd->hphl_jack_type_normally_open) + plug_type = CDC_A_HPHL_PLUG_TYPE_NO; + + if (wcd->gnd_jack_type_normally_open) + plug_type |= CDC_A_GND_PLUG_TYPE_NO; + + snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, + CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 | + CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD | + plug_type | + CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN); + + + snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, + CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS | + CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS); + + /* enable MBHC clock */ + snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL, + DIG_CLK_CTL_D_MBHC_CLK_EN_MASK, + DIG_CLK_CTL_D_MBHC_CLK_EN); + + snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, CDC_DEF_INT_MASK, 0); + snd_soc_update_bits(codec, CDC_D_INT_EN_SET, CDC_DEF_INT_MASK, + CDC_DEF_INT_MASK); + wcd->mbhc_btn0_pressed = false; +} + +static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, + bool micbias2_enabled) +{ + struct snd_soc_codec *codec = priv->codec; + u32 coarse, fine, reg_val, reg_addr; + int *vrefs, i; + + if (!micbias2_enabled) { /* use internal 100uA Current source */ + /* Enable internal 2.2k Internal Rbias Resistor */ + snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, + MICB_1_INT_TX2_INT_RBIAS_EN_MASK, + MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); + /* Remove pull down on MIC BIAS2 */ + snd_soc_update_bits(codec, CDC_A_MICB_2_EN, + CDC_A_MICB_2_PULL_DOWN_EN_MASK, + 0); + /* enable 100uA internal current source */ + snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK, + CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA); + } + snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK, + CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN); + + if (micbias2_enabled) + vrefs = &priv->mbhc_data.vref_btn_micb[0]; + else + vrefs = &priv->mbhc_data.vref_btn_cs[0]; + + /* program vref ranges for all the buttons */ + reg_addr = CDC_A_MBHC_BTN0_ZDET_CTL_0; + for (i = 0; i < MBHC_MAX_BUTTONS; i++) { + /* split mv in to coarse parts of 100mv & fine parts of 12mv */ + coarse = (vrefs[i] / 100); + fine = ((vrefs[i] % 100) / 12); + reg_val = (coarse << CDC_A_MBHC_BTN_VREF_COARSE_SHIFT) | + (fine << CDC_A_MBHC_BTN_VREF_FINE_SHIFT); + snd_soc_update_bits(codec, reg_addr, + CDC_A_MBHC_BTN_VREF_MASK, + reg_val); + reg_addr++; + } + + return 0; +} + static int pm8916_wcd_analog_enable_micbias_int2(struct snd_soc_dapm_widget *w, struct snd_kcontrol @@ -373,6 +526,15 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + switch (event) { + case SND_SOC_DAPM_POST_PMU: + pm8916_mbhc_configure_bias(wcd, true); + break; + case SND_SOC_DAPM_POST_PMD: + pm8916_mbhc_configure_bias(wcd, false); + break; + } + return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, wcd->micbias2_cap_mode); } @@ -540,9 +702,14 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) snd_soc_write(codec, wcd_reg_defaults_2_0[reg].reg, wcd_reg_defaults_2_0[reg].def); + priv->codec = codec; + snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, RST_CTL_DIG_SW_RST_N_MASK, RST_CTL_DIG_SW_RST_N_REMOVE_RESET); + + pm8916_wcd_setup_mbhc(priv); + return 0; } @@ -741,11 +908,110 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("A_MCLK2", CDC_D_CDC_TOP_CLK_CTL, 3, 0, NULL, 0), }; +static int pm8916_wcd_analog_set_jack(struct snd_soc_codec *codec, + struct snd_soc_jack *jack, + void *data) +{ + struct msm8916_wcd_mbhc_data *d = data; + struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + + wcd->jack = jack; + wcd->mbhc_data = *d; + + return 0; +} + static struct regmap *pm8916_get_regmap(struct device *dev) { return dev_get_regmap(dev->parent, NULL); } +static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg) +{ + struct pm8916_wcd_analog_priv *priv = arg; + struct snd_soc_codec *codec = priv->codec; + u32 btn_result; + + btn_result = snd_soc_read(codec, CDC_A_MBHC_RESULT_1) & + CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK; + + if (!btn_result) + priv->mbhc_btn0_pressed = false; + + snd_jack_report(priv->jack->jack, 0); + + return IRQ_HANDLED; +} + +static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) +{ + struct pm8916_wcd_analog_priv *priv = arg; + struct snd_soc_codec *codec = priv->codec; + u32 btn_result; + + btn_result = snd_soc_read(codec, CDC_A_MBHC_RESULT_1) & + CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK; + + switch (btn_result) { + case 0xf: + snd_jack_report(priv->jack->jack, SND_JACK_BTN_4); + break; + case 0x7: + snd_jack_report(priv->jack->jack, SND_JACK_BTN_3); + break; + case 0x3: + snd_jack_report(priv->jack->jack, SND_JACK_BTN_2); + break; + case 0x1: + snd_jack_report(priv->jack->jack, SND_JACK_BTN_1); + break; + case 0: + priv->mbhc_btn0_pressed = true; + snd_jack_report(priv->jack->jack, SND_JACK_BTN_0); + break; + } + + return IRQ_HANDLED; +} + +static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg) +{ + struct pm8916_wcd_analog_priv *priv = arg; + struct snd_soc_codec *codec = priv->codec; + bool micbias_enabled = false; + bool ins = false; + + if (snd_soc_read(codec, CDC_A_MBHC_DET_CTL_1) & + CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) + ins = true; + + /* Set the detection type appropriately */ + snd_soc_update_bits(codec, CDC_A_MBHC_DET_CTL_1, + CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK, + (!ins << CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT)); + if (ins) { /* hs insertion */ + if (snd_soc_read(codec, CDC_A_MICB_2_EN) & + CDC_A_MICB_2_EN_ENABLE) + micbias_enabled = true; + + pm8916_mbhc_configure_bias(priv, micbias_enabled); + + /* + * if only a btn press event is receive just before + * insert event then its a 3 pole headphone + */ + if (priv->mbhc_btn0_pressed) + snd_jack_report(priv->jack->jack, SND_JACK_HEADPHONE); + else + snd_jack_report(priv->jack->jack, SND_JACK_HEADSET); + + } else { /* removal */ + snd_jack_report(priv->jack->jack, 0); + } + + return IRQ_HANDLED; +} + static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { [0] = { .name = "pm8916_wcd_analog_pdm_rx", @@ -774,6 +1040,7 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { static struct snd_soc_codec_driver pm8916_wcd_analog = { .probe = pm8916_wcd_analog_probe, .remove = pm8916_wcd_analog_remove, + .set_jack = pm8916_wcd_analog_set_jack, .get_regmap = pm8916_get_regmap, .component_driver = { .controls = pm8916_wcd_analog_snd_controls, @@ -803,6 +1070,18 @@ static int pm8916_wcd_analog_parse_dt(struct device *dev, &priv->micbias_mv)) priv->micbias_mv = MICB_DEFAULT_VAL; + if (of_property_read_bool(dev->of_node, + "qcom,hphl-jack-type-normally-open")) + priv->hphl_jack_type_normally_open = true; + else + priv->hphl_jack_type_normally_open = false; + + if (of_property_read_bool(dev->of_node, + "qcom,gnd-jack-type-normally-open")) + priv->gnd_jack_type_normally_open = true; + else + priv->gnd_jack_type_normally_open = false; + return 0; } @@ -842,6 +1121,50 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev) return ret; } + priv->mbhc_sw_irq = platform_get_irq_byname(pdev, "mbhc_switch_int"); + if (priv->mbhc_sw_irq < 0) { + dev_err(dev, "failed to get mbhc switch irq\n"); + return priv->mbhc_sw_irq; + } + + priv->mbhc_btn_press_irq = platform_get_irq_byname(pdev, + "mbhc_but_press_det"); + if (priv->mbhc_btn_press_irq < 0) { + dev_err(dev, "failed to get button press irq\n"); + return priv->mbhc_btn_press_irq; + } + + priv->mbhc_btn_release_irq = platform_get_irq_byname(pdev, + "mbhc_but_rel_det"); + if (priv->mbhc_btn_release_irq < 0) { + dev_err(dev, "failed to get button release irq\n"); + return priv->mbhc_btn_release_irq; + } + + ret = devm_request_irq(dev, priv->mbhc_btn_release_irq, + mbhc_btn_release_irq_handler, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "mbhc btn release irq", priv); + if (ret) + dev_err(dev, "cannot request mbhc button release irq\n"); + + ret = devm_request_irq(dev, priv->mbhc_btn_press_irq, + mbhc_btn_press_irq_handler, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "mbhc btn press irq", priv); + if (ret) + dev_err(dev, "cannot request mbhc button press irq\n"); + + ret = devm_request_irq(dev, priv->mbhc_sw_irq, + pm8916_mbhc_switch_irq_handler, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "mbhc switch irq", priv); + if (ret) + dev_err(dev, "cannot request mbhc switch irq\n"); + dev_set_drvdata(dev, priv); return snd_soc_register_codec(dev, &pm8916_wcd_analog, diff --git a/sound/soc/codecs/msm8916-wcd.h b/sound/soc/codecs/msm8916-wcd.h new file mode 100644 index 0000000..23f1d7a --- /dev/null +++ b/sound/soc/codecs/msm8916-wcd.h @@ -0,0 +1,12 @@ +#ifndef _MSM8916_WCD_H_ +#define _MSM8916_WCD_H_ + +#define MBHC_MAX_BUTTONS (5) +struct msm8916_wcd_mbhc_data { + /* Voltage threshold when internal current source of 100uA is used */ + int vref_btn_cs[MBHC_MAX_BUTTONS]; + /* Voltage threshold when microphone bias is ON */ + int vref_btn_micb[MBHC_MAX_BUTTONS]; +}; + +#endif /* _MSM8916_WCD_H_ */ From patchwork Wed Jul 26 00:35:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 108724 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp198578qge; Tue, 25 Jul 2017 17:35:44 -0700 (PDT) X-Received: by 10.99.36.193 with SMTP id k184mr16058129pgk.406.1501029343877; Tue, 25 Jul 2017 17:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1501029343; cv=none; d=google.com; s=arc-20160816; b=F5jX64kg2m8Q86SKfLhXXV2VCKGjCSWcWxJqbN+YkakErYsXKsXfKcge68hvU9RIOf xwxbsE5medbazAv9uIgbV0u5iPiJZUIpBw/wWPtQz1yZsI65iOkbVHjDJDc5OAd0T2Bz xLxgBC6OG38cYaCxZ+8J0tpCbaY05KOQi3KMyphDulFc50xX67ROvjaaGLQNA/FOfkbp z7jBfZhfrlJvkhVUpOkMK6CgURGm4rh+lF4e3UI4Kp8qd8vWSyPVgyXqIrxmYrVTPGNQ f0tWUiXpyJr/NGsNFwQREPM2HPLfuHACQLkjR+Jtj0orNRAzNKAZq8SB4EEIFY/LIsWv npfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=zh4eHiChyDJuxqsYA8yde9ls/Smrn98yB6Ap/L/1oyw=; b=Cani3G93InSHH+Pw5xlP00XftnkG4moQvw8qAY2hhYZ5KwPh+1+ES9ab0F4t+78qlY F+0g80cav+42sVj1j+7JY1lI7u6ml8L8K5tCAbPFi1PAi6vLXqrbUkmm35wccmbm7UkQ hKqkw0uqvKC/lBPdxgg0toG7WsGHUvVBoGBLahHPzY+HisH0wj4drKuVgjZnVYDj5Oze ECvYWV+H6R6IOSalTpNFLCqr3R7v8mqjZYLiDrXfPfz5MfHNKdGu9MeTginFzc8kYJWk NajuMnrF57PqipNFsoar49oF9YdxqnvA2y5yzXPxKlpwISQQqFm/GOpg0Jxxp9mv0cS0 jHhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=JJDhsqUv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n9si8888327pge.35.2017.07.25.17.35.43; Tue, 25 Jul 2017 17:35:43 -0700 (PDT) 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=@linaro.org header.b=JJDhsqUv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751925AbdGZAfl (ORCPT + 26 others); Tue, 25 Jul 2017 20:35:41 -0400 Received: from mail-it0-f45.google.com ([209.85.214.45]:37806 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751595AbdGZAfg (ORCPT ); Tue, 25 Jul 2017 20:35:36 -0400 Received: by mail-it0-f45.google.com with SMTP id v127so60229564itd.0 for ; Tue, 25 Jul 2017 17:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zh4eHiChyDJuxqsYA8yde9ls/Smrn98yB6Ap/L/1oyw=; b=JJDhsqUvN7ieQwoKGtddONu/kdTT9tpNY8zRD7E1POVGuRXZ70htpkxbPPIh7MJZ7R z0NRPxqhqz3zs0w6oHLh1/TV9A/VaNKZBwHD9RMyO2KKglWgE7g6xsrM8WOrdRsLkEge N86ZxD4Qj26gZQ8yEO4tu3wMUpGYZJtLWRhAc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zh4eHiChyDJuxqsYA8yde9ls/Smrn98yB6Ap/L/1oyw=; b=Ze/mSTEQDWxcuiW6AquH5kg0dd/pvLhn94+OYqIaS6JDtEfeBo4eWjQ4djJMRWHfWa XjdcHw3WsxzOfTMByMvT7Pxrjn7wvuUbwOfp812wjq0/0vpbpcoFTdAi2KzTATfKzPP0 P9q+w0hkJWFv8v02pkpK2uOiuGnITuS1iyuc4CcZh7h0bGuHQHpOZyrPZSe7Eu2wYgDF erY+tGeO4uxRQ1duNsZm0E2iNo+3EC2O2fk7EKareCk1Mb75sZzC/CD0kpxaI8HuLJ03 5KuI56FbYPnhojSqXbP0VDPdWo7hUcH6B+fLaFlF7HgxHI+ZaPVO9Siw7cqZBJ/hstK5 kxhg== X-Gm-Message-State: AIVw110l3MJ9grs0CyttwK2h/kkD88vY4mmJEPwPw3eQ6xNBJ2+e1zvi ZlUCxmBjHEWvpkkf X-Received: by 10.36.55.145 with SMTP id r139mr13195807itr.117.1501029335533; Tue, 25 Jul 2017 17:35:35 -0700 (PDT) Received: from localhost.localdomain (static.8.26.4.46.clients.your-server.de. [46.4.26.8]) by smtp.gmail.com with ESMTPSA id l69sm5097373ioi.49.2017.07.25.17.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Jul 2017 17:35:35 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Mark Brown , Banajit Goswami , alsa-devel@alsa-project.org Cc: Jaroslav Kysela , Takashi Iwai , Patrick Lai , linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1 6/6] ASoC: qcom: apq8016-sbc: Add support to Headset JACK Date: Wed, 26 Jul 2017 02:35:12 +0200 Message-Id: <20170726003512.18965-7-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> References: <20170726003512.18965-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Kandagatla This patch adds support to Headset JACK, also provides board specific vref ranges for mbhc buttons to be detected. This headset supports both 3 pole and 5 pole headset type and 5 buttons. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/apq8016_sbc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) -- 2.9.3 diff --git a/sound/soc/qcom/apq8016_sbc.c b/sound/soc/qcom/apq8016_sbc.c index f07aa1e..ccb3620 100644 --- a/sound/soc/qcom/apq8016_sbc.c +++ b/sound/soc/qcom/apq8016_sbc.c @@ -21,12 +21,18 @@ #include #include #include +#include #include +#include #include +#include "../codecs/msm8916-wcd.h" struct apq8016_sbc_data { void __iomem *mic_iomux; void __iomem *spkr_iomux; + struct snd_soc_jack jack; + struct msm8916_wcd_mbhc_data mbhc_data; + bool jack_setup; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ }; @@ -43,6 +49,7 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai_link *dai_link = rtd->dai_link; struct snd_soc_card *card = rtd->card; struct apq8016_sbc_data *pdata = snd_soc_card_get_drvdata(card); + struct msm8916_wcd_mbhc_data *data; int i, rval; switch (cpu_dai->id) { @@ -70,6 +77,45 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) } + 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 | + SND_JACK_BTN_4, + &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_MEDIA); + 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); + + /* board specific vref thresholds in mv */ + data = &pdata->mbhc_data; + data->vref_btn_cs[0] = 75; + data->vref_btn_micb[0] = 75; + data->vref_btn_cs[1] = 150; + data->vref_btn_micb[1] = 150; + data->vref_btn_cs[2] = 237; + data->vref_btn_micb[2] = 237; + data->vref_btn_cs[3] = 450; + data->vref_btn_micb[3] = 450; + data->vref_btn_cs[4] = 500; + data->vref_btn_micb[4] = 500; + + pdata->jack_setup = true; + } + for (i = 0 ; i < dai_link->num_codecs; i++) { struct snd_soc_dai *dai = rtd->codec_dais[i]; @@ -81,6 +127,12 @@ static int apq8016_sbc_dai_init(struct snd_soc_pcm_runtime *rtd) dev_warn(card->dev, "Failed to set mclk: %d\n", rval); return rval; } + rval = snd_soc_codec_set_jack(codec, &pdata->jack, + &pdata->mbhc_data); + if (rval != 0 && rval != -ENOTSUPP) { + dev_warn(card->dev, "Failed to set jack: %d\n", rval); + return rval; + } } return 0;