Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1154635pxu; Wed, 2 Dec 2020 12:27:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqRqED/E4YM+4BWtdcfGfiaLTumkNVAUOdMnLxgCtl3q/bx2yPtagZEK9/4C8QdxXR7MT4 X-Received: by 2002:aa7:db56:: with SMTP id n22mr1785874edt.4.1606940854302; Wed, 02 Dec 2020 12:27:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606940854; cv=none; d=google.com; s=arc-20160816; b=tlIX5ZAuZFoTbuwe1rdRwvFDNaUtfm8U+5aF9Wpea0ttdCFmPhg2QowIdeR3XHhQEg i8rj84J1yPBF1UAxYaQEe29VaHDCmYvjnmuM8kFQH11Q86PrPC1E/RkcZhO1t3BmVBqv oyUIunjy9ToS0DVMWopJIblnAsb7cIHIef2O1A9DmLAry5b5scMktOLkEcftQWETjNbo kfPjpWPQQ8OL3tqkBxaoTauVZYZM7nUPyzTXp3x/pHt0vj/fPcHcvpgk3GNliblgPRSt 7xjyumKr6lxkyyRlr3RTmtrK45+pSYp0OgTxKDHFn6ZXFe/SV79Dugifix888e8QzP1B H+Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jPXLgrfmPsVossgPwOVXqHGCtH2YsRf8UcPWK89e/XE=; b=uoGmqvQrWVTolcV7DSwdelPSmH1SwqyBCyp4RHtZl7Zkwxdt54/3tjfreHs3PVd1+n D78JPLDCcZasohNlCIy2pv50goJ9RFbpw+jsdvw5xQlDKpbiPYmiltkKwq6cfoFLs0ix tT/KRFUokKQRLWlI/v6hFuK1ftjY2NBZrJH/u1KCy+tGS53sWhVU2ct4bN0XMC+jwbe1 0R57ve54x8lOvdVzovDYlP+FBzDg2lwoS6LGR8X+viEe3kZA31V6z7tXxCM4c/KJ/7wS buJiTFwCQJ+GzLct7L5QYKYmsPIsXhViL7MY1AnfHDbNB0NwyANMgGG5sy22evidVZQD piAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c17HjQZo; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p89si653535edp.328.2020.12.02.12.27.11; Wed, 02 Dec 2020 12:27:34 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=c17HjQZo; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729217AbgLBUX3 (ORCPT + 99 others); Wed, 2 Dec 2020 15:23:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728814AbgLBUX2 (ORCPT ); Wed, 2 Dec 2020 15:23:28 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC43AC0613D6; Wed, 2 Dec 2020 12:22:48 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id r9so1661680pjl.5; Wed, 02 Dec 2020 12:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=jPXLgrfmPsVossgPwOVXqHGCtH2YsRf8UcPWK89e/XE=; b=c17HjQZoRSkabFcQ4upzoWsYEn2nhGmFpVMHiOWRalYsFPACNwPPlFHfRqr55n1ifW UIbf93b6R4dwdO/1sf1rOV1GFKBOduB4JyTWTYqkpkMr2k22teMqdR4+8cI+A1Xf+D2d yejUZ1H8KRnenqf603ZtkoJrhm+SiFOvH80nPnS+ngZUT0kThG9j9+fH1Qnsr6MlptDf 0dZch+3qT+ebRiq3Qkg6r2MonVxgBYEXmxkarId8LsLmhv/3nzTeapzeuZs8ChORAnMZ WwgpkmAUzoNwyLhfvQ/lGRDDKg2sQNFFVAc7apcQrLmjRb2wyHRF7uhh1+K6blqtJYAL 8Vuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=jPXLgrfmPsVossgPwOVXqHGCtH2YsRf8UcPWK89e/XE=; b=YKBp+bTapsE0sCxkuON+ZifWSo/Yab38n0Ow2CrE2020kTz98HgvmVG7DfU66EqoLu gcLaO4cT8DrZI+Mhl9quYGOwJ7cxrB5xaRPZjDsZZl5z4gsREtJzw9OoUxC0TL9AmJQu DB/mtziYUmai+sbzt904inoTmEVT12cDQao+uH0mnc7751l2kqMen3DCh8EjkbqeTwYB C1f31xIVPoHOvMe/tcUVn08NVAsNslEsCZTHrzzcjxLO3SeHVtHw68OF7mw0QnCoCGzt /FP+4W1DbPsZqeBB6gRXrY63d4BX9OKtLNtGtuGgrMN58FSLDSEnlDlQbBBJqS+VKK4Z QLBw== X-Gm-Message-State: AOAM532r3hkILeusLqXeYEDoU3IcC3Gbex7lhNIKm5TyTqloVth3Hcbz tti7iiCm2adzCRr+t69HG24= X-Received: by 2002:a17:902:7c8d:b029:da:625c:8218 with SMTP id y13-20020a1709027c8db02900da625c8218mr4161472pll.26.1606940568169; Wed, 02 Dec 2020 12:22:48 -0800 (PST) Received: from Asurada-Nvidia (thunderhill.nvidia.com. [216.228.112.22]) by smtp.gmail.com with ESMTPSA id 143sm593457pfc.119.2020.12.02.12.22.46 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 Dec 2020 12:22:47 -0800 (PST) Date: Wed, 2 Dec 2020 12:19:56 -0800 From: Nicolin Chen To: Shengjiu Wang Cc: timur@kernel.org, Xiubo.Lee@gmail.com, festevam@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, lgirdwood@gmail.com, robh+dt@kernel.org, devicetree@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] ASoC: fsl: Add imx-hdmi machine driver Message-ID: <20201202201955.GB1498@Asurada-Nvidia> References: <1606455021-18882-1-git-send-email-shengjiu.wang@nxp.com> <1606455021-18882-2-git-send-email-shengjiu.wang@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1606455021-18882-2-git-send-email-shengjiu.wang@nxp.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 27, 2020 at 01:30:21PM +0800, Shengjiu Wang wrote: > The driver is initially designed for sound card using HDMI > interface on i.MX platform. There is internal HDMI IP or > external HDMI modules connect with SAI or AUD2HTX interface. > It supports both transmitter and receiver devices. > > Signed-off-by: Shengjiu Wang > --- > sound/soc/fsl/Kconfig | 12 ++ > sound/soc/fsl/Makefile | 2 + > sound/soc/fsl/imx-hdmi.c | 235 +++++++++++++++++++++++++++++++++++++++ > 3 files changed, 249 insertions(+) > create mode 100644 sound/soc/fsl/imx-hdmi.c > diff --git a/sound/soc/fsl/imx-hdmi.c b/sound/soc/fsl/imx-hdmi.c > new file mode 100644 > index 000000000000..ac164514b1b2 > --- /dev/null > +++ b/sound/soc/fsl/imx-hdmi.c > +static int imx_hdmi_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct imx_hdmi_data *data = snd_soc_card_get_drvdata(rtd->card); > + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; > + struct snd_soc_dai *cpu_dai = asoc_rtd_to_cpu(rtd, 0); > + struct snd_soc_card *card = rtd->card; > + struct device *dev = card->dev; > + int ret; > + > + /* set cpu DAI configuration */ > + ret = snd_soc_dai_set_sysclk(cpu_dai, data->cpu_priv.sysclk_id[tx], > + 8 * data->cpu_priv.slot_width * params_rate(params), Looks like fixed 2 slots being used, judging by the set_tdm_slot call below. Then...why "8 *"? Probably need a line of comments? > + tx ? SND_SOC_CLOCK_OUT : SND_SOC_CLOCK_IN); > + if (ret && ret != -ENOTSUPP) { > + dev_err(dev, "failed to set cpu sysclk: %d\n", ret); > + return ret; > + } > + > + ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0, 2, data->cpu_priv.slot_width); May have a local variable to cache slot_width. > +static int imx_hdmi_probe(struct platform_device *pdev) > + data->dai.name = "i.MX HDMI"; > + data->dai.stream_name = "i.MX HDMI"; > + data->dai.cpus->dai_name = dev_name(&cpu_pdev->dev); > + data->dai.platforms->of_node = cpu_np; > + data->dai.ops = &imx_hdmi_ops; > + data->dai.playback_only = true; > + data->dai.capture_only = false; > + data->dai.init = imx_hdmi_init; > + > + > + if (of_property_read_bool(np, "hdmi-out")) { > + data->dai.playback_only = true; > + data->dai.capture_only = false; > + data->dai.codecs->dai_name = "i2s-hifi"; > + data->dai.codecs->name = "hdmi-audio-codec.1"; > + data->dai.dai_fmt = data->dai_fmt | > + SND_SOC_DAIFMT_NB_NF | > + SND_SOC_DAIFMT_CBS_CFS; > + } > + > + if (of_property_read_bool(np, "hdmi-in")) { > + data->dai.playback_only = false; > + data->dai.capture_only = true; > + data->dai.codecs->dai_name = "i2s-hifi"; > + data->dai.codecs->name = "hdmi-audio-codec.2"; > + data->dai.dai_fmt = data->dai_fmt | > + SND_SOC_DAIFMT_NB_NF | > + SND_SOC_DAIFMT_CBM_CFM; > + } > + > + if ((data->dai.playback_only && data->dai.capture_only) || > + (!data->dai.playback_only && !data->dai.capture_only)) { > + dev_err(&pdev->dev, "Wrongly enable HDMI DAI link\n"); > + goto fail; > + } Seems that this condition check can never be true, given that: 1. By default: playback_only=true && capture_only=false 2. Conditionally overwritten: playback_only=true && capture_only=false 3. Conditionally overwritten: playback_only=false && capture_only=true If I understand it correctly, probably should be something like: bool hdmi_out = of_property_read_bool(np, "hdmi-out"); bool hdmi_in = of_property_read_bool(np, "hdmi-in"); if ((hdmi_out && hdmi_in) || (!hdmi_out || !hdmi_in)) // "Invalid HDMI DAI link"; goto fail; if (hdmi_out) { // ... } else if (hdmi_in) { // ... } else // No need of this line if two properties are exclusive > + data->card.num_links = 1; > + data->card.dai_link = &data->dai; > + > + platform_set_drvdata(pdev, &data->card); Why pass card pointer?