Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp779888ybj; Tue, 5 May 2020 07:27:08 -0700 (PDT) X-Google-Smtp-Source: APiQypJeqErljs/AAhSEwaoXyHOQEre7Qy6P80pvIJMY+Xzw642C7KRKIlPyunahBI1yVgUNw7hE X-Received: by 2002:aa7:c0d1:: with SMTP id j17mr2907342edp.308.1588688827888; Tue, 05 May 2020 07:27:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588688827; cv=none; d=google.com; s=arc-20160816; b=Gsm7bTCLq7DoYeMmyjh41nAMMQHuT9E2IbZadSkPmeMqWwgq22Gku3DdAEK1Jl0gBP yEwe9JAXwYBUgYOfS8NsC1wuLl53WL8UX4gtxSF09lK3opjXQzSnvPrt6NUwVaWuZHSO yWbPwjOj/vxxJHvKrwdAU3lKWBkEsNXgtX2Y7XC9bjYVlT3qlT1hocjYp6oTN+Pp0F0B 7e1rhrMWiILF0gScprTYyAd6/5/Se63RXo3z1NF70y2dXHTBEztdgQvi024Q42+KJLKJ VAn2TA3F5fFvteqeD4fxRJJ6ezFrxNTwLpoaPYOcb0OOkc8bKWwOLF/ITdfJTSHK0uHR L84Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1Y70Nah3FzhZidtus6gd4+NBEFZJBCSZiFmzmK0CZes=; b=Z7P2R9FMcSqHvkHznRQUFfR3eaG4tfdNToZjCFpMg4/Fs3v1QzLt0tFqqL2Vi57/ZC spTjShtxZLCjDD7gEZQ6mYeqv5aPWhspXIJfKXCf3eta1ZEe+FglaRCMhtvsLdScGRXH iKIKDZToxSSgYBPJrBAvmvuTPrjpI2zxi5eE6mK9xd4AkLHr8igGAbcJV/e/vld3CiTk kIaenvho7peXzh6gURJNsk9IftyC9QwvLT2O0NJUqrCxElHY+zStS8L2u9n94Z12C2Ov aozuA49Jzj5x9xjGHchkU7FqTbl1CGhViYcliZHxUeofZXZ6MY264bLgwBD/CqVCgnVR Xfpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=x1AlWCzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df12si1321315edb.540.2020.05.05.07.26.43; Tue, 05 May 2020 07:27:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf-com.20150623.gappssmtp.com header.s=20150623 header.b=x1AlWCzm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730417AbgEEOYB (ORCPT + 99 others); Tue, 5 May 2020 10:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730134AbgEEOYA (ORCPT ); Tue, 5 May 2020 10:24:00 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6548C061A0F for ; Tue, 5 May 2020 07:23:59 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id k1so2999813wrx.4 for ; Tue, 05 May 2020 07:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1Y70Nah3FzhZidtus6gd4+NBEFZJBCSZiFmzmK0CZes=; b=x1AlWCzm3i+12zcO6l4aukwQ6Aaof5MzjJECcmVMkipsGWsE3LSKZMf9m9jgofhDqk JEP67rHJ/3IuCTnaK93uk3OOdXP03ypzlV3f7xKJPsGyOkFJxvTT6CFAOU0AX3bfS0vV luvzHQ5DXTLwgApmTca8dEUYyqZFiqDGqhmQlkjjvRI97PPi4ru79qs3fCKOpSGNjzvM T/AWvaVizbhmtLgUNVM+9P74+/nfqBOHSjtU77MMzNdwkJcYDJ2IRgX/HOksz7ybaQ5j AgXz02KGCDDTyh+art+q9aNX9mTlNZ5lkOUxQWfKF4ZO6hvUjC9vUOldHWGNFS2LbZZg zI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1Y70Nah3FzhZidtus6gd4+NBEFZJBCSZiFmzmK0CZes=; b=AdGMAVpbpQkHfaeMzWQsu0rFRrLyzkr2y/0gPVrZr6NTo+TQKd9dAzfBJHGmNsbX7F rNbtEWGUnhaaLH+uOH73xK375gCkK8JgQ/Fjw45HXqxPSdm0SEirSUJDStjxKbUhZ/Hg 7trfyy7JgLqJxURpe7Zl9TNkwHwbdZCW/7cuxttvUHb/LS4G/pzkmvo9qg0Zun5BCBRd rukP4XH6qZsm5PEvshkUMuQoCS0DAit+tjXQP5ePvn7YI+vMyJBC8ZCcD5syjgrxEidi ubJFZQ4dexr1h/BNulu8Maw8wRtVoiBnqNQB2Uf4aOkKVuM2KhQVHTazEhFjERkJQmAQ I3Jw== X-Gm-Message-State: AGi0PuaKQrkb16yz0d/eaRhpgS3B4FETj13s83szyAHzDm8ClATYCiDp 8fVdRhgJuVReCOXnlusuTX/pi3nOjM10yB+8MfielQ== X-Received: by 2002:adf:f1c6:: with SMTP id z6mr4004676wro.361.1588688638314; Tue, 05 May 2020 07:23:58 -0700 (PDT) MIME-Version: 1.0 References: <20200501193141.30293-1-rad@semihalf.com> <3ad44b75-387f-da75-d7b2-3a16ed00550c@linux.intel.com> In-Reply-To: <3ad44b75-387f-da75-d7b2-3a16ed00550c@linux.intel.com> From: =?UTF-8?Q?Rados=C5=82aw_Biernacki?= Date: Tue, 5 May 2020 16:23:41 +0200 Message-ID: Subject: Re: [PATCH V2] ASoC: Intel: boards: Use FS as nau8825 sysclk in nau88125_* machine To: Pierre-Louis Bossart Cc: Liam Girdwood , Jie Yang , Jaroslav Kysela , Takashi Iwai , Lech Betlej , alsa-devel@alsa-project.org, Todd Broch , Harshapriya , John Hsu , linux-kernel@vger.kernel.org, "Sienkiewicz, Michal" , Ben Zhang , Mac Chiang , Yong Zhi , Marcin Wojtas , Vamshi Krishna , Alex Levin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thank you Pierre for the review! answers inline pt., 1 maj 2020 o 22:16 Pierre-Louis Bossart wrote: > > > > On 5/1/20 2:31 PM, Radoslaw Biernacki wrote: > > This single fix address two issues on machines with nau88125: > > 1) Audio distortion, due to lack of required clock rate on MCLK line > > 2) Loud audible "pops" on headphones if there is no sysclk during nau8825 > > playback power up sequence > > > > Explanation for: > > 1) Due to Skylake HW limitation, MCLK pin can only output 24MHz clk > > rate (it can be only connected to XTAL parent clk). The BCLK pin > > can be driven by dividers and therefore FW is able to set it to rate > > required by chosen audio format. According to nau8825 datasheet, 256*FS > > sysclk gives the best audio quality and the only way to achieve this > > (taking into account the above limitations) its to regenerate the MCLK > > from BCLK on nau8825 side by FFL. Without required clk rate, audio is > > distorted by added harmonics. > > The BCLK is going to be a multiple of 50 * Fs due to clocking > restrictions. Can the codec regenerate a good-enough sysclk from this? According to Intel, silicon has a limitation, on SKL/KBL only clk_id = SKL_XTAL, .name = "xtal" is available for IO domain. As mentioned in the commit: MCLK is generated by using 24MHz Xtal directly or applying a divider (so no way of achieving the rate required by audio format). BCLK/FS is generated from 24MHz and uses dividers and additional padding bits are used to match the clock source. Next gen silicon has the possibility of using additional clock sources. Summing up, using MCLK from SKL to NAU88L25 is not an option. The only option we found is to use BCLK and regen the required clock rate by FLL on the NAU88l25 side. > > > > 2) Currently Skylake does not output MCLK/FS when the back-end DAI op > > hw_param is called, so we cannot switch to MCLK/FS in hw_param. This > > patch reduces pop by letting nau8825 keep using its internal VCO clock > > during widget power up sequence, until SNDRV_PCM_TRIGGER_START when > > MCLK/FS is available. Once device resumes, the system will only enable > > power sequence for playback without doing hardware parameter, audio > > format, and PLL configure. In the mean time, the jack detecion sequence > > has changed PLL parameters and switched to internal clock. Thus, the > > playback signal distorted without correct PLL parameters. That is why > > we need to configure the PLL again in SNDRV_PCM_TRIGGER_RESUME case. > > IIRC the FS can be controlled with the clk_ api with the Skylake driver, > as done for some KBL platforms. Or is this not supported by the firmware > used by this machine? According to Ben, SKL had limitations in FW for managing the clk's back in the days. Can you point to the other driver you mention so we can cross check? > > > -static int skylake_nau8825_hw_params(struct snd_pcm_substream *substream, > > - struct snd_pcm_hw_params *params) > > +static int skylake_nau8825_trigger(struct snd_pcm_substream *substream, int cmd) > > { > > struct snd_soc_pcm_runtime *rtd = substream->private_data; > > + struct snd_pcm_runtime *runtime = substream->runtime; > > struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); > > - int ret; > > - > > - ret = snd_soc_dai_set_sysclk(codec_dai, > > - NAU8825_CLK_MCLK, 24000000, SND_SOC_CLOCK_IN); > > + int ret = 0; > > > > - if (ret < 0) > > - dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret); > > + switch (cmd) { > > + case SNDRV_PCM_TRIGGER_START: > > + ret = snd_soc_dai_set_sysclk(codec_dai, NAU8825_CLK_FLL_FS, 0, > > + SND_SOC_CLOCK_IN); > > + if (ret < 0) { > > + dev_err(codec_dai->dev, "can't set FS clock %d\n", ret); > > + break; > > + } > > + ret = snd_soc_dai_set_pll(codec_dai, 0, 0, runtime->rate, > > + runtime->rate * 256); > > + if (ret < 0) > > + dev_err(codec_dai->dev, "can't set FLL: %d\n", ret); > > + break; > > + case SNDRV_PCM_TRIGGER_RESUME: > > + ret = snd_soc_dai_set_pll(codec_dai, 0, 0, runtime->rate, > > + runtime->rate * 256); > > + if (ret < 0) > > + dev_err(codec_dai->dev, "can't set FLL: %d\n", ret); > > + msleep(20); > > is there a reason why you'd need a msleep for resume and not for start? No. I think we missed this. msleep() is needed to stabilize FLL. Will fix in next rev.