Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4557227pxu; Tue, 20 Oct 2020 22:24:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyuSK1hLs6OQ2TiV/dwNCjAA0rIJkNlJ9i6MVcFb/5xFWKqK7C55Y7ZmUMjW08Bv4qHq4l X-Received: by 2002:a17:906:bc42:: with SMTP id s2mr1618585ejv.251.1603257865951; Tue, 20 Oct 2020 22:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603257865; cv=none; d=google.com; s=arc-20160816; b=Wr1WXqWLqKs+Wnu1pgMNhWFBmd5nfNpcsDcCwWIF0T/JjazdkYdueKbrbR0hlTXvEr QKgMzvCJ8CQjjO/Vatzom8ui1OPwZ+DDkkVIShmQaylyaz1RbQmfgbqQekzkWLaFZSYn IMrqrKzdysePdrEQNzlGS4ozPnI6nZvr+FZ9m3k8cTxV5qfrKltNZ1X7U58LIsZ/v6nl z4pjXhEaOiyLScL/g7gRImRqhRH8TJhDYbVXAuGXs0xhWNgyW5xgYave5LCU2lbgSd/a +9gniD4ydLCxwwIJUwmPF5XGptY+8Te6Dv4xOOIdtHxEBbDnPOI2OxNJ6S3DEC9KFkz9 cQPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Dd/4tB1jhfJBU76uhWYvJK/M1Y4WZsbkyJFSG8k8QQo=; b=RG+LM2YHAFx3fdJ+mNEuiGSr3zdK8bnN9yR4RstqBVa/5tioRqOzVT4Fr2/skH8C01 g7kJuBcyx0mUvWbyuSgb7sRPoTJiIYoJPD8IhrptuEggxL2/J2Exq2VtnNOyI+VmkydB UL/Y8ql7P0IyEXNrB1Rcux68iazdmbE/Vy657bUJpqKeK5SGp4Jv5jCe0U3Gi6IRtii1 GV2you0Pl/pG7a+GxDqyjzKJt2olDLoh+aU+H1/uSkbWbxzZMQpL8SwvRc83up+QsyDA Y4YNaNx6Z4fzrxToQbLCOEZYlZTEHrZ7DQCImeEcbHli/Z9XeCurINK3l7WC3QpCa5Tl zkZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TPK9GUXw; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si709914ejb.743.2020.10.20.22.24.03; Tue, 20 Oct 2020 22:24:25 -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=@chromium.org header.s=google header.b=TPK9GUXw; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407505AbgJTNhf (ORCPT + 99 others); Tue, 20 Oct 2020 09:37:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407478AbgJTNhf (ORCPT ); Tue, 20 Oct 2020 09:37:35 -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 4C60FC0613CE for ; Tue, 20 Oct 2020 06:37:34 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id h7so2182962wre.4 for ; Tue, 20 Oct 2020 06:37:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Dd/4tB1jhfJBU76uhWYvJK/M1Y4WZsbkyJFSG8k8QQo=; b=TPK9GUXwppf2mM1kCN3ve/x60CKUztqZ+989Nh8aqFSLGa+l7mbzE/LqA70BHIvGZz 9t62mD+eV+mTcXERLQfsqGiscvH12E6jUFihaaN9G4Q/H5OP5vn/D7cAcdZLOAKnGAP4 3CcOZMOSIaLcag5ahYLat4UtdM8iVyx44UW/o= 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=Dd/4tB1jhfJBU76uhWYvJK/M1Y4WZsbkyJFSG8k8QQo=; b=k0A6Gm7c5vS9S493Dfd57bDjO94MMfjz4C+aQymqyHmKruorCMNJH4Sn62M2OE6sBR REWt9/Mp9XVQj4kzMxJT1FiPgii6JyKxkEaI6joQ6ZPnl57twrUKaut67UbpxKUgLwXi Vam09utfV3mJqX9EMfWRX6HjO+LeBp2rDHYfB+S4XOtBBf/b2R0IKDFuyvDdktUvXDue 6W1mQnFQfLYITbpj97BvW9wxQdmzrEdSKH3lt3Nx3eZx5O//Zww6LhPZJ+doJoxo5Fzf VmBFHZ04b5Yx+6pIcBWL/6LOX8seBWIu8fjGTuCKTBc2Gb3JjPd9XKn6tnX+v9mGuYlq QxDw== X-Gm-Message-State: AOAM530uYWXbFbgBvWoeseyGN6MVRcBxLscC9gKs+F6zwOVploWGRwn1 lvkTPCC8ozxPCC5bl+LPrrCiIdfouAZVgB80N9EimA== X-Received: by 2002:adf:cc82:: with SMTP id p2mr3646265wrj.177.1603201052544; Tue, 20 Oct 2020 06:37:32 -0700 (PDT) MIME-Version: 1.0 References: <20200914080619.4178587-1-cychiang@chromium.org> <20200914080619.4178587-3-cychiang@chromium.org> <7bdc0d63-27b1-f99e-c5f8-65f880733d16@linaro.org> <20201015161251.GF4390@sirena.org.uk> In-Reply-To: <20201015161251.GF4390@sirena.org.uk> From: Cheng-yi Chiang Date: Tue, 20 Oct 2020 21:37:05 +0800 Message-ID: Subject: Re: [PATCH v11 2/3] ASoC: qcom: dt-bindings: Add sc7180 machine bindings To: Mark Brown Cc: Srinivas Kandagatla , linux-kernel , Taniya Das , Rohit kumar , Banajit Goswami , Patrick Lai , Andy Gross , Bjorn Andersson , Liam Girdwood , Rob Herring , Jaroslav Kysela , Takashi Iwai , Stephan Gerhold , Matthias Brugger , Heiko Stuebner , Srinivasa Rao , Doug Anderson , Dylan Reid , Tzung-Bi Shih , Linux ARM , linux-arm-msm , Kuninori Morimoto , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "moderated list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..." , "moderated list:ARM/Mediatek SoC support" , "open list:ARM/Rockchip SoC..." , Ajye Huang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 16, 2020 at 12:13 AM Mark Brown wrote: > > On Thu, Oct 15, 2020 at 03:59:26PM +0800, Cheng-yi Chiang wrote: > > On Tue, Oct 13, 2020 at 6:36 PM Srinivas Kandagatla > > > > > +properties: > > > > + compatible: > > > > + const: qcom,sc7180-sndcard-rt5682-m98357-1mic > > > > This information can come from the dai link description itself, why > > > should compatible string have this information? > > > I think dailink description is not enough to specify everything > > machine driver needs to know. > > E.g. there is a variation where there are front mic and rear mic. We > > need to tell the machine driver about it so > > it can create proper widget, route, and controls. > > That sounds like something that could be better described with > properties (including for example the existing bindings used for setting > up things like analogue outputs and DAPM routes)? > Hi Mark, thank you for the comments. May I know your suggestion on Ajye's patch "ASoC: qcom: sc7180: Modify machine driver for 2mic" ? https://lore.kernel.org/r/20200928063744.525700-3-ajye_huang@compal.corp-partner.google.com I think adding code in the machine driver makes the intent straightforward. If we want the machine driver to be fully configurable, we can always add more code to handle properties like gpio, route, widget (mux, text selection) passed in from the device tree. But I feel that we don't need a machine driver to be that configurable from the device tree. I think having the logic scattered in various dtsi files and relying on manual inspection to understand the usage would be less maintainable than only exposing needed property like gpio. Especially in the complicated case where we need to create a mux widget with callback toggling the gpio like this: +static const char * const dmic_mux_text[] = { + "Front Mic", + "Rear Mic", +}; + +static SOC_ENUM_SINGLE_DECL(sc7180_dmic_enum, + SND_SOC_NOPM, 0, dmic_mux_text); + +static const struct snd_kcontrol_new sc7180_dmic_mux_control = + SOC_DAPM_ENUM_EXT("DMIC Select Mux", sc7180_dmic_enum, + dmic_get, dmic_set); + +SND_SOC_DAPM_MUX("Dmic Mux", SND_SOC_NOPM, 0, 0, &sc7180_dmic_mux_control), Passing all the logic along with the callback of dmic_get, dmic_set from the device tree would be too hard to maintain. > > The codec combination also matters. There will be a variation where > > rt5682 is replaced with adau7002 for dmic. > > Although machine driver can derive some information by looking at dailink, > > I think specifying it explicitly in the compatible string is easier to > > tell what machine driver should do, e.g. > > setting PLL related to rt5682 or not. > > These feel more like things that fit with compatible, though please take > a look at Morimoto-san's (CCed) work on generic sound cards for more > complex devices: > > https://lore.kernel.org/alsa-devel/87imbeybq5.wl-kuninori.morimoto.gx@renesas.com/ > > This is not yet implemented but it'd be good to make sure that the > Qualcomm systems can be handled too in future. Yes, that should work to describe the dailink we are using. But a more tricky issue is how to do calls like setting PLL in dai startup ops. /* Configure PLL1 for codec */ ret = snd_soc_dai_set_pll(codec_dai, 0, RT5682_PLL1_S_MCLK, DEFAULT_MCLK_RATE, RT5682_PLL1_FREQ); I think that asking a generic machine driver to do configuration like this with only a limited interface of device property might be too much of an ask for the machine driver. > > > You can see widget, route, controls are used according to the configuration. > > The alternative approach is to check whether "dmic-gpio" property > > exists to decide adding these stuff or not. > > But it makes the intent less easier to understand. > > OTOH if you have lots of compatibles then it can get hard to work out > exactly which one corresponds to a given board. Totally agree. Glad we have only three variations up to now. Would you mind if I simplify the compatible string like Srinivas suggested, and send a v12? As for other two kinds of variations that I am aware of: 1. front mic / rear mic 2. replace alc5682 with adau7002 We can set different board names and different compatible strings to achieve such variation. So that it would make sense to describe configuration in compatible strings like you suggested, and also provides UCM a way to distinguish different boards. What do you think ? Thanks!