From patchwork Thu Jun 11 11:14:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zidan Wang X-Patchwork-Id: 6587641 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B0AF3C0020 for ; Thu, 11 Jun 2015 11:14:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C7A0B2051C for ; Thu, 11 Jun 2015 11:14:49 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 82119204AD for ; Thu, 11 Jun 2015 11:14:48 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 817EF266520; Thu, 11 Jun 2015 13:14:47 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 7D5A626648D; Thu, 11 Jun 2015 13:14:10 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8165A266439; Thu, 11 Jun 2015 13:14:07 +0200 (CEST) Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0138.outbound.protection.outlook.com [157.56.111.138]) by alsa0.perex.cz (Postfix) with ESMTP id 2EBF2261AB7 for ; Thu, 11 Jun 2015 13:13:59 +0200 (CEST) Received: from BY2PR03CA005.namprd03.prod.outlook.com (10.255.93.22) by BY1PR0301MB1256.namprd03.prod.outlook.com (10.161.203.28) with Microsoft SMTP Server (TLS) id 15.1.184.17; Thu, 11 Jun 2015 11:13:57 +0000 Received: from BL2FFO11FD037.protection.gbl (10.255.93.4) by BY2PR03CA005.outlook.office365.com (10.255.93.22) with Microsoft SMTP Server (TLS) id 15.1.190.14 via Frontend Transport; Thu, 11 Jun 2015 11:13:51 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD037.mail.protection.outlook.com (10.173.161.133) with Microsoft SMTP Server (TLS) id 15.1.190.9 via Frontend Transport; Thu, 11 Jun 2015 11:13:50 +0000 Received: from b50113.ap.freescale.net (b50113.ap.freescale.net [10.192.241.89]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t5BBDjKh015356; Thu, 11 Jun 2015 04:13:46 -0700 From: Zidan Wang To: Date: Thu, 11 Jun 2015 19:14:33 +0800 Message-ID: <880838f666b591f5ffb0de1e39df5e3734846246.1434020423.git.zidan.wang@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD037; 1:5gFu7ZirmqbJZ5vyv9oFwaDi01z5qjZ9OFNlK0e18ObkzuLEYHCAcGyQ30IPkRRwYqmi+wpg11o87p3CwbiYmga68N1VTWqF6X8UETL7NfTKu8rYkUeGFDPyXegfmx4ZI/Pv26UqADsY8PfNx+CUaarPHcQIL6nbGezQOM+d2hyGKPZ2ICWAqPiCYdYaViv4dwMMnqp0r31MCJz2gK3fTLVdEi9+rYR01nRohGdnnua5H364YqUspwO4cVUGxwyDxceIgPQl6fpm7W826BjjbsZyoXfUUT6eewU958lF8Qbwj/iwe8jgVRavqy1q9Fj4c4Vv1m07yFrdhwaq9v0h4+biwn6+EL8Mndpyitz5zgs= X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(339900001)(189002)(199003)(229853001)(2950100001)(46102003)(48376002)(92566002)(104016003)(33646002)(86362001)(106466001)(189998001)(77156002)(62966003)(118296001)(6806004)(77096005)(50466002)(2351001)(19580395003)(110136002)(36756003)(107886002)(50226001)(5001960100002)(87936001)(50986999)(105606002)(85426001)(47776003)(76176999)(19580405001)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BY1PR0301MB1256; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB1256; 2:Wdc+xBFnLf5m9JmW6b7r9IboBLp8se8aHqGJ924zo9XP0gUqzYDgt2jxqXAhj6JN; 2:lMU0sqar32V+Y6MFGtA7EGlP/6IVHRClTBHwbQTw+pughMy1lxi4KhWybUGTvmAgGcl9SBhPjRULpEADgmRQCTe2O6zm1KLI4voFhYLSzx0sHE/E3v00sLXcZKy3F1f0dmzTCr9P7JBhqxLMAnJ76+qFZ5qQ+RvH9hggCZooVqhCcNlJ4km3tIzHL+KJZkdh+QAqfmhcdfm4i8hIP9sU4n17ZwnZtOPshLixlb0ozZI=; 6:/55tD9KRjOavdN3jZujNF6N3xEid2L88v1wFIG+oyCUnXM8H7lvK1QTS9INQWPE0xQbCJcdtdMokdDd2gKUDc6nT+1XpFKWSFz+3TQkwmsPk0uYAESdAWTahPB8pLbCwdR/4DQStoxcbkeZRami4SvAk8Ft1fPtLsi/NBW16gD0Ba/hkM4KTjb6R913P+83a6oUFRSW1doID6T7GE23S3uMLAM3oP5SWDjKg9WP1l8i0gX94vf7PMO1eFFGcjDjVmGIkdsbt/9m7jAJHp+Tg5rn7a93kmxjAQGkQyKidYG924VAxYWnDumv1O3dPpAU/t+rbqTT0/3vsbMzAlFotSg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY1PR0301MB1256; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(520003)(3002001); SRVR:BY1PR0301MB1256; BCL:0; PCL:0; RULEID:; SRVR:BY1PR0301MB1256; X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB1256; 3:yOE3wyR+ibpmWKOD6iVzfRVSEBGpUeaQC9bUNlyIegXiYxFwuD7q/FsNupyGIupAJqhYoK+pxxLQN7fwqL6BhtXl+0RbLQHsa3ImkXRnzmAVUjoTWiVrFPW0XyvN0Jnb95naeGyAHBrR9VJHYBzI12RfS4q2hOcsSSjOD9uxGJK4eUdWvQyy3mHbHd18oxDGWEPF7r4BT2K8vHapg48X1YekdHYE5qy1xq3JGuSqs4i7akuOBP9+IkiYPwETR0vXQ1/YRI/AFjsdPLeQEDGnJ3isL0k7RTq/iW2eYU3zXGD1Sv0dXIOct5JRfOfWO55O X-Forefront-PRVS: 0604AFA86B X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB1256; 9:k4rxdLn5f6XeI1bE/SJzFMK/sWYNUtUGM2SCqez6wJIxSoXdBsCmKrSa0nNc1yCLZtJY8laXP9fD3uCtFAKQ9FYlcDwcs/x0hrARx4SB/Z8F/vb896/XItc2TG3z4fR5wUvdwHE1rMEjl/dUM7E364xuFAWw+44AMtQalpKFKuW/oYIxrL2nhONvZECLQpVPNpCFroTMmpxNifpF1ESY4oNctrslDWl3q5CT9Wb51iBrTsJDAurrn9CRcmN6+xpRVb+ndfGg02/G7bTVEaMwIOWQOJumOKmLLvaTI5iub5OlxUQY/dWGHgyc1pFW+5wDBbhYRJJgcCUhb0+NsaZUAl+n4q82pTgHlY6uHVEtnnhfX9VgN/ioHXAq3brPJghpUO3hLeZ3to52eq52UhICo6VTSh/3rymw2ud+fAeGUrY2NtSZ6/on2f+3t7TerEp+t0cFW2FrSg2/GHnkmZMNu86Kae/yz9JPaCdSKENMPd2rBr3ZCRSKrJ0u/IsNjk6A7bHJtu4g0Za2JdtVVi1C8Bitv1iiFFKJv+KDLSejztxI+PpO4gPUd+Hn1DKX9UDf271Z0nrnlK1L/6djS7iCrVLULfs0Do3q1WhmewkezV8k5P59p8YK8CXpddQBomSEZlPtGtEzrBJOsBACVFPGM68zoPCwzWSn0VBBonnTKnzoKB5748kkKe/4UqmlZYy3lCEjYRoS53OV8FaDYmDdGh63IzFfmorOM5t5a+b4YwakmoWtsvhrjAJnF0u0YWsm3fSEOSzqkqrS0vRgOct+Li3qx+x7MVDPYl+ks5EVTR376FXY/l0Edg/NlgdWB/EqFstKw3m4/yb8qDPLnFuklO2yrm0Yi7ZfZJmzY6mlYXyp/YZ10TJl3AYq0WhAx+NBsvO8hDq/djYqQSgy8iB2PKRFJ7xxG8u+WZJNyOE7CPA= X-Microsoft-Exchange-Diagnostics: 1; BY1PR0301MB1256; 3:Pve7zJHyVC8F31gVun0Bzsgamf3fAD5YYYZGr4DWE8doHKFC/5ce4TpZII33xpIvS2ESIPo7lqrt2Nx/kLVka6rJzz4cAqO2GTR8hX3iR+BeDOU5JMavgGd4xwkMQMe6ia08GB+/EQ7gfDTwZSDsJw==; 10:y8sjlcdHG9s4r1n18dcGHgTG+J1oInTbw6AhTzHRU3ppIdZiMWov3Brw46xArcrKu8sOWN3jRb3U0QVavqv0ttxN0/VyccYGozqESQCcuQI=; 6:3S/wh71GQOYTW3Yn0MijbH9BA2XqBAGCKqsY5JvSVhQ6iS79CyWP2qsc50TdJooE X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2015 11:13:50.7947 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB1256 Cc: alsa-devel@alsa-project.org, lars@metafoo.de, Zidan Wang , tiwai@suse.de, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com, lgirdwood@gmail.com, ckeepax@opensource.wolfsonmicro.com Subject: [alsa-devel] [PATCH 1/4] ASoC: wm8960: codec mclk should be enabled early to avoid jack detect error X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP It will playback from speaker in the first 2 seconds, then switch to headphone. Steps to reproduce this issue: 1. plug out headphone and playback a wav. 2. stop playback and wait for at least 5 seconds, then plug in headphone and playback a wav. Signed-off-by: Zidan Wang --- sound/soc/codecs/wm8960.c | 73 +++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 761418f..729205f 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -491,6 +491,34 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec) return 0; } +int wm8960_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *codec_dai) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + int ret; + + if (!IS_ERR(wm8960->mclk)) { + ret = clk_prepare_enable(wm8960->mclk); + if (ret) { + dev_err(codec->dev, + "Failed to enable MCLK: %d\n", ret); + return ret; + } + } + return 0; +} + +void wm8960_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *codec_dai) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + + if (!IS_ERR(wm8960->mclk)) + clk_disable_unprepare(wm8960->mclk); +} + static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { @@ -702,38 +730,14 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); - int ret; switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - switch (snd_soc_codec_get_bias_level(codec)) { - case SND_SOC_BIAS_STANDBY: - if (!IS_ERR(wm8960->mclk)) { - ret = clk_prepare_enable(wm8960->mclk); - if (ret) { - dev_err(codec->dev, - "Failed to enable MCLK: %d\n", - ret); - return ret; - } - } - - /* Set VMID to 2x50k */ - snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); - break; - - case SND_SOC_BIAS_ON: - if (!IS_ERR(wm8960->mclk)) - clk_disable_unprepare(wm8960->mclk); - break; - - default: - break; - } - + /* Set VMID to 2x50k */ + snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); break; case SND_SOC_BIAS_STANDBY: @@ -780,7 +784,7 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, enum snd_soc_bias_level level) { struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); - int reg, ret; + int reg; switch (level) { case SND_SOC_BIAS_ON: @@ -821,22 +825,9 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, WM8960_VREF, WM8960_VREF); msleep(100); - - if (!IS_ERR(wm8960->mclk)) { - ret = clk_prepare_enable(wm8960->mclk); - if (ret) { - dev_err(codec->dev, - "Failed to enable MCLK: %d\n", - ret); - return ret; - } - } break; case SND_SOC_BIAS_ON: - if (!IS_ERR(wm8960->mclk)) - clk_disable_unprepare(wm8960->mclk); - /* Enable anti-pop mode */ snd_soc_update_bits(codec, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | @@ -1059,6 +1050,8 @@ static int wm8960_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) static const struct snd_soc_dai_ops wm8960_dai_ops = { + .startup = wm8960_startup, + .shutdown = wm8960_shutdown, .hw_params = wm8960_hw_params, .digital_mute = wm8960_mute, .set_fmt = wm8960_set_dai_fmt,