Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1848403pxb; Sat, 2 Apr 2022 05:55:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydOb1PeA2EYRx5Pk9h6cQIT4YKKB0I2CixydJNbzrRWQGBODE54phRUE1Wm/lJGFE09nd6 X-Received: by 2002:a63:f515:0:b0:384:1f78:34b0 with SMTP id w21-20020a63f515000000b003841f7834b0mr18671261pgh.67.1648904118282; Sat, 02 Apr 2022 05:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648904118; cv=none; d=google.com; s=arc-20160816; b=RIKCwdejZBQH0C/fradndgXyVLVhlnvWkCBSabI9s2XKNo9gVeUZSRvdhDd4h7rEEb iCtBtGbQittOokN5Yz1bnOvz2/SEYkmO6bnvRFEe+df8A1JL1FLWGJqwdka+LlPBtuL5 VSVxFD/A5nL3RuzeCne2ZhAYVNw5UjOCZxsoNBLgQnN0vbiEsHdpDzUGtZPm5ys58rH+ gMnyEDwb2Sh1QLnMdGuz6Emp+q7n0edsy+6ANtKfZ90ptOuuP2REd8JKVgBcyYX44ihM QBoIkyaa7JrJva4ldojKbJffPsHbbywXX0F8qrK8eF2x5nD8Y9mOESiogP06CqU1kYMF iRKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=o0s8+g9O9ptEUPJSHpyizR5cnYWekpbCjfSIKFYgW5M=; b=ZGJy9ShzZ6XGGJExs56g45yyizmYbf3HVvblDSsf6bwSypwzrxUP+D9w7gjWEHXZZA pNhJaSKKXLFqXwsSIImfpkaOaySV7CVzozoLwWJwMy/nsTAm2Sqtz9dHuRBhFiuXhmfj GQ9keSZy2w3cw7vBRDwZVkzda5oALgsosjgFPrbSmyU8kZimGrFXj085El97ChTIOyuw ieR1yDnwJr/NljL6TxQhP4+wnJR+AQn1Dhdq74SGHYBlpjOrh3Rzw3Z94H4cI3z9ChfR Ndbj7+kmb/aaSfM3tKSSnjCGuokI4lTW7NtYhQz08Wf7Jh/Z5vfhW2SApwex5Hw4b2TA p/Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=K3eA+hrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n2-20020a6563c2000000b003816043f114si4950763pgv.777.2022.04.02.05.55.04; Sat, 02 Apr 2022 05:55:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cutebit.org header.s=mail header.b=K3eA+hrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cutebit.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235821AbiCaMKr (ORCPT + 99 others); Thu, 31 Mar 2022 08:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235797AbiCaMKq (ORCPT ); Thu, 31 Mar 2022 08:10:46 -0400 Received: from hutie.ust.cz (unknown [IPv6:2a03:3b40:fe:f0::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2CC457B7; Thu, 31 Mar 2022 05:08:55 -0700 (PDT) Content-Type: text/plain; charset=utf-8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cutebit.org; s=mail; t=1648728531; bh=o0s8+g9O9ptEUPJSHpyizR5cnYWekpbCjfSIKFYgW5M=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=K3eA+hrvPQ7rnRY1xefkH25uA65TIlMtFlXRqItvNKPSb3gNDMCXKWCcU5KIow4zd PfxtaOk4qkcLF9IRD56uT6aamjWVop9XUyQMBd3EAUJcL3Etc+DHrF6uZzi/3mvFAw 7uqF+SxBQG/o7hiwzQ6wVjEZH4pP+DD78fucp6Ss= Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.40.0.1.81\)) Subject: Re: [RFC PATCH 5/5] ASoC: Add macaudio machine driver From: =?utf-8?Q?Martin_Povi=C5=A1er?= In-Reply-To: Date: Thu, 31 Mar 2022 14:08:51 +0200 Cc: =?utf-8?Q?Martin_Povi=C5=A1er?= , Liam Girdwood , Rob Herring , Krzysztof Kozlowski , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Kettenis , Hector Martin , Sven Peter Content-Transfer-Encoding: quoted-printable Message-Id: <4651D426-BA1A-418F-90E5-278C705DA984@cutebit.org> References: <20220331000449.41062-1-povik+lin@cutebit.org> <20220331000449.41062-6-povik+lin@cutebit.org> To: Mark Brown X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_FAIL,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On 31. 3. 2022, at 13:59, Mark Brown wrote: >=20 > On Thu, Mar 31, 2022 at 02:04:49AM +0200, Martin Povi=C5=A1er wrote: >=20 >> --- /dev/null >> +++ b/sound/soc/apple/macaudio.c >> @@ -0,0 +1,597 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * ASoC machine driver for Apple Silicon Macs >> + * >=20 > Please make the entire comment a C++ one so things look more > intentional. >=20 >> + /* CPU side is bit and frame clock master, I2S with both = clocks inverted */ >=20 > Please refer to clock providers here. >=20 >> + ret =3D of_property_read_string(np, "link-name", = &link->name); >> + if (ret) { >> + dev_err(card->dev, "Missing link name\n"); >> + goto err_put_np; >> + } >=20 > This doesn't look like it's mandatory in the binding. Good catch! >> +static int macaudio_init(struct snd_soc_pcm_runtime *rtd) >> +{ >> + struct snd_soc_card *card =3D rtd->card; >> + struct macaudio_snd_data *ma =3D snd_soc_card_get_drvdata(card); >> + struct snd_soc_component *component; >> + int ret, i; >> + >> + if (rtd->num_codecs > 1) { >> + ret =3D macaudio_assign_tdm(rtd); >> + if (ret < 0) >> + return ret; >> + } >> + >> + for_each_rtd_components(rtd, i, component) >> + snd_soc_component_set_jack(component, &ma->jack, NULL); >=20 > What is the jack configuration this is attempting to describe? It = looks > like you have some dedicated speaker driver devices which are going to > get attached to jacks here for example. We know the speakers will ignore the set_jack call. There=E2=80=99s one = jack and this way we know the jack codec will attach to it, for speakers it=E2=80=99= s a no-op. (If you prefer I will special-case it to the jack codec.) >> +} macaudio_kctlfixes[] =3D { >> + {"* ASI1 Sel", "Left"}, >> + {"* ISENSE Switch", "Off"}, >> + {"* VSENSE Switch", "Off"}, >> + { } >> +}; >> + >> +static bool macaudio_kctlfix_matches(const char *pattern, const char = *name) >> +{ >> + if (pattern[0] =3D=3D '*') { >> + int namelen, patternlen; >> + >> + pattern++; >> + if (pattern[0] =3D=3D ' ') >> + pattern++; >> + >> + namelen =3D strlen(name); >> + patternlen =3D strlen(pattern); >> + >> + if (namelen > patternlen) >> + name +=3D (namelen - patternlen); >> + } >> + >> + return !strcmp(name, pattern); >> +} >=20 > This looks worryingly like use case configuration. I go over this in the cover letter! This is fixing the TDM slot = selection and disabling voltage/current sensing on the speaker amp codecs, which = have no business being exposed to userspace as options. This is not use case, this not letting people blow their speakers from userspace. >=20 >> +/* >> + * Maybe this could be a general ASoC function? >> + */ >> +static void snd_soc_kcontrol_set_strval(struct snd_soc_card *card, >> + struct snd_kcontrol *kcontrol, const = char *strvalue) >=20 > No, we should not be setting user visible control values from the > kernel. This shouldn't be a machine driver function either. What are > you trying to accomplish here? See above. Martin