From patchwork Fri Dec 1 04:25:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10086135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F63160327 for ; Fri, 1 Dec 2017 04:26:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C2852A391 for ; Fri, 1 Dec 2017 04:26:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F9AD2A39A; Fri, 1 Dec 2017 04:26:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAB2B2A391 for ; Fri, 1 Dec 2017 04:26:11 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 24EFB267B9B; Fri, 1 Dec 2017 05:26:10 +0100 (CET) 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 78F4A267B9C; Fri, 1 Dec 2017 05:26:09 +0100 (CET) Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by alsa0.perex.cz (Postfix) with ESMTP id 3C706267B70 for ; Fri, 1 Dec 2017 05:26:02 +0100 (CET) Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 01 Dec 2017 13:26:00 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 7EAF16C15B; Fri, 1 Dec 2017 13:26:00 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.45,344,1508770800"; d="scan'208";a="263840226" Received: from mail-pu1apc01lp0017.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.17]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 01 Dec 2017 13:25:59 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=X6wR2Pdhq1fAIHjRr4a55AD2hbCNY8WdVEw1j24/O+g=; b=SYyYH75MgBlN59RkCdqh6PnXCMkZ6OlIHZq7W+xjqp0wb9fdCd7HwCbV2sAANOsjjnOxZabhDtwKVKzH4xXY6cttyUuWzIfzzH0uBa0ygf9wrlfe16s2Tu6o1Svg/RQOZiMpQyMA4QMNlyAFChT5t0unRTTw7koHjk3ZFvByIzE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.138) by SG2PR0601MB1888.apcprd06.prod.outlook.com (2603:1096:3:9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.282.5; Fri, 1 Dec 2017 04:25:57 +0000 Message-ID: <87k1y73wwa.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 1 Dec 2017 04:25:57 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: SG2PR06CA0113.apcprd06.prod.outlook.com (2603:1096:1:1d::15) To SG2PR0601MB1888.apcprd06.prod.outlook.com (2603:1096:3:9::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1cf357c0-85be-4443-9b1f-08d538739eb7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603286); SRVR:SG2PR0601MB1888; X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1888; 3:8GQjhD5z3w6qsTepghAXj/uT8ldrg9XAEAVDCauT164ho539DQ+iKgCIgDOnFysQGHCpqoG9vdLAj4Fy9jbVP20aYklHZlFtE35Eb7WKDBFU4cC8wRBo92f/FMFX/CAaWWtpMALJDzCl8bxx3jU+0Bv2fwZpncSeqjnaCpGVv+10TZGP8GTP7Vi/mcslM6a+WkfbF51ZqfXj13fIXtPdGxr/bvj4juRlg3BpNI674JheujfIsXzyCw85U0wWes7y; 25:YREp0sWdMT8qDltiZ9Jc9r6acCUmS6TN+wYGxiAbHOq4+H3uIGrhJkAljBwTjgW4ZEVWOQsaFQ2pULP52q5aeDJ3FSCqAQu8iyZxFvJ/AkgJ/ZRqRoQYPKg32TEfznRoEHTgV6rj+BLQe3wn3fttO+Mg26bCEfzn23dDtuRMsZoVa56mWJA2QTeoHzNz3xF7yVh6MLbmCTyVt1jb4V4wV/nRvcL7M2WITCq/0oNzuBnV7FF+U/NHth+uZKF4FdZajDYKKPKfGYCdB45zAjhtBEA5K0NvG/XFq/aotXP3BLX8Rx2PTDkgbRCNB65VcEhDAh6iHgRU+tSpRQnvkTk+cw==; 31:E+APDY9/CayMoS2dWIke1Kx2kAAt038CSRTmxT+Von5gQELAeiq7P3h9XAaiiGG0teKBPgZU8Fa0FPhKO2XPUO76BQX/508pZ5GFvjBdJbQhRFEyDNjcxJGrrtGh73rnNbd2Wkc05jPAkJLy1L6QFcD52Yx/dIrfk9IgPjqJoIAM5hmKs4AVg8g3MjocWf1Nsu9HdtKrBhk12JwAMp/npwplOSNoAJ4v1f//XZbz1cc= X-MS-TrafficTypeDiagnostic: SG2PR0601MB1888: X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1888; 20:SfnVWw8kLbDrA/XUohK3yfK4g0YBwrA1F1SjZWF+9PzOR9oHoqQml830NEuHXgEagAEWQ9+aqlVJAkVRDWpLBqU3+QYC/VdTzyBrUKrgRKO4kiDk7HP0SAD2rzsULyfSIrkSrGTHl7dTpmOM278gKTRbKYMoexitQyxGYCDRFZLiQuF/HnsNhRK096EIw3v78+zcsJ9JSSpekrBMBKDbUHLrJ5BHK/HeKWo99Z1ZZLFdcGTK3MqOcyS0PEACY6EW+ntZ2/LX1+Gqi7/UOtw8Mt2sskRNkvDTub9yZDdphkrLtBzxQwkO+viQ+L0ZANdnm5IuwogbZ297zgWqeMqd+a2/fRLaQkG/gKrAPWcEKlcOpohZN+NjdFJWfxUvueNqFVTodkg3z1JxOgQQdSbzIJg9NcZg69+3YBy34nk7Z1CTJhVKwOcEtJktDHl+I8je1APD7lFCIYl/OXXmrB50RVoXlpT+IzfOIbg/PqAQhqhm7/aVR80Wmrr/l2akXFAv; 4:jM+5W8BQ55IfAYNZp5hNrjUFgfj4AtMezrY6njm2bQDwh+Zxi+j3LbadPEw7A8D45yUG5BPHzLUkGgJo3+6OLY31ysIHeVKXTOR/6BdEsOalmnVs8kgze0d5SPMF7XcMtEi7VQI7h95ceRBr9Dm35UXCFmcFCzRbVoRbdUL1cGEFXsQARDqiRakXq/5zSswWXYLbH9B/zHD0LDyLSi4hJnPuxv1Ndpl1mLeKSwcUSQdg4tNqMUPaIxdQy1MwtW3Wrw8YIArPlEmsHbC4YXO1/Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(3231022)(93006095)(93001095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123562025)(20161123558100)(20161123560025)(6072148)(201708071742011); SRVR:SG2PR0601MB1888; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SG2PR0601MB1888; X-Forefront-PRVS: 05087F0C24 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(39860400002)(366004)(346002)(376002)(199003)(189002)(8936002)(83506002)(68736007)(106356001)(105586002)(5660300001)(6916009)(97736004)(189998001)(316002)(54906003)(54356011)(16586007)(4326008)(58126008)(25786009)(52116002)(478600001)(7696005)(16526018)(53936002)(6116002)(81156014)(81166006)(66066001)(3846002)(53416004)(8676002)(23726003)(101416001)(7736002)(2906002)(6486002)(86362001)(69596002)(33646002)(47776003)(305945005)(36756003)(50466002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR0601MB1888; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR0601MB1888; 23:QUxks4mSX3CnWBxJEUYELad8GVoQkRPOXPejbJT?= =?us-ascii?Q?f2mN9BRz8t0pEpslV57fdEwlULiGnQPLm+AoWcLj7ZCEWMpRr9YKTwAoqIAA?= =?us-ascii?Q?atSCUHrEkv2Txw1YH9t1aBAl48+lSe/PdRA2eJzTRAsloP6Sf3yV/78fXJ8i?= =?us-ascii?Q?mFJumXcdLfc2Aw0+/TlV1qOpWfRj5ikQAMO3J96wFMWAwd2u0dK04JRXEu0l?= =?us-ascii?Q?TlwHvExyerkcKO16OIZAdRZid2hcvNcU13ikrO44c4rFNgbKX+Y9k/4hZhPH?= =?us-ascii?Q?2zfwRqh3i+VRNOQ6Ls/3aCR1oRgavIkK4yEDIG4GipJcgMKMnOYyLh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2C4Y7xVtGEN3zLVRpb0Keex21XX+rkA3VASgCAdrn1wYgs= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2017 04:25:57.1926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cf357c0-85be-4443-9b1f-08d538739eb7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR0601MB1888 Cc: Linux-ALSA , Simon , "Yokoyama \(Renesas\)" , Takashi Sakamoto Subject: [alsa-devel] [PATCH v4] ASoC: ak4613: call dummy write for PW_MGMT1/3 when Playback 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 From: Kuninori Morimoto Power Down Release Command (PMVR, PMDAC, RSTN, PMDA1-PMDA6) which are located on PW_MGMT1 / PW_MGMT3 register must be write again after at least 5 LRCK cycle or later on each command. Otherwise, Playback volume will be 0dB. Basically, it should be 1. PowerDownRelease by Power Management1 <= call 1.x after 5LRCK 1.x Dummy write to Power Management1 2. PowerDownRelease by Power Management3 <= call 2.x after 5LRCK 2.x Dummy write to Power Management3 To avoid too many dummy write, this patch is merging these. 1. PowerDownRelease by Power Management1 2. PowerDownRelease by Power Management3 <= call after 5LRCK 2.x Dummy write to Power Management1/3 <= merge dummy write This patch adds dummy write when Playback Start timing. Tested-by: Hiroyuki Yokoyama Signed-off-by: Kuninori Morimoto --- v3 -> v4 - use schedule_work() instead of schedule_delayed_work() sound/soc/codecs/ak4613.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c index ee9e822..8d2c90b 100644 --- a/sound/soc/codecs/ak4613.c +++ b/sound/soc/codecs/ak4613.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include @@ -95,6 +96,9 @@ struct ak4613_priv { struct mutex lock; const struct ak4613_interface *iface; struct snd_pcm_hw_constraint_list constraint; + struct work_struct dummy_write_work; + struct snd_soc_component *component; + unsigned int rate; unsigned int sysclk; unsigned int fmt; @@ -392,6 +396,7 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } + priv->rate = rate; /* * FIXME @@ -467,11 +472,65 @@ static int ak4613_set_bias_level(struct snd_soc_component *component, return 0; } +static void ak4613_dummy_write(struct work_struct *work) +{ + struct ak4613_priv *priv = container_of(work, + struct ak4613_priv, + dummy_write_work); + struct snd_soc_component *component = priv->component; + unsigned int mgmt1; + unsigned int mgmt3; + + /* wait 5 LR clocks */ + udelay(5000000 / priv->rate); + + snd_soc_component_read(component, PW_MGMT1, &mgmt1); + snd_soc_component_read(component, PW_MGMT3, &mgmt3); + + snd_soc_component_write(component, PW_MGMT1, mgmt1); + snd_soc_component_write(component, PW_MGMT3, mgmt3); +} + +static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + + /* + * FIXME + * + * PW_MGMT1 / PW_MGMT3 needs dummy write at least after 5 LR clocks + * from Power Down Release. Otherwise, Playback volume will be 0dB. + * To avoid complex multiple delay/dummy_write method from + * ak4613_set_bias_level() / SND_SOC_DAPM_DAC_E("DACx", ...), + * call it once here. + * + * But, unfortunately, we can't "write" here because here is atomic + * context (It uses I2C access for write). + * Thus, use delayed work with 0 delay to switch to normal context + * immediately, and wait 5 LR clocks and do dummy_write there. + */ + + if ((cmd != SNDRV_PCM_TRIGGER_START) && + (cmd != SNDRV_PCM_TRIGGER_RESUME)) + return 0; + + if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) + return 0; + + priv->component = &codec->component; + schedule_work(&priv->dummy_write_work); + + return 0; +} + static const struct snd_soc_dai_ops ak4613_dai_ops = { .startup = ak4613_dai_startup, .shutdown = ak4613_dai_shutdown, .set_sysclk = ak4613_dai_set_sysclk, .set_fmt = ak4613_dai_set_fmt, + .trigger = ak4613_dai_trigger, .hw_params = ak4613_dai_hw_params, }; @@ -591,6 +650,7 @@ static int ak4613_i2c_probe(struct i2c_client *i2c, priv->iface = NULL; priv->cnt = 0; priv->sysclk = 0; + INIT_WORK(&priv->dummy_write_work, ak4613_dummy_write); mutex_init(&priv->lock);