From patchwork Fri Oct 15 16:40:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 12562519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DCC3C433F5 for ; Fri, 15 Oct 2021 16:40:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4676F61151 for ; Fri, 15 Oct 2021 16:40:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4676F61151 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 66091183A; Fri, 15 Oct 2021 18:39:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 66091183A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634316001; bh=IzaNeADeFu7AszlRHuC3vFDJ/MAeCPRCIeUSQZgsJhs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=vMCbgYiHwdruA09Klky+2ddPGzCHlJHivagJYwC5G/x33yZqgVdTmnreQqkOaZSen G3jTPLQo8tWDmPGfpX75lGm9/fjrYOyuakfC8oF+APQ6Yd9XRUMmgld+3CdoEBM5aC 5L9GUqXpt4kQ+FAwgFDz8dyMLo9j5vsbNZAlxq5Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C78F4F804AC; Fri, 15 Oct 2021 18:38:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6F26CF804AC; Fri, 15 Oct 2021 18:38:31 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6A4B4F80167 for ; Fri, 15 Oct 2021 18:38:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6A4B4F80167 X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="251395120" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="251395120" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 09:38:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="593028300" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga004.jf.intel.com with ESMTP; 15 Oct 2021 09:38:18 -0700 From: Cezary Rojewski To: alsa-devel@alsa-project.org Subject: [PATCH 1/5] ALSA: hda: Drop device-argument in NHLT functions Date: Fri, 15 Oct 2021 18:40:43 +0200 Message-Id: <20211015164047.44492-2-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015164047.44492-1-cezary.rojewski@intel.com> References: <20211015164047.44492-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, Cezary Rojewski , tiwai@suse.com, hdegoede@redhat.com, broonie@kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi?= =?utf-8?q?=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Amadeusz Sławiński ACPI is device independent, so printing warnings using device functions is misleading. Replace dev_xxx() with pr_xxx() and remove now unnecessary argument. Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- include/sound/intel-nhlt.h | 9 ++++----- sound/hda/intel-dsp-config.c | 4 ++-- sound/hda/intel-nhlt.c | 24 +++++++++++++----------- sound/soc/intel/skylake/skl.c | 5 ++--- sound/soc/sof/intel/hda.c | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/sound/intel-nhlt.h b/include/sound/intel-nhlt.h index d0574805865f..4debab7c1996 100644 --- a/include/sound/intel-nhlt.h +++ b/include/sound/intel-nhlt.h @@ -126,17 +126,17 @@ enum { NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf, }; -struct nhlt_acpi_table *intel_nhlt_init(struct device *dev); +struct nhlt_acpi_table *intel_nhlt_init(void); void intel_nhlt_free(struct nhlt_acpi_table *addr); -int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt); +int intel_nhlt_get_dmic_geo(struct nhlt_acpi_table *nhlt); #else struct nhlt_acpi_table; -static inline struct nhlt_acpi_table *intel_nhlt_init(struct device *dev) +static inline struct nhlt_acpi_table *intel_nhlt_init(void) { return NULL; } @@ -145,8 +145,7 @@ static inline void intel_nhlt_free(struct nhlt_acpi_table *addr) { } -static inline int intel_nhlt_get_dmic_geo(struct device *dev, - struct nhlt_acpi_table *nhlt) +static inline int intel_nhlt_get_dmic_geo(struct nhlt_acpi_table *nhlt) { return 0; } diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c index b9ac9e9e45a4..60cc4735c6ec 100644 --- a/sound/hda/intel-dsp-config.c +++ b/sound/hda/intel-dsp-config.c @@ -382,9 +382,9 @@ static int snd_intel_dsp_check_dmic(struct pci_dev *pci) struct nhlt_acpi_table *nhlt; int ret = 0; - nhlt = intel_nhlt_init(&pci->dev); + nhlt = intel_nhlt_init(); if (nhlt) { - if (intel_nhlt_get_dmic_geo(&pci->dev, nhlt)) + if (intel_nhlt_get_dmic_geo(nhlt)) ret = 1; intel_nhlt_free(nhlt); } diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c index e2237239d922..195d9e193a6c 100644 --- a/sound/hda/intel-nhlt.c +++ b/sound/hda/intel-nhlt.c @@ -1,10 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only // Copyright (c) 2015-2019 Intel Corporation +#define pr_fmt(fmt) "NHLT: " fmt + #include #include -struct nhlt_acpi_table *intel_nhlt_init(struct device *dev) +struct nhlt_acpi_table *intel_nhlt_init(void) { struct nhlt_acpi_table *nhlt; acpi_status status; @@ -12,7 +14,7 @@ struct nhlt_acpi_table *intel_nhlt_init(struct device *dev) status = acpi_get_table(ACPI_SIG_NHLT, 0, (struct acpi_table_header **)&nhlt); if (ACPI_FAILURE(status)) { - dev_warn(dev, "NHLT table not found\n"); + pr_warn("NHLT table not found\n"); return NULL; } @@ -26,7 +28,7 @@ void intel_nhlt_free(struct nhlt_acpi_table *nhlt) } EXPORT_SYMBOL_GPL(intel_nhlt_free); -int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) +int intel_nhlt_get_dmic_geo(struct nhlt_acpi_table *nhlt) { struct nhlt_endpoint *epnt; struct nhlt_dmic_array_config *cfg; @@ -40,7 +42,7 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) return 0; if (nhlt->header.length <= sizeof(struct acpi_table_header)) { - dev_warn(dev, "Invalid DMIC description table\n"); + pr_warn("Invalid DMIC description table\n"); return 0; } @@ -55,7 +57,7 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) /* find max number of channels based on format_configuration */ if (fmt_configs->fmt_count) { - dev_dbg(dev, "%s: found %d format definitions\n", + pr_debug("%s: found %d format definitions\n", __func__, fmt_configs->fmt_count); for (i = 0; i < fmt_configs->fmt_count; i++) { @@ -66,9 +68,9 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) if (fmt_ext->fmt.channels > max_ch) max_ch = fmt_ext->fmt.channels; } - dev_dbg(dev, "%s: max channels found %d\n", __func__, max_ch); + pr_debug("%s: max channels found %d\n", __func__, max_ch); } else { - dev_dbg(dev, "%s: No format information found\n", __func__); + pr_debug("%s: No format information found\n", __func__); } if (cfg->device_config.config_type != NHLT_CONFIG_TYPE_MIC_ARRAY) { @@ -90,21 +92,21 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) dmic_geo = cfg_vendor->nb_mics; break; default: - dev_warn(dev, "%s: undefined DMIC array_type 0x%0x\n", + pr_warn("%s: undefined DMIC array_type 0x%0x\n", __func__, cfg->array_type); } if (dmic_geo > 0) { - dev_dbg(dev, "%s: Array with %d dmics\n", __func__, dmic_geo); + pr_debug("%s: Array with %d dmics\n", __func__, dmic_geo); } if (max_ch > dmic_geo) { - dev_dbg(dev, "%s: max channels %d exceed dmic number %d\n", + pr_debug("%s: max channels %d exceed dmic number %d\n", __func__, max_ch, dmic_geo); } } } - dev_dbg(dev, "%s: dmic number %d max_ch %d\n", + pr_debug("%s: dmic number %d max_ch %d\n", __func__, dmic_geo, max_ch); return dmic_geo; diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 5b1a15e39912..4f122616b636 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -517,8 +517,7 @@ static int skl_find_machine(struct skl_dev *skl, void *driver_data) if (pdata) { skl->use_tplg_pcm = pdata->use_tplg_pcm; mach->mach_params.dmic_num = - intel_nhlt_get_dmic_geo(&skl->pci->dev, - skl->nhlt); + intel_nhlt_get_dmic_geo(skl->nhlt); } return 0; @@ -1009,7 +1008,7 @@ static int skl_probe(struct pci_dev *pci, device_disable_async_suspend(bus->dev); - skl->nhlt = intel_nhlt_init(bus->dev); + skl->nhlt = intel_nhlt_init(); if (skl->nhlt == NULL) { #if !IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 883d78dd01b5..75c2ee91bf13 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -651,9 +651,9 @@ static int check_nhlt_dmic(struct snd_sof_dev *sdev) struct nhlt_acpi_table *nhlt; int dmic_num; - nhlt = intel_nhlt_init(sdev->dev); + nhlt = intel_nhlt_init(); if (nhlt) { - dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt); + dmic_num = intel_nhlt_get_dmic_geo(nhlt); intel_nhlt_free(nhlt); if (dmic_num >= 1 && dmic_num <= 4) return dmic_num; From patchwork Fri Oct 15 16:40:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 12562525 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAC4FC433EF for ; Fri, 15 Oct 2021 16:41:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 430A461151 for ; Fri, 15 Oct 2021 16:41:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 430A461151 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A1A3B1867; Fri, 15 Oct 2021 18:40:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A1A3B1867 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634316062; bh=8Smh5yXFplWLesflgbp6ZjhKHteXKR8sMQyDur2s0mU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gXZSkK0rtRMeJGDRVXcka/GcsRSmWHVpiINxQTjGCtqTcvjP/7e6Z8mZgxzVQ47nR qfp9bvIwiD4HFQGIk2VxUXhZO3XytZQvL4W/S5w8VSU32qtHRPZFpkjSULlyhmbOq6 OMJghFqzIcDcVfwnAK04H2IiZBncQKxaq6DGkCeg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 53F02F804FD; Fri, 15 Oct 2021 18:38:40 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E60E8F804FE; Fri, 15 Oct 2021 18:38:38 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D2343F80269 for ; Fri, 15 Oct 2021 18:38:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D2343F80269 X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="251395125" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="251395125" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 09:38:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="593028312" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga004.jf.intel.com with ESMTP; 15 Oct 2021 09:38:21 -0700 From: Cezary Rojewski To: alsa-devel@alsa-project.org Subject: [PATCH 2/5] ALSA: hda: Follow ACPI convention in NHLT struct naming Date: Fri, 15 Oct 2021 18:40:44 +0200 Message-Id: <20211015164047.44492-3-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015164047.44492-1-cezary.rojewski@intel.com> References: <20211015164047.44492-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, Cezary Rojewski , tiwai@suse.com, hdegoede@redhat.com, broonie@kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi?= =?utf-8?q?=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Amadeusz Sławiński All ACPI table structs except for NHLT ones are defined in postfix way. Update NHLT structs naming to make code cohesive. Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski --- include/sound/intel-nhlt.h | 16 ++++++++-------- sound/hda/intel-dsp-config.c | 2 +- sound/hda/intel-nhlt.c | 8 ++++---- sound/soc/intel/skylake/skl-nhlt.c | 8 ++++---- sound/soc/intel/skylake/skl.h | 2 +- sound/soc/sof/intel/hda.c | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/sound/intel-nhlt.h b/include/sound/intel-nhlt.h index 4debab7c1996..b7eec4b3ca01 100644 --- a/include/sound/intel-nhlt.h +++ b/include/sound/intel-nhlt.h @@ -77,7 +77,7 @@ struct nhlt_endpoint { struct nhlt_specific_cfg config; } __packed; -struct nhlt_acpi_table { +struct acpi_table_nhlt { struct acpi_table_header header; u8 endpoint_count; struct nhlt_endpoint desc[]; @@ -126,26 +126,26 @@ enum { NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf, }; -struct nhlt_acpi_table *intel_nhlt_init(void); +struct acpi_table_nhlt *intel_nhlt_init(void); -void intel_nhlt_free(struct nhlt_acpi_table *addr); +void intel_nhlt_free(struct acpi_table_nhlt *addr); -int intel_nhlt_get_dmic_geo(struct nhlt_acpi_table *nhlt); +int intel_nhlt_get_dmic_geo(struct acpi_table_nhlt *nhlt); #else -struct nhlt_acpi_table; +struct acpi_table_nhlt; -static inline struct nhlt_acpi_table *intel_nhlt_init(void) +static inline struct acpi_table_nhlt *intel_nhlt_init(void) { return NULL; } -static inline void intel_nhlt_free(struct nhlt_acpi_table *addr) +static inline void intel_nhlt_free(struct acpi_table_nhlt *addr) { } -static inline int intel_nhlt_get_dmic_geo(struct nhlt_acpi_table *nhlt) +static inline int intel_nhlt_get_dmic_geo(struct acpi_table_nhlt *nhlt) { return 0; } diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c index 60cc4735c6ec..4c9d5bc39cbd 100644 --- a/sound/hda/intel-dsp-config.c +++ b/sound/hda/intel-dsp-config.c @@ -379,7 +379,7 @@ static const struct config_entry *snd_intel_dsp_find_config static int snd_intel_dsp_check_dmic(struct pci_dev *pci) { - struct nhlt_acpi_table *nhlt; + struct acpi_table_nhlt *nhlt; int ret = 0; nhlt = intel_nhlt_init(); diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c index 195d9e193a6c..c41d20e1b349 100644 --- a/sound/hda/intel-nhlt.c +++ b/sound/hda/intel-nhlt.c @@ -6,9 +6,9 @@ #include #include -struct nhlt_acpi_table *intel_nhlt_init(void) +struct acpi_table_nhlt *intel_nhlt_init(void) { - struct nhlt_acpi_table *nhlt; + struct acpi_table_nhlt *nhlt; acpi_status status; status = acpi_get_table(ACPI_SIG_NHLT, 0, @@ -22,13 +22,13 @@ struct nhlt_acpi_table *intel_nhlt_init(void) } EXPORT_SYMBOL_GPL(intel_nhlt_init); -void intel_nhlt_free(struct nhlt_acpi_table *nhlt) +void intel_nhlt_free(struct acpi_table_nhlt *nhlt) { acpi_put_table((struct acpi_table_header *)nhlt); } EXPORT_SYMBOL_GPL(intel_nhlt_free); -int intel_nhlt_get_dmic_geo(struct nhlt_acpi_table *nhlt) +int intel_nhlt_get_dmic_geo(struct acpi_table_nhlt *nhlt) { struct nhlt_endpoint *epnt; struct nhlt_dmic_array_config *cfg; diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c index 64226072f0ee..3033c1bf279f 100644 --- a/sound/soc/intel/skylake/skl-nhlt.c +++ b/sound/soc/intel/skylake/skl-nhlt.c @@ -88,7 +88,7 @@ struct nhlt_specific_cfg struct hdac_bus *bus = skl_to_bus(skl); struct device *dev = bus->dev; struct nhlt_specific_cfg *sp_config; - struct nhlt_acpi_table *nhlt = skl->nhlt; + struct acpi_table_nhlt *nhlt = skl->nhlt; u16 bps = (s_fmt == 16) ? 16 : 32; u8 j; @@ -132,7 +132,7 @@ static void skl_nhlt_trim_space(char *trim) int skl_nhlt_update_topology_bin(struct skl_dev *skl) { - struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; + struct acpi_table_nhlt *nhlt = (struct acpi_table_nhlt *)skl->nhlt; struct hdac_bus *bus = skl_to_bus(skl); struct device *dev = bus->dev; @@ -155,7 +155,7 @@ static ssize_t platform_id_show(struct device *dev, struct pci_dev *pci = to_pci_dev(dev); struct hdac_bus *bus = pci_get_drvdata(pci); struct skl_dev *skl = bus_to_skl(bus); - struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; + struct acpi_table_nhlt *nhlt = (struct acpi_table_nhlt *)skl->nhlt; char platform_id[32]; sprintf(platform_id, "%x-%.6s-%.8s-%d", skl->pci_id, @@ -335,7 +335,7 @@ static void skl_get_mclk(struct skl_dev *skl, struct skl_ssp_clk *mclk, void skl_get_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks) { - struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; + struct acpi_table_nhlt *nhlt = (struct acpi_table_nhlt *)skl->nhlt; struct nhlt_endpoint *epnt; struct nhlt_fmt *fmt; int i; diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 33ed274fc0cb..37195aafbf27 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -67,7 +67,7 @@ struct skl_dev { struct snd_soc_component *component; struct snd_soc_dai_driver *dais; - struct nhlt_acpi_table *nhlt; /* nhlt ptr */ + struct acpi_table_nhlt *nhlt; /* nhlt ptr */ struct list_head ppl_list; struct list_head bind_list; diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 75c2ee91bf13..4a8907fe7f94 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -648,7 +648,7 @@ static int hda_init(struct snd_sof_dev *sdev) static int check_nhlt_dmic(struct snd_sof_dev *sdev) { - struct nhlt_acpi_table *nhlt; + struct acpi_table_nhlt *nhlt; int dmic_num; nhlt = intel_nhlt_init(); From patchwork Fri Oct 15 16:40:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 12562521 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 748D4C433F5 for ; Fri, 15 Oct 2021 16:40:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE46A60C41 for ; Fri, 15 Oct 2021 16:40:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AE46A60C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F06A1184E; Fri, 15 Oct 2021 18:39:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F06A1184E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634316012; bh=vBv8h08pcv0K3Ul+JXhrfgjcDY7YInmhghYlhZraNZ8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Y7YHsrTXUJ4oSCijWrtcaK34v5URUzQwIBvcqfgxdBMmFYD8ZmaEDfARBVWR7d9hi M+PeTV0EqUhfC+QtxcnjsqlBq4kUsTEhGvbIpMlwrfg6nSiWO5Q9KjekU/4qapksZm +SAugRGnFJQatcLbI9IzOlgKLCjXTMdN8KVBFkKU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ABCDFF804E6; Fri, 15 Oct 2021 18:38:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C077FF8025B; Fri, 15 Oct 2021 18:38:33 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C8E9EF8025B for ; Fri, 15 Oct 2021 18:38:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C8E9EF8025B X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="251395136" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="251395136" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 09:38:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="593028326" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga004.jf.intel.com with ESMTP; 15 Oct 2021 09:38:23 -0700 From: Cezary Rojewski To: alsa-devel@alsa-project.org Subject: [PATCH 3/5] ALSA: hda: Fill gaps in NHLT endpoint-interface Date: Fri, 15 Oct 2021 18:40:45 +0200 Message-Id: <20211015164047.44492-4-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015164047.44492-1-cezary.rojewski@intel.com> References: <20211015164047.44492-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, Cezary Rojewski , tiwai@suse.com, hdegoede@redhat.com, broonie@kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi?= =?utf-8?q?=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Amadeusz Sławiński Two key operations missings are: endpoint presence-check and retrieval of matching endpoint hardware configuration (blob). Add operations for both use cases. Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski Reported-by: kernel test robot --- include/sound/intel-nhlt.h | 20 ++++++++ sound/hda/intel-nhlt.c | 99 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/include/sound/intel-nhlt.h b/include/sound/intel-nhlt.h index b7eec4b3ca01..2cd3f27b7a72 100644 --- a/include/sound/intel-nhlt.h +++ b/include/sound/intel-nhlt.h @@ -132,6 +132,12 @@ void intel_nhlt_free(struct acpi_table_nhlt *addr); int intel_nhlt_get_dmic_geo(struct acpi_table_nhlt *nhlt); +bool intel_nhlt_has_endpoint_type(struct acpi_table_nhlt *nhlt, u8 link_type); +struct nhlt_specific_cfg * +intel_nhlt_get_endpoint_blob(struct acpi_table_nhlt *nhlt, + u32 bus_id, u8 link_type, u8 vbps, u8 bps, + u8 num_ch, u32 rate, u8 dir, u8 dev_type); + #else struct acpi_table_nhlt; @@ -149,6 +155,20 @@ static inline int intel_nhlt_get_dmic_geo(struct acpi_table_nhlt *nhlt) { return 0; } + +bool intel_nhlt_has_endpoint_type(struct acpi_table_nhlt *nhlt, u8 link_type) +{ + return false; +} + +struct nhlt_specific_cfg * +intel_nhlt_get_endpoint_blob(struct acpi_table_nhlt *nhlt, + u32 bus_id, u8 link_type, u8 vbps, u8 bps, + u8 num_ch, u32 rate, u8 dir, u8 dev_type) +{ + return NULL; +} + #endif #endif diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c index c41d20e1b349..d97fe57a7ef2 100644 --- a/sound/hda/intel-nhlt.c +++ b/sound/hda/intel-nhlt.c @@ -112,3 +112,102 @@ int intel_nhlt_get_dmic_geo(struct acpi_table_nhlt *nhlt) return dmic_geo; } EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo); + +bool intel_nhlt_has_endpoint_type(struct acpi_table_nhlt *nhlt, u8 link_type) +{ + struct nhlt_endpoint *epnt; + int i; + + if (!nhlt) + return false; + + epnt = (struct nhlt_endpoint *)nhlt->desc; + for (i = 0; i < nhlt->endpoint_count; i++) { + if (epnt->linktype == link_type) + return true; + + epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); + } + return false; +} +EXPORT_SYMBOL(intel_nhlt_has_endpoint_type); + +static struct nhlt_specific_cfg * +nhlt_get_specific_cfg(struct nhlt_fmt *fmt, u8 num_ch, u32 rate, u8 vbps, u8 bps) +{ + struct nhlt_fmt_cfg *cfg = fmt->fmt_config; + struct wav_fmt *wfmt; + u16 _bps, _vbps; + int i; + + pr_debug("Endpoint format count=%d\n", fmt->fmt_count); + + for (i = 0; i < fmt->fmt_count; i++) { + wfmt = &cfg->fmt_ext.fmt; + _bps = wfmt->bits_per_sample; + _vbps = cfg->fmt_ext.sample.valid_bits_per_sample; + + pr_debug("Endpoint format: ch=%d fmt=%d/%d rate=%d\n", + wfmt->channels, _vbps, _bps, wfmt->samples_per_sec); + + if (wfmt->channels == num_ch && wfmt->samples_per_sec == rate && + vbps == _vbps && bps == _bps) + return &cfg->config; + + cfg = (struct nhlt_fmt_cfg *)(cfg->config.caps + cfg->config.size); + } + + return NULL; +} + +static bool nhlt_check_ep_match(struct nhlt_endpoint *epnt, + u32 bus_id, u8 link_type, u8 dir, u8 dev_type) +{ + pr_debug("Endpoint: vbus_id=%d link_type=%d dir=%d dev_type = %d\n", + epnt->virtual_bus_id, epnt->linktype, + epnt->direction, epnt->device_type); + + if ((epnt->virtual_bus_id != bus_id) || + (epnt->linktype != link_type) || + (epnt->direction != dir)) + return false; + + /* link of type DMIC bypasses device_type check */ + return epnt->linktype == NHLT_LINK_DMIC || + epnt->device_type == dev_type; +} + +struct nhlt_specific_cfg * +intel_nhlt_get_endpoint_blob(struct acpi_table_nhlt *nhlt, + u32 bus_id, u8 link_type, u8 vbps, u8 bps, + u8 num_ch, u32 rate, u8 dir, u8 dev_type) +{ + struct nhlt_specific_cfg *cfg; + struct nhlt_endpoint *epnt; + struct nhlt_fmt *fmt; + int i; + + if (!nhlt) + return NULL; + + pr_debug("Looking for configuration:\n"); + pr_debug(" vbus_id=%d link_type=%d dir=%d, dev_type=%d\n", + bus_id, link_type, dir, dev_type); + pr_debug(" ch=%d fmt=%d/%d rate=%d\n", num_ch, vbps, bps, rate); + pr_debug("Endpoint count=%d\n", nhlt->endpoint_count); + + epnt = (struct nhlt_endpoint *)nhlt->desc; + for (i = 0; i < nhlt->endpoint_count; i++) { + if (nhlt_check_ep_match(epnt, bus_id, link_type, dir, dev_type)) { + fmt = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size); + cfg = nhlt_get_specific_cfg(fmt, num_ch, rate, vbps, bps); + if (cfg) + return cfg; + } + + epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); + } + + return NULL; +} +EXPORT_SYMBOL(intel_nhlt_get_endpoint_blob); From patchwork Fri Oct 15 16:40:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 12562523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F45EC433F5 for ; Fri, 15 Oct 2021 16:40:45 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A59160E0C for ; Fri, 15 Oct 2021 16:40:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4A59160E0C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8CCE11865; Fri, 15 Oct 2021 18:39:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8CCE11865 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634316042; bh=MKpvxJlUeDFzDhk7ngCxxqKAK3ALRWuMHqH1/zzhY4w=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Tx2X1sKX2XNfHYCTS9MI38h3YWZU5QJNf87uW/Wy62Wjyo7Gzr5IUFpWQka/S3K5K ns177MhSywd5wWbDMpg6lqbDPtNC50/T9v22cEbfTMLYX8SeNYwnlS8A2C13TXCYqr i50mI+FLLihHOcaXo4y3AdXarkgYmCI0+loiYnGg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 94A53F804FB; Fri, 15 Oct 2021 18:38:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C51DFF804ED; Fri, 15 Oct 2021 18:38:36 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E7F32F8016C for ; Fri, 15 Oct 2021 18:38:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E7F32F8016C X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="251395145" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="251395145" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 09:38:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="593028341" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga004.jf.intel.com with ESMTP; 15 Oct 2021 09:38:26 -0700 From: Cezary Rojewski To: alsa-devel@alsa-project.org Subject: [PATCH 4/5] ALSA: hda: Simplify DMIC-in-NHLT check Date: Fri, 15 Oct 2021 18:40:46 +0200 Message-Id: <20211015164047.44492-5-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015164047.44492-1-cezary.rojewski@intel.com> References: <20211015164047.44492-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, Cezary Rojewski , tiwai@suse.com, hdegoede@redhat.com, broonie@kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi?= =?utf-8?q?=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Amadeusz Sławiński Only DMIC endpoint presence is relevant, not its configuration. Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski Reported-by: kernel test robot --- sound/hda/intel-dsp-config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/hda/intel-dsp-config.c b/sound/hda/intel-dsp-config.c index 4c9d5bc39cbd..e8fc5557436b 100644 --- a/sound/hda/intel-dsp-config.c +++ b/sound/hda/intel-dsp-config.c @@ -384,7 +384,7 @@ static int snd_intel_dsp_check_dmic(struct pci_dev *pci) nhlt = intel_nhlt_init(); if (nhlt) { - if (intel_nhlt_get_dmic_geo(nhlt)) + if (intel_nhlt_has_endpoint_type(nhlt, NHLT_LINK_DMIC)) ret = 1; intel_nhlt_free(nhlt); } From patchwork Fri Oct 15 16:40:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 12562527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6B88C433EF for ; Fri, 15 Oct 2021 16:41:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45BD960E0C for ; Fri, 15 Oct 2021 16:41:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 45BD960E0C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A6B941872; Fri, 15 Oct 2021 18:40:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A6B941872 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1634316076; bh=BG7T7D4c5TGIEGwuRRDnJwlEMr4wIpUJGZDR5MpsKbI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KCAUTlZkICCaifnIzJeHdgLWbRmWV5qD/Spov1eQ8siLJ98LS4pO+ks3B2uAKLJVp HqzC2Jnygy3eKThBP+6MOY3J6KJnP0rm9Ag9Yng6RZoHsCnjkv4PCybIZkd1uCi2GE sNo+Zbvtkvd6n/SXAJx+652mfqHsU4bYto+aarZo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3D17AF80507; Fri, 15 Oct 2021 18:38:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9A511F804FE; Fri, 15 Oct 2021 18:38:39 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 291CBF80167 for ; Fri, 15 Oct 2021 18:38:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 291CBF80167 X-IronPort-AV: E=McAfee;i="6200,9189,10138"; a="251395149" X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="251395149" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 09:38:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,376,1624345200"; d="scan'208";a="593028370" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga004.jf.intel.com with ESMTP; 15 Oct 2021 09:38:28 -0700 From: Cezary Rojewski To: alsa-devel@alsa-project.org Subject: [PATCH 5/5] ASoC: Intel: Skylake: Use NHLT API to search for blob Date: Fri, 15 Oct 2021 18:40:47 +0200 Message-Id: <20211015164047.44492-6-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015164047.44492-1-cezary.rojewski@intel.com> References: <20211015164047.44492-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Cc: pierre-louis.bossart@linux.intel.com, Cezary Rojewski , tiwai@suse.com, hdegoede@redhat.com, broonie@kernel.org, =?utf-8?q?Amadeusz_S=C5=82awi?= =?utf-8?q?=C5=84ski?= X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Amadeusz Sławiński With NHLT enriched with new search functions, remove local code in favour of them. This also fixes broken behaviour: search should be based on significant bits count rather than container size. Signed-off-by: Amadeusz Sławiński Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/intel/skylake/skl-nhlt.c | 102 ------------------------- sound/soc/intel/skylake/skl-pcm.c | 3 + sound/soc/intel/skylake/skl-topology.c | 27 ++++--- sound/soc/intel/skylake/skl-topology.h | 1 + sound/soc/intel/skylake/skl.h | 4 - 5 files changed, 19 insertions(+), 118 deletions(-) diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c index 3033c1bf279f..16f70554b2a0 100644 --- a/sound/soc/intel/skylake/skl-nhlt.c +++ b/sound/soc/intel/skylake/skl-nhlt.c @@ -13,108 +13,6 @@ #include "skl.h" #include "skl-i2s.h" -static struct nhlt_specific_cfg *skl_get_specific_cfg( - struct device *dev, struct nhlt_fmt *fmt, - u8 no_ch, u32 rate, u16 bps, u8 linktype) -{ - struct nhlt_specific_cfg *sp_config; - struct wav_fmt *wfmt; - struct nhlt_fmt_cfg *fmt_config = fmt->fmt_config; - int i; - - dev_dbg(dev, "Format count =%d\n", fmt->fmt_count); - - for (i = 0; i < fmt->fmt_count; i++) { - wfmt = &fmt_config->fmt_ext.fmt; - dev_dbg(dev, "ch=%d fmt=%d s_rate=%d\n", wfmt->channels, - wfmt->bits_per_sample, wfmt->samples_per_sec); - if (wfmt->channels == no_ch && wfmt->bits_per_sample == bps) { - /* - * if link type is dmic ignore rate check as the blob is - * generic for all rates - */ - sp_config = &fmt_config->config; - if (linktype == NHLT_LINK_DMIC) - return sp_config; - - if (wfmt->samples_per_sec == rate) - return sp_config; - } - - fmt_config = (struct nhlt_fmt_cfg *)(fmt_config->config.caps + - fmt_config->config.size); - } - - return NULL; -} - -static void dump_config(struct device *dev, u32 instance_id, u8 linktype, - u8 s_fmt, u8 num_channels, u32 s_rate, u8 dirn, u16 bps) -{ - dev_dbg(dev, "Input configuration\n"); - dev_dbg(dev, "ch=%d fmt=%d s_rate=%d\n", num_channels, s_fmt, s_rate); - dev_dbg(dev, "vbus_id=%d link_type=%d\n", instance_id, linktype); - dev_dbg(dev, "bits_per_sample=%d\n", bps); -} - -static bool skl_check_ep_match(struct device *dev, struct nhlt_endpoint *epnt, - u32 instance_id, u8 link_type, u8 dirn, u8 dev_type) -{ - dev_dbg(dev, "vbus_id=%d link_type=%d dir=%d dev_type = %d\n", - epnt->virtual_bus_id, epnt->linktype, - epnt->direction, epnt->device_type); - - if ((epnt->virtual_bus_id == instance_id) && - (epnt->linktype == link_type) && - (epnt->direction == dirn)) { - /* do not check dev_type for DMIC link type */ - if (epnt->linktype == NHLT_LINK_DMIC) - return true; - - if (epnt->device_type == dev_type) - return true; - } - - return false; -} - -struct nhlt_specific_cfg -*skl_get_ep_blob(struct skl_dev *skl, u32 instance, u8 link_type, - u8 s_fmt, u8 num_ch, u32 s_rate, - u8 dirn, u8 dev_type) -{ - struct nhlt_fmt *fmt; - struct nhlt_endpoint *epnt; - struct hdac_bus *bus = skl_to_bus(skl); - struct device *dev = bus->dev; - struct nhlt_specific_cfg *sp_config; - struct acpi_table_nhlt *nhlt = skl->nhlt; - u16 bps = (s_fmt == 16) ? 16 : 32; - u8 j; - - dump_config(dev, instance, link_type, s_fmt, num_ch, s_rate, dirn, bps); - - epnt = (struct nhlt_endpoint *)nhlt->desc; - - dev_dbg(dev, "endpoint count =%d\n", nhlt->endpoint_count); - - for (j = 0; j < nhlt->endpoint_count; j++) { - if (skl_check_ep_match(dev, epnt, instance, link_type, - dirn, dev_type)) { - fmt = (struct nhlt_fmt *)(epnt->config.caps + - epnt->config.size); - sp_config = skl_get_specific_cfg(dev, fmt, num_ch, - s_rate, bps, link_type); - if (sp_config) - return sp_config; - } - - epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); - } - - return NULL; -} - static void skl_nhlt_trim_space(char *trim) { char *s = trim; diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 9ecaf6a1e847..34908af50046 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -317,6 +317,7 @@ static int skl_pcm_hw_params(struct snd_pcm_substream *substream, dev_dbg(dai->dev, "dma_id=%d\n", dma_id); p_params.s_fmt = snd_pcm_format_width(params_format(params)); + p_params.s_cont = snd_pcm_format_physical_width(params_format(params)); p_params.ch = params_channels(params); p_params.s_freq = params_rate(params); p_params.host_dma_id = dma_id; @@ -405,6 +406,7 @@ static int skl_be_hw_params(struct snd_pcm_substream *substream, struct skl_pipe_params p_params = {0}; p_params.s_fmt = snd_pcm_format_width(params_format(params)); + p_params.s_cont = snd_pcm_format_physical_width(params_format(params)); p_params.ch = params_channels(params); p_params.s_freq = params_rate(params); p_params.stream = substream->stream; @@ -569,6 +571,7 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream, snd_soc_dai_set_tdm_slot(codec_dai, 0, stream_tag, 0, 0); p_params.s_fmt = snd_pcm_format_width(params_format(params)); + p_params.s_cont = snd_pcm_format_physical_width(params_format(params)); p_params.ch = params_channels(params); p_params.s_freq = params_rate(params); p_params.stream = substream->stream; diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 89e4231304dd..4a92f046925d 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -285,7 +285,7 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, { struct skl_module_cfg *m_cfg = w->priv; int link_type, dir; - u32 ch, s_freq, s_fmt; + u32 ch, s_freq, s_fmt, s_cont; struct nhlt_specific_cfg *cfg; u8 dev_type = skl_tplg_be_dev_type(m_cfg->dev_type); int fmt_idx = m_cfg->fmt_idx; @@ -301,7 +301,8 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, link_type = NHLT_LINK_DMIC; dir = SNDRV_PCM_STREAM_CAPTURE; s_freq = m_iface->inputs[0].fmt.s_freq; - s_fmt = m_iface->inputs[0].fmt.bit_depth; + s_fmt = m_iface->inputs[0].fmt.valid_bit_depth; + s_cont = m_iface->inputs[0].fmt.bit_depth; ch = m_iface->inputs[0].fmt.channels; break; @@ -310,12 +311,14 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, if (m_cfg->hw_conn_type == SKL_CONN_SOURCE) { dir = SNDRV_PCM_STREAM_PLAYBACK; s_freq = m_iface->outputs[0].fmt.s_freq; - s_fmt = m_iface->outputs[0].fmt.bit_depth; + s_fmt = m_iface->outputs[0].fmt.valid_bit_depth; + s_cont = m_iface->outputs[0].fmt.bit_depth; ch = m_iface->outputs[0].fmt.channels; } else { dir = SNDRV_PCM_STREAM_CAPTURE; s_freq = m_iface->inputs[0].fmt.s_freq; - s_fmt = m_iface->inputs[0].fmt.bit_depth; + s_fmt = m_iface->inputs[0].fmt.valid_bit_depth; + s_cont = m_iface->inputs[0].fmt.bit_depth; ch = m_iface->inputs[0].fmt.channels; } break; @@ -325,16 +328,16 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, } /* update the blob based on virtual bus_id and default params */ - cfg = skl_get_ep_blob(skl, m_cfg->vbus_id, link_type, - s_fmt, ch, s_freq, dir, dev_type); + cfg = intel_nhlt_get_endpoint_blob(skl->nhlt, m_cfg->vbus_id, link_type, + s_fmt, s_cont, ch, s_freq, dir, dev_type); if (cfg) { m_cfg->formats_config[SKL_PARAM_INIT].caps_size = cfg->size; m_cfg->formats_config[SKL_PARAM_INIT].caps = (u32 *)&cfg->caps; } else { dev_err(skl->dev, "Blob NULL for id %x type %d dirn %d\n", m_cfg->vbus_id, link_type, dir); - dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d\n", - ch, s_freq, s_fmt); + dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d/%d\n", + ch, s_freq, s_fmt, s_cont); return -EIO; } @@ -1849,10 +1852,10 @@ static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai, pipe_fmt = &pipe->configs[pipe->pipe_config_idx].in_fmt; /* update the blob based on virtual bus_id*/ - cfg = skl_get_ep_blob(skl, mconfig->vbus_id, link_type, - pipe_fmt->bps, pipe_fmt->channels, - pipe_fmt->freq, pipe->direction, - dev_type); + cfg = intel_nhlt_get_endpoint_blob(skl->nhlt, mconfig->vbus_id, link_type, + pipe_fmt->bps, params->s_cont, + pipe_fmt->channels, pipe_fmt->freq, + pipe->direction, dev_type); if (cfg) { mconfig->formats_config[SKL_PARAM_INIT].caps_size = cfg->size; mconfig->formats_config[SKL_PARAM_INIT].caps = (u32 *)&cfg->caps; diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index f0695b2ac5dd..22963634fbea 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -284,6 +284,7 @@ struct skl_pipe_params { u32 ch; u32 s_freq; u32 s_fmt; + u32 s_cont; u8 linktype; snd_pcm_format_t format; int link_index; diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 37195aafbf27..3b92dfc23731 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -165,10 +165,6 @@ struct skl_dsp_ops { int skl_platform_unregister(struct device *dev); int skl_platform_register(struct device *dev); -struct nhlt_specific_cfg *skl_get_ep_blob(struct skl_dev *skl, u32 instance, - u8 link_type, u8 s_fmt, u8 num_ch, - u32 s_rate, u8 dirn, u8 dev_type); - int skl_nhlt_update_topology_bin(struct skl_dev *skl); int skl_init_dsp(struct skl_dev *skl); int skl_free_dsp(struct skl_dev *skl);