Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2746865pxu; Sun, 29 Nov 2020 03:48:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUEIWpWz8paqowT6jBgzu6euEut4rb9xBx2GEkcAOHiUvf/AoA/ba6/iy73vm4qc3K/9Mb X-Received: by 2002:a50:e791:: with SMTP id b17mr3322786edn.388.1606650491483; Sun, 29 Nov 2020 03:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606650491; cv=none; d=google.com; s=arc-20160816; b=RXiaV1oEjbwL4KSP3n2SYgjWl1/qrH0EYh4RQllyXA6kbRvTJy9qUjQBjwE/f2ycvb SZVpUhI5gYUKgXJ+GlMZ9uhe898ZTgzAgtABiEdxBFGJnblSuGW3K1QvJ7BLskMCXp6n k9GA4gvmiC86xhzpO25/ZWXB5gMICm0j1V7396+o3K2UfqF6MBt9yzMrpePiKDAwVtdT Fj265YC+cRaOOpS1+qm51sOXx00MpLLWzIWa/xVSQlRvlHMfSqcgYZfTDIzmrtU7PnFC r3NAmO0mHswepzMN5RzJRVY2SiPMHTLwigvAKPrxA7Ui9pgcWbs9hpqWDtpMyTXh0GmE qNSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=+gSA71yz3AvhlSBLjgCbD8Iyr8dBvyUfu0u2Qo4YI8Y=; b=T5SfPz8TovZKXit+QvT5n5FJaz7APz3pKA52OoTKpljx8mKhDeMN6LtN83ZPWHeAZJ A8wz5PeeD4h9Gmi6YaxjnCERSp7f03AEYRXOoTb97mXuCSEIIDH6EnBosUEXM7xlvJ/T skqUa2JMeppTnSFDwyhczL/KHf3FP7HdMw6pSfRzvxhntzyNaSMXEkqS/kkh5N6IHJbm lLWRwbhtS+YlWJ/LMOBJoj5eRYICtj+lpIWKrwwpqFVT24/kixY0/b9g5ma6oVKHavlY 2ICxherDDbGr78U7bAZnDhpUsIrkgigQ1nCETqCGT3ZcssHYNTUFTR8CqmmURcinBTu7 fZNA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t10si8681919eju.536.2020.11.29.03.47.48; Sun, 29 Nov 2020 03:48:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387461AbgK2Lo7 (ORCPT + 99 others); Sun, 29 Nov 2020 06:44:59 -0500 Received: from mga07.intel.com ([134.134.136.100]:8130 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbgK2Lo7 (ORCPT ); Sun, 29 Nov 2020 06:44:59 -0500 IronPort-SDR: fcQT/+l3AvLNyMNriBZbkXGE9N5U9wd1SSr4JYojA6IsdBKol8Y85bl5wQ+QbhfJb7Mezxf+3m XhkUPdjpYGQQ== X-IronPort-AV: E=McAfee;i="6000,8403,9819"; a="236654216" X-IronPort-AV: E=Sophos;i="5.78,379,1599548400"; d="scan'208";a="236654216" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2020 03:43:21 -0800 IronPort-SDR: 8hOqvENdMdNyXUQbrRMDK/8JxCqYtLxxtWuAiZspRKLIGSG700KvboJy2Vq2q/tQzpxFL+MGPM r3CP4wDWfPGg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,379,1599548400"; d="scan'208";a="480261683" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga004.jf.intel.com with ESMTP; 29 Nov 2020 03:43:19 -0800 From: Cezary Rojewski To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: alsa-devel@alsa-project.org, broonie@kernel.org, tiwai@suse.com, pierre-louis.bossart@linux.intel.com, mateusz.gorski@linux.intel.com Subject: [PATCH 8/8] ASoC: Intel: Skylake: Automatic DMIC format configuration according to information from NHLT Date: Sun, 29 Nov 2020 12:41:48 +0100 Message-Id: <20201129114148.13772-9-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201129114148.13772-1-cezary.rojewski@intel.com> References: <20201129114148.13772-1-cezary.rojewski@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mateusz Gorski commit 2d744ecf2b98405723a2138a547e5c75009bc4e5 upstream. Automatically choose DMIC pipeline format configuration depending on information included in NHLT. Change the access rights of appropriate kcontrols to read-only in order to prevent user interference. Signed-off-by: Mateusz Gorski Reviewed-by: Cezary Rojewski Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20200427132727.24942-4-mateusz.gorski@linux.intel.com Signed-off-by: Mark Brown Cc: # 5.4.x --- include/uapi/sound/skl-tplg-interface.h | 1 + sound/soc/intel/skylake/skl-topology.c | 64 +++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/include/uapi/sound/skl-tplg-interface.h b/include/uapi/sound/skl-tplg-interface.h index f2711186c81f..a93c0decfdd5 100644 --- a/include/uapi/sound/skl-tplg-interface.h +++ b/include/uapi/sound/skl-tplg-interface.h @@ -19,6 +19,7 @@ #define SKL_CONTROL_TYPE_BYTE_TLV 0x100 #define SKL_CONTROL_TYPE_MIC_SELECT 0x102 #define SKL_CONTROL_TYPE_MULTI_IO_SELECT 0x103 +#define SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC 0x104 #define HDA_SST_CFG_MAX 900 /* size of copier cfg*/ #define MAX_IN_QUEUE 8 diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index c9cd6d60d57b..aa5833001fde 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -1405,6 +1405,18 @@ static int skl_tplg_multi_config_set(struct snd_kcontrol *kcontrol, return skl_tplg_multi_config_set_get(kcontrol, ucontrol, true); } +static int skl_tplg_multi_config_get_dmic(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return skl_tplg_multi_config_set_get(kcontrol, ucontrol, false); +} + +static int skl_tplg_multi_config_set_dmic(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return skl_tplg_multi_config_set_get(kcontrol, ucontrol, true); +} + static int skl_tplg_tlv_control_get(struct snd_kcontrol *kcontrol, unsigned int __user *data, unsigned int size) { @@ -1949,6 +1961,11 @@ static const struct snd_soc_tplg_kcontrol_ops skl_tplg_kcontrol_ops[] = { .get = skl_tplg_multi_config_get, .put = skl_tplg_multi_config_set, }, + { + .id = SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC, + .get = skl_tplg_multi_config_get_dmic, + .put = skl_tplg_multi_config_set_dmic, + } }; static int skl_tplg_fill_pipe_cfg(struct device *dev, @@ -3109,12 +3126,21 @@ static int skl_tplg_control_load(struct snd_soc_component *cmpnt, case SND_SOC_TPLG_CTL_ENUM: tplg_ec = container_of(hdr, struct snd_soc_tplg_enum_control, hdr); - if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READWRITE) { + if (kctl->access & SNDRV_CTL_ELEM_ACCESS_READ) { se = (struct soc_enum *)kctl->private_value; if (tplg_ec->priv.size) - return skl_init_enum_data(bus->dev, se, - tplg_ec); + skl_init_enum_data(bus->dev, se, tplg_ec); } + + /* + * now that the control initializations are done, remove + * write permission for the DMIC configuration enums to + * avoid conflicts between NHLT settings and user interaction + */ + + if (hdr->ops.get == SKL_CONTROL_TYPE_MULTI_IO_SELECT_DMIC) + kctl->access = SNDRV_CTL_ELEM_ACCESS_READ; + break; default: @@ -3584,6 +3610,37 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index, return 0; } +static void skl_tplg_complete(struct snd_soc_component *component) +{ + struct snd_soc_dobj *dobj; + struct snd_soc_acpi_mach *mach = + dev_get_platdata(component->card->dev); + int i; + + list_for_each_entry(dobj, &component->dobj_list, list) { + struct snd_kcontrol *kcontrol = dobj->control.kcontrol; + struct soc_enum *se = + (struct soc_enum *)kcontrol->private_value; + char **texts = dobj->control.dtexts; + char chan_text[4]; + + if (dobj->type != SND_SOC_DOBJ_ENUM || + dobj->control.kcontrol->put != + skl_tplg_multi_config_set_dmic) + continue; + sprintf(chan_text, "c%d", mach->mach_params.dmic_num); + + for (i = 0; i < se->items; i++) { + struct snd_ctl_elem_value val; + + if (strstr(texts[i], chan_text)) { + val.value.enumerated.item[0] = i; + kcontrol->put(kcontrol, &val); + } + } + } +} + static struct snd_soc_tplg_ops skl_tplg_ops = { .widget_load = skl_tplg_widget_load, .control_load = skl_tplg_control_load, @@ -3593,6 +3650,7 @@ static struct snd_soc_tplg_ops skl_tplg_ops = { .io_ops_count = ARRAY_SIZE(skl_tplg_kcontrol_ops), .manifest = skl_manifest_load, .dai_load = skl_dai_load, + .complete = skl_tplg_complete, }; /* -- 2.17.1