Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp760267imn; Tue, 26 Jul 2022 08:33:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1thOO1G6aNKiiDVAKe1l3FqPpurV8cqlNgAK8bQsjHFmUOBYRtHvVu0p1GWSCPKAozRIJET X-Received: by 2002:a17:907:8a14:b0:72b:76d0:520 with SMTP id sc20-20020a1709078a1400b0072b76d00520mr14152242ejc.468.1658849623299; Tue, 26 Jul 2022 08:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658849623; cv=none; d=google.com; s=arc-20160816; b=ZJ2PBfwfosrAt+8bJHmvRfdrHDN3jZBJ/W95P06B/dzd3FQ2rpHlPv7829cdsWAxdr SaRX8lkm58Vy+2owO6Ho0IqOx7C4nY7YlBCmgLG5FVcOcPf+PEdxbGuhGQRvtJkd0cyY pHWwKosxE0dfRKAndcyLeZg9LOskmqD8BrPbsx2/xBszAcTb+K9TQ0t/mlaBC9jU75qq H79K8lHX8aVS3ayOFdBfuvCyNYH//Ulh4zjDr6mlGXSq8tLPnI//gkflZPf1Uap4p8t+ 85iyoeKEZxp5ZYh13e0QXFfpOS1TUf88WUCJZ48Ns/W89euwaVou6OsVESjprI0OPrXV jd8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=OrU7VdrgCC3vu2cCa5wYKfwQZlfj/lFXIKKCHDIOf/0=; b=izVYlF3NV3PiBLYioiClorukRkoUfFdjJWcjJrcgKDzZ9MWFghfhFEsKjdE9hwUm7M xautpWzvTc4VE2bq2hd/vXU0o7Ig3/3GLp0p7mymnrgq/S/5OSugwGS7GPH+DXZR+HeH MFwu0d8TOetFP9AlD2KjrIeVgV6fo+crTXmbmHGkcF1Op0/G1gdaPtBmrDSXTSMrpKdZ xBenOXbf8d+t0yEccykRTYpapiyAk5RAr7LI5i3tiOFc2r9JJFkxSspi9mo/ctXvUetC n22T+PIc5sjVMJsprRqCRymCFNCKTg++BiGEzFzAGF/ppNUR6xkJDcEkczrWutkF0swM 9t5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JrJx4XRU; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id he35-20020a1709073da300b0072b66c5cdc8si12466445ejc.522.2022.07.26.08.33.17; Tue, 26 Jul 2022 08:33:43 -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=@intel.com header.s=Intel header.b=JrJx4XRU; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239452AbiGZOrx (ORCPT + 99 others); Tue, 26 Jul 2022 10:47:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239445AbiGZOru (ORCPT ); Tue, 26 Jul 2022 10:47:50 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B22919037 for ; Tue, 26 Jul 2022 07:47:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658846868; x=1690382868; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=AVdLXZczB78wzjYne0LzeumnXgq283J0Ar7FnM/OkOY=; b=JrJx4XRUU4kj6ryLQZwGweBpZLSRlfU8DQLBtP26mCMRf+MIjaWlMvXW s4dRhjkq9pwMWUwN32hvfS6pRakmxQqZfiwkKOEqud1mpQlMF4bKfVw3E DjZnG/b+Pt4FRkH0eLRe6MjD5RGGQhombq8Ppj7dD9N01JmBJXGieLMmM bbmeStlUUN+FN9kIJabnWt6glnB5zuw8+CGHJhHD/sBCOLCVd9LyZh4hr a+mahSA4pqxcaF0r5L/8+fAcohBme9MQwJ6CTem2DV1VZQlqPbAW6OUkN nT980Jwui+bwKaYcct4WiKOH3WkETD8hDhBT1j1BmbEQP38m99O5vZswM Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10420"; a="286727545" X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="286727545" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 07:47:47 -0700 X-IronPort-AV: E=Sophos;i="5.93,193,1654585200"; d="scan'208";a="597047566" Received: from adamreed-mobl.amr.corp.intel.com (HELO [10.212.70.145]) ([10.212.70.145]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jul 2022 07:47:46 -0700 Message-ID: <013c0854-5b8e-6968-1ab2-88f2d0b142a0@linux.intel.com> Date: Tue, 26 Jul 2022 09:34:05 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.11.0 Subject: Re: [PATCH v1] ASoC: Intel: cirrus-common: Use UID to map correct amp to prefix Content-Language: en-US To: Stefan Binding , Mark Brown , Liam Girdwood , Brent Lu , xliu Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com, Vitaly Rodionov References: <20220726134634.2842185-1-sbinding@opensource.cirrus.com> From: Pierre-Louis Bossart In-Reply-To: <20220726134634.2842185-1-sbinding@opensource.cirrus.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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 7/26/22 08:46, Stefan Binding wrote: > Since the order of the amps in the ACPI determines the device name, > and the ACPI order may change depending on hardware configuration, > use UID to dynamically compute the dai links, allowing dynamic > assignment of the name_prefix. This is interesting, I didn't even know what this _UID thingy could be used for. ACPI is the gift that keeps on giving after 30 years, eh? I think you should add an explanation on what this _UID is, nothing says it actually needs to be an integer, I see e.g. this sort of 'id' in various DSDT Name (_UID, Zero) // _UID: Unique ID Name (_UID, 0x05) // _UID: Unique ID Name (_UID, "SerialIoUart0") // _UID: Unique ID Name (_UID, "PCHRESV") // _UID: Unique ID Name (_UID, "IoTraps") // _UID: Unique ID Name (_UID, "SADDLESTRING") // _UID: Unique ID and my favorite Name (_UID, "TestDev") // _UID: Unique ID > /* > * Mapping between ACPI instance id and speaker position. > - * > - * Four speakers: > - * 0: Tweeter left, 1: Woofer left > - * 2: Tweeter right, 3: Woofer right > */ > -static struct snd_soc_codec_conf cs35l41_codec_conf[] = { > - { > - .dlc = COMP_CODEC_CONF(CS35L41_DEV0_NAME), > - .name_prefix = "TL", > - }, > - { > - .dlc = COMP_CODEC_CONF(CS35L41_DEV1_NAME), > - .name_prefix = "WL", > - }, > - { > - .dlc = COMP_CODEC_CONF(CS35L41_DEV2_NAME), > - .name_prefix = "TR", > - }, > - { > - .dlc = COMP_CODEC_CONF(CS35L41_DEV3_NAME), > - .name_prefix = "WR", > - }, > -}; > +static struct snd_soc_codec_conf cs35l41_codec_conf[CS35L41_MAX_AMPS]; > > static int cs35l41_init(struct snd_soc_pcm_runtime *rtd) > { > @@ -117,10 +82,10 @@ static int cs35l41_init(struct snd_soc_pcm_runtime *rtd) > static const struct { > unsigned int rx[2]; > } cs35l41_channel_map[] = { > - {.rx = {0, 1}}, /* TL */ > {.rx = {0, 1}}, /* WL */ > - {.rx = {1, 0}}, /* TR */ > {.rx = {1, 0}}, /* WR */ > + {.rx = {0, 1}}, /* TL */ > + {.rx = {1, 0}}, /* TR */ > }; > > static int cs35l41_hw_params(struct snd_pcm_substream *substream, > @@ -175,8 +140,32 @@ static const struct snd_soc_ops cs35l41_ops = { > .hw_params = cs35l41_hw_params, > }; > > +static const char * const cs35l41_name_prefixes[] = { "WL", "WR", "TL", "TR" }; > + > +static const char * const cs35l41_uid_strings[] = { "0", "1", "2", "3" }; I must admit not understanding why you changed the order. I vaguely recall Brent Lu added this on TL, WL, TR, WR order on purpose and that it matches the order in the SOF topology. Brent, can you please comment on this? I don't really care about the order selected, just want to make sure we don't introduce a channel swap with what the firmware does. > +static void cs35l41_compute_codec_conf(void) > +{ > + int uid; > + struct acpi_device *adev; > + struct device *physdev; > + > + for (uid = 0; uid < CS35L41_MAX_AMPS; uid++) { > + adev = acpi_dev_get_first_match_dev(CS35L41_HID, cs35l41_uid_strings[uid], -1); > + if (!adev) > + return; shouldn't you log an error or something telling the user that their DSDT configuration is incorrect? If I understand the code above, is the expectation that the UID expected in the DSDT should be: Name (_UID, "0") // _UID: Unique ID for WL Name (_UID, "1") // _UID: Unique ID for WR Name (_UID, "2") // _UID: Unique ID for TL Name (_UID, "3") // _UID: Unique ID for TR Is yes that's worthy of a comment for future generations. > + physdev = get_device(acpi_get_first_physical_node(adev)); > + cs35l41_components[uid].name = dev_name(physdev); > + cs35l41_components[uid].dai_name = CS35L41_CODEC_DAI; > + cs35l41_codec_conf[uid].dlc.name = dev_name(physdev); > + cs35l41_codec_conf[uid].name_prefix = cs35l41_name_prefixes[uid]; > + acpi_dev_put(adev); > + } > +} > + > void cs35l41_set_dai_link(struct snd_soc_dai_link *link) > { > + cs35l41_compute_codec_conf(); > link->codecs = cs35l41_components; > link->num_codecs = ARRAY_SIZE(cs35l41_components); > link->init = cs35l41_init;