From patchwork Wed Aug 23 08:05:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361768 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 111AEEE49A0 for ; Wed, 23 Aug 2023 08:10:02 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 00084A4E; Wed, 23 Aug 2023 10:09:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 00084A4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778200; bh=OJ576/1w9u7k81TtDQ7Kv6kMK9t0WXvYg95NJFotF0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Qx39K1HhJ1nY7c6jF2L7sCdssWmhx70vqwKByNHvC6YWZ4hqsoTcinZkxkOtBk++f WoH8OcismkK+ePeX9lRT+VbPz2wXlebD3lPcsNdzro5OsmqXaAU7/mqXH9meUohI07 957esIMG7SkqVHCCnfHMenhB2uPiN+WPx3WPQgLY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 28426F805AD; Wed, 23 Aug 2023 10:07:37 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3C453F805AC; Wed, 23 Aug 2023 10:07:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8ACA5F80537; Wed, 23 Aug 2023 10:06:34 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 1E975F80158 for ; Wed, 23 Aug 2023 10:06:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1E975F80158 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KMclLn5y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777971; x=1724313971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OJ576/1w9u7k81TtDQ7Kv6kMK9t0WXvYg95NJFotF0Q=; b=KMclLn5y/Wy1UEGdI2eX7N1BHuTdJGBUCBmKP7vdlzySQDPRPjnDRRBt txg9UxzI7eFw/6OkNR4zNF34EBOrFJCmTDLnnLebFHnYqTmqpY3SuyUmb 7H3+yLGn3nc9WBSzZbUs84+G9BK+nbsXr3bxzUmIF4i6IUK4IcSTZk2hx VQD+lpwz11KgYgpCz+5nbcT6+mZSrcwrdJeXzKl1yk+XJLaSOl37yVfd6 4QFcqN1z9o4rGQHwnEPj6s4CRWuHFHYEU5L718XSUwrzn+25ig0KgPAWJ NhD39R/C33j2BH3UtLOwK+kFqnrZh4cZGCClavlpLNHMR5eTkUu9JWWPr Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372987983" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372987983" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042635" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042635" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:05 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 01/17] ALSA: pcm: Introduce MSBITS subformat interface Date: Wed, 23 Aug 2023 10:05:30 +0200 Message-Id: <20230823080546.2224713-2-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: MBZVB2RXSXCYNXQ2B53ELGXY5UBWRVAY X-Message-ID-Hash: MBZVB2RXSXCYNXQ2B53ELGXY5UBWRVAY X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Improve granularity of format selection for S32/U32 formats by adding constants representing 20, 24 and 32 most significant bits. To make it easy for drivers to utilize those constants, introduce snd_pcm_subformat_width() and snd_pcm_hw_params_bps(). While the former is self-explanatory, the latter returns the bit-per-sample value based on format, subformat and msbits characteristics of the provided hw_params. Signed-off-by: Cezary Rojewski --- include/sound/pcm.h | 8 ++++++++ include/sound/pcm_params.h | 2 ++ include/uapi/sound/asound.h | 5 ++++- sound/core/pcm.c | 3 +++ sound/core/pcm_lib.c | 30 ++++++++++++++++++++++++++++++ sound/core/pcm_misc.c | 23 +++++++++++++++++++++++ tools/include/uapi/sound/asound.h | 5 ++++- 7 files changed, 74 insertions(+), 2 deletions(-) diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 19f564606ac4..f78441ff9d85 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -31,6 +31,7 @@ struct snd_pcm_hardware { unsigned int info; /* SNDRV_PCM_INFO_* */ u64 formats; /* SNDRV_PCM_FMTBIT_* */ + u64 subformats; /* SNDRV_PCM_SUBFMTBIT_* */ unsigned int rates; /* SNDRV_PCM_RATE_* */ unsigned int rate_min; /* min rate */ unsigned int rate_max; /* max rate */ @@ -219,6 +220,12 @@ struct snd_pcm_ops { #define SNDRV_PCM_FMTBIT_U20 SNDRV_PCM_FMTBIT_U20_BE #endif +#define _SNDRV_PCM_SUBFMTBIT(fmt) BIT((__force int)SNDRV_PCM_SUBFORMAT_##fmt) +#define SNDRV_PCM_SUBFMTBIT_STD _SNDRV_PCM_SUBFMTBIT(STD) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_20 _SNDRV_PCM_SUBFMTBIT(MSBITS_20) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_24 _SNDRV_PCM_SUBFMTBIT(MSBITS_24) +#define SNDRV_PCM_SUBFMTBIT_MSBITS_32 _SNDRV_PCM_SUBFMTBIT(MSBITS_32) + struct snd_pcm_file { struct snd_pcm_substream *substream; int no_compat_mmap; @@ -1130,6 +1137,7 @@ int snd_pcm_format_physical_width(snd_pcm_format_t format); /* in bits */ ssize_t snd_pcm_format_size(snd_pcm_format_t format, size_t samples); const unsigned char *snd_pcm_format_silence_64(snd_pcm_format_t format); int snd_pcm_format_set_silence(snd_pcm_format_t format, void *buf, unsigned int frames); +int snd_pcm_subformat_width(snd_pcm_subformat_t subformat); void snd_pcm_set_ops(struct snd_pcm * pcm, int direction, const struct snd_pcm_ops *ops); diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h index ba184f49f7e1..df17c7d3e853 100644 --- a/include/sound/pcm_params.h +++ b/include/sound/pcm_params.h @@ -362,6 +362,8 @@ static inline int params_physical_width(const struct snd_pcm_hw_params *p) return snd_pcm_format_physical_width(params_format(p)); } +int snd_pcm_hw_params_bps(const struct snd_pcm_hw_params *p); + static inline void params_set_format(struct snd_pcm_hw_params *p, snd_pcm_format_t fmt) { diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index f9939da41122..30a43541ed00 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -267,7 +267,10 @@ typedef int __bitwise snd_pcm_format_t; typedef int __bitwise snd_pcm_subformat_t; #define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0) -#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD +#define SNDRV_PCM_SUBFORMAT_MSBITS_20 ((__force snd_pcm_subformat_t) 1) +#define SNDRV_PCM_SUBFORMAT_MSBITS_24 ((__force snd_pcm_subformat_t) 2) +#define SNDRV_PCM_SUBFORMAT_MSBITS_32 ((__force snd_pcm_subformat_t) 3) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_MSBITS_32 #define SNDRV_PCM_INFO_MMAP 0x00000001 /* hardware supports mmap */ #define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 /* period data are valid during transfer */ diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 9d95e3731123..7900897ef036 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -265,6 +265,9 @@ static const char * const snd_pcm_access_names[] = { static const char * const snd_pcm_subformat_names[] = { SUBFORMAT(STD), + SUBFORMAT(MSBITS_20), + SUBFORMAT(MSBITS_24), + SUBFORMAT(MSBITS_32), }; static const char * const snd_pcm_tstamp_mode_names[] = { diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 9c121a921b04..ed7e3dc6b529 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1706,6 +1706,36 @@ int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, } EXPORT_SYMBOL(snd_pcm_hw_param_last); +/** + * snd_pcm_hw_params_bps - Get the number of bits per the sample. + * @p: hardware parameters + * + * Return: The number of bits per sample based on the format, + * subformat and msbits the specified hw params has. + */ +int snd_pcm_hw_params_bps(const struct snd_pcm_hw_params *p) +{ + snd_pcm_subformat_t subformat = params_subformat(p); + snd_pcm_format_t format = params_format(p); + int width; + + switch (format) { + case SNDRV_PCM_FORMAT_S32_LE: + case SNDRV_PCM_FORMAT_U32_LE: + case SNDRV_PCM_FORMAT_S32_BE: + case SNDRV_PCM_FORMAT_U32_BE: + width = snd_pcm_subformat_width(subformat); + if (width) + return width; + if (p->msbits) + return (int)p->msbits; + fallthrough; + default: + return snd_pcm_format_width(format); + } +} +EXPORT_SYMBOL(snd_pcm_hw_params_bps); + static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, void *arg) { diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c index 5588b6a1ee8b..127bb36fd2e4 100644 --- a/sound/core/pcm_misc.c +++ b/sound/core/pcm_misc.c @@ -482,6 +482,29 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int } EXPORT_SYMBOL(snd_pcm_format_set_silence); +/** + * snd_pcm_subformat_width - return the bit-width of the subformat + * @subformat: the subformat to check + * + * Return: The bit-width of the subformat, or a negative error code + * otherwise. + */ +int snd_pcm_subformat_width(snd_pcm_subformat_t subformat) +{ + switch (subformat) { + case SNDRV_PCM_SUBFORMAT_MSBITS_20: + return 20; + case SNDRV_PCM_SUBFORMAT_MSBITS_24: + return 24; + case SNDRV_PCM_SUBFORMAT_MSBITS_32: + return 32; + case SNDRV_PCM_SUBFORMAT_STD: + default: + return 0; + } +} +EXPORT_SYMBOL(snd_pcm_subformat_width); + /** * snd_pcm_hw_limit_rates - determine rate_min/rate_max fields * @hw: the pcm hw instance diff --git a/tools/include/uapi/sound/asound.h b/tools/include/uapi/sound/asound.h index f9939da41122..30a43541ed00 100644 --- a/tools/include/uapi/sound/asound.h +++ b/tools/include/uapi/sound/asound.h @@ -267,7 +267,10 @@ typedef int __bitwise snd_pcm_format_t; typedef int __bitwise snd_pcm_subformat_t; #define SNDRV_PCM_SUBFORMAT_STD ((__force snd_pcm_subformat_t) 0) -#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_STD +#define SNDRV_PCM_SUBFORMAT_MSBITS_20 ((__force snd_pcm_subformat_t) 1) +#define SNDRV_PCM_SUBFORMAT_MSBITS_24 ((__force snd_pcm_subformat_t) 2) +#define SNDRV_PCM_SUBFORMAT_MSBITS_32 ((__force snd_pcm_subformat_t) 3) +#define SNDRV_PCM_SUBFORMAT_LAST SNDRV_PCM_SUBFORMAT_MSBITS_32 #define SNDRV_PCM_INFO_MMAP 0x00000001 /* hardware supports mmap */ #define SNDRV_PCM_INFO_MMAP_VALID 0x00000002 /* period data are valid during transfer */ From patchwork Wed Aug 23 08:05:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361763 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7DCF2EE49A0 for ; Wed, 23 Aug 2023 08:08:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 21E1C836; Wed, 23 Aug 2023 10:07:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 21E1C836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778108; bh=xYNNIyxVR7KiISqp+e+GiV75aUZndbayAZ3Z4C/kjFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=p6c9+f1zATQzckNrVNWPnEdlIzyN6dwpD78APOL1E+ic1y1u+P7mqI/rzO6EimyHa alEc76kZ1N/nxyyoFtrcLNHpJUBaYS5ftlK2RpMu0vIX6Pn6Vn8JhXXAslOD3k5S1Z xfXz9+1pJlnO0I34kFMFkUykK0oq8iPuqV+ftt48= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 94121F8022B; Wed, 23 Aug 2023 10:07:28 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 06CC7F80158; Wed, 23 Aug 2023 10:07:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2F639F80536; Wed, 23 Aug 2023 10:06:20 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 11516F80022 for ; Wed, 23 Aug 2023 10:06:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 11516F80022 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=HIoERzz6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777971; x=1724313971; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xYNNIyxVR7KiISqp+e+GiV75aUZndbayAZ3Z4C/kjFc=; b=HIoERzz61fUKNQlYb7GIaflFTznpkX5AlwZBogLEpQFyttKwHdbuIEHE ii8skXOpHTQj5t357Rjo+yVV5FfXCeRkrfL/aV6vIDv40lfxMIknfXTij q/LWLd58ccfxosc2OjdTJXrE0+ie6lZavRhMgh5b62fpvYsHsGne25Jhn nJyx5U7Xf/2dhs0t/7xihofVNfvNNVDUa1Az8wSODygzI8poNUIIPE/uO g7j+CwiXtL2I3f2IgkERKNL4NanThC2RdVvVNQYqfhZL1BhMy/koDHG1C 35GMMCF+nCXXM/UepLjgI5r5r8XkJhupQUoe/rf/zgI3yDMaxMCCG8BSg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988001" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988001" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042651" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042651" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:07 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 02/17] ALSA: pcm: Honor subformat when configuring substream Date: Wed, 23 Aug 2023 10:05:31 +0200 Message-Id: <20230823080546.2224713-3-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: DKJPURGAETW2WAHWXR6KIIW2A7HIISF5 X-Message-ID-Hash: DKJPURGAETW2WAHWXR6KIIW2A7HIISF5 X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Substream value is currently hardcoded to SNDRV_PCM_SUBFORMAT_STD. Update the constraint procedure so that subformat selection is not ignored. Signed-off-by: Cezary Rojewski --- sound/core/pcm_native.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 95fc56e403b1..01f2879ff8e2 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2614,6 +2614,8 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) int err; unsigned int mask = 0; + /* All PCMs support at least the default STD subformat. */ + hw->subformats |= PARAM_MASK_BIT(SNDRV_PCM_SUBFORMAT_STD); if (hw->info & SNDRV_PCM_INFO_INTERLEAVED) mask |= PARAM_MASK_BIT(SNDRV_PCM_ACCESS_RW_INTERLEAVED); if (hw->info & SNDRV_PCM_INFO_NONINTERLEAVED) @@ -2634,8 +2636,7 @@ static int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) if (err < 0) return err; - err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, - PARAM_MASK_BIT(SNDRV_PCM_SUBFORMAT_STD)); + err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, hw->subformats); if (err < 0) return err; From patchwork Wed Aug 23 08:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361773 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id ACA97EE49AE for ; Wed, 23 Aug 2023 08:11:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id C3F13857; Wed, 23 Aug 2023 10:10:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C3F13857 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778278; bh=ngU0OZ1zaFpKeiLs9pGmm0oDyxE4GLMkNKWHMdSNTVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=JNGTqYUYEuN+BEKVa8S7+eM6v82yQS45HsINMKw6Pi+Gc2k4qp8hPrkzBNDQCZjyy 1FO4Lqzy8S2RMH6MSkO0xROru9y8q3hDPLX0q8F6OoYyJkjMEUBY+G2FZHytRz6oUh 5rCnza7/1Dl+7hv4t96d9KM5YIGOw6uovZgv2k1c= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D7606F805F1; Wed, 23 Aug 2023 10:07:47 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 28005F805EB; Wed, 23 Aug 2023 10:07:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E6EFFF80022; Wed, 23 Aug 2023 10:06:42 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 6FEAAF8022B for ; Wed, 23 Aug 2023 10:06:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6FEAAF8022B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=Qj/MZ8Zh DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777973; x=1724313973; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ngU0OZ1zaFpKeiLs9pGmm0oDyxE4GLMkNKWHMdSNTVQ=; b=Qj/MZ8ZhObn4FYAtQeo+opF8jnktSspMSlnuxBfDxSSiwXXcCKp4trLV CEEvoGA1OmVFPe4pqW+gsHSOIBYE32EnV7knDvBLm/rGq1SEQcPEanq15 2fd9zuCh21RI4tSYoiPXRQ+9dmg+X452rSBVK41Pc/gIb+uLRfLI8bGuk mv+9995HamB/TJK2NXg/Fbd5yfvcjUwq3B8oJQZ0j7+QXy0otV6or8CLt hLA4gNQ/UVwtvqY8mehPdNf5jSMqjjs9JU+s0IX1A+OAXVbzdzh9RGxOo HkkkTa2+pRcrRWnyhH9lEy4KTYNw59GvANhgeVVfWwvmJGum7HVIt6qq+ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988021" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988021" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042668" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042668" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:09 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 03/17] ALSA: hda: Honor subformat when querying PCMs Date: Wed, 23 Aug 2023 10:05:32 +0200 Message-Id: <20230823080546.2224713-4-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: ZSDQU7L45Z7CJMXBWUOLDQUWLXBB4C5W X-Message-ID-Hash: ZSDQU7L45Z7CJMXBWUOLDQUWLXBB4C5W X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Update mechanism for querying supported PCMs to allow for granular format selection when container size is 32 bits. Currently always the highest bit depth is selected, regardless of how many actual formats codec in question supports. Signed-off-by: Cezary Rojewski --- include/sound/hda_codec.h | 5 +++-- include/sound/hdaudio.h | 2 +- sound/hda/hdac_device.c | 42 ++++++++++++++++++++---------------- sound/pci/hda/hda_codec.c | 2 ++ sound/pci/hda/patch_hdmi.c | 1 + sound/soc/codecs/hdac_hdmi.c | 3 ++- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/include/sound/hda_codec.h b/include/sound/hda_codec.h index 5497dc9c396a..2ffefcfe06aa 100644 --- a/include/sound/hda_codec.h +++ b/include/sound/hda_codec.h @@ -141,6 +141,7 @@ struct hda_pcm_stream { hda_nid_t nid; /* default NID to query rates/formats/bps, or set up */ u32 rates; /* supported rates */ u64 formats; /* supported formats (SNDRV_PCM_FMTBIT_) */ + u64 subformats; /* supported subformats (SNDRV_PCM_SUBFMTBIT_) */ unsigned int maxbps; /* supported max. bit per sample */ const struct snd_pcm_chmap_elem *chmap; /* chmap to override */ struct hda_pcm_ops ops; @@ -448,8 +449,8 @@ void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid, #define snd_hda_codec_cleanup_stream(codec, nid) \ __snd_hda_codec_cleanup_stream(codec, nid, 0) -#define snd_hda_query_supported_pcm(codec, nid, ratesp, fmtsp, bpsp) \ - snd_hdac_query_supported_pcm(&(codec)->core, nid, ratesp, fmtsp, bpsp) +#define snd_hda_query_supported_pcm(codec, nid, ratesp, fmtsp, subfmtp, bpsp) \ + snd_hdac_query_supported_pcm(&(codec)->core, nid, ratesp, fmtsp, subfmtp, bpsp) #define snd_hda_is_supported_format(codec, nid, fmt) \ snd_hdac_is_supported_format(&(codec)->core, nid, fmt) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 32c59053b48e..000fc72aaece 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -146,7 +146,7 @@ unsigned int snd_hdac_calc_stream_format(unsigned int rate, unsigned int maxbps, unsigned short spdif_ctls); int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, - u32 *ratesp, u64 *formatsp, unsigned int *bpsp); + u32 *ratesp, u64 *formatsp, u64 *subformatsp, unsigned int *bpsp); bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid, unsigned int format); diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index bbf7bcdb449a..eb4ece908bca 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -817,15 +817,16 @@ static unsigned int query_stream_param(struct hdac_device *codec, hda_nid_t nid) * @nid: NID to query * @ratesp: the pointer to store the detected rate bitflags * @formatsp: the pointer to store the detected formats + * @subformatsp: the pointer to store the detected subformats * @bpsp: the pointer to store the detected format widths * - * Queries the supported PCM rates and formats. The NULL @ratesp, @formatsp - * or @bsps argument is ignored. + * Queries the supported PCM rates and formats. The NULL @ratesp, @formatsp, + * @subformatsp or @bpsp argument is ignored. * * Returns 0 if successful, otherwise a negative error code. */ int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, - u32 *ratesp, u64 *formatsp, unsigned int *bpsp) + u32 *ratesp, u64 *formatsp, u64 *subformatsp, unsigned int *bpsp) { unsigned int i, val, wcaps; @@ -848,8 +849,9 @@ int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, *ratesp = rates; } - if (formatsp || bpsp) { + if (formatsp || subformatsp || bpsp) { u64 formats = 0; + u64 subformats = 0; unsigned int streams, bps; streams = query_stream_param(codec, nid); @@ -866,24 +868,24 @@ int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, formats |= SNDRV_PCM_FMTBIT_S16_LE; bps = 16; } - if (wcaps & AC_WCAP_DIGITAL) { - if (val & AC_SUPPCM_BITS_32) + if (val & AC_SUPPCM_BITS_20) { + formats |= SNDRV_PCM_FMTBIT_S32_LE; + subformats |= SNDRV_PCM_SUBFMTBIT_MSBITS_20; + bps = 20; + } + if (val & AC_SUPPCM_BITS_24) { + formats |= SNDRV_PCM_FMTBIT_S32_LE; + subformats |= SNDRV_PCM_SUBFMTBIT_MSBITS_24; + bps = 24; + } + if (val & AC_SUPPCM_BITS_32) { + subformats |= SNDRV_PCM_SUBFMTBIT_MSBITS_32; + if (wcaps & AC_WCAP_DIGITAL) { formats |= SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE; - if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24)) + } else { formats |= SNDRV_PCM_FMTBIT_S32_LE; - if (val & AC_SUPPCM_BITS_24) - bps = 24; - else if (val & AC_SUPPCM_BITS_20) - bps = 20; - } else if (val & (AC_SUPPCM_BITS_20|AC_SUPPCM_BITS_24| - AC_SUPPCM_BITS_32)) { - formats |= SNDRV_PCM_FMTBIT_S32_LE; - if (val & AC_SUPPCM_BITS_32) bps = 32; - else if (val & AC_SUPPCM_BITS_24) - bps = 24; - else if (val & AC_SUPPCM_BITS_20) - bps = 20; + } } } #if 0 /* FIXME: CS4206 doesn't work, which is the only codec supporting float */ @@ -911,6 +913,8 @@ int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, } if (formatsp) *formatsp = formats; + if (subformatsp) + *subformatsp = subformats; if (bpsp) *bpsp = bps; } diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index bd19f92aeeec..3c1555e327cd 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3165,6 +3165,7 @@ static int set_pcm_default_values(struct hda_codec *codec, err = snd_hda_query_supported_pcm(codec, info->nid, info->rates ? NULL : &info->rates, info->formats ? NULL : &info->formats, + info->subformats ? NULL : &info->subformats, info->maxbps ? NULL : &info->maxbps); if (err < 0) return err; @@ -3759,6 +3760,7 @@ int snd_hda_multi_out_analog_open(struct hda_codec *codec, snd_hda_query_supported_pcm(codec, mout->dig_out_nid, &mout->spdif_rates, &mout->spdif_formats, + NULL, &mout->spdif_maxbps); } mutex_lock(&codec->spdif_mutex); diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 260d3e64f658..c476b16144cb 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -1977,6 +1977,7 @@ static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid) err = snd_hda_query_supported_pcm(codec, cvt_nid, &per_cvt->rates, &per_cvt->formats, + NULL, &per_cvt->maxbps); if (err < 0) return err; diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 8b6b76029694..fb3f8a565485 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -670,6 +670,7 @@ hdac_hdmi_query_cvt_params(struct hdac_device *hdev, struct hdac_hdmi_cvt *cvt) err = snd_hdac_query_supported_pcm(hdev, cvt->nid, &cvt->params.rates, &cvt->params.formats, + NULL, &cvt->params.maxbps); if (err < 0) dev_err(&hdev->dev, @@ -1577,7 +1578,7 @@ static int hdac_hdmi_create_dais(struct hdac_device *hdev, list_for_each_entry(cvt, &hdmi->cvt_list, head) { ret = snd_hdac_query_supported_pcm(hdev, cvt->nid, - &rates, &formats, &bps); + &rates, &formats, NULL, &bps); if (ret) return ret; From patchwork Wed Aug 23 08:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361771 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id A9964EE49AF for ; Wed, 23 Aug 2023 08:10:54 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A81EFDEE; Wed, 23 Aug 2023 10:10:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A81EFDEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778252; bh=d/y3ZSzVnLQg+JYbhzlp4/k04uFxDZCewVaVB3x4u4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=GNBD2OvaWAXzS7KigGEG/T1Iy0oc/M9Bm3G7jUR/ArIhSYTYIHMUmYRVFzKx+PaFN uCe0abqhRLep1MpwPL9NTXqGCGmwEhuY+U8APnaqvktlz4Vcn1kGqYbM4cL78RNk9I X2iLuCsuO1Armp93mreJHIpsxamIy83mAPjF6iGU= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8AA0BF805D4; Wed, 23 Aug 2023 10:07:43 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D8C97F805C7; Wed, 23 Aug 2023 10:07:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 305FCF8023B; Wed, 23 Aug 2023 10:06:38 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 96227F800F5 for ; Wed, 23 Aug 2023 10:06:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 96227F800F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=G6OtF18D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777975; x=1724313975; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=d/y3ZSzVnLQg+JYbhzlp4/k04uFxDZCewVaVB3x4u4c=; b=G6OtF18DemJNiAQmaHpv5an16PXBK/Cl/lcWJ1F1Wjy2Oatig/YQ0uKx nhH2dq3OLC2jw+u2gji19wTQuJgd8JHO4DW/t97EzwINRmwcJTX3/cffF I0JuANOIe+QnqDR54lY27rkiGCRVwM8eqYtoDqefwIZLP7Yb5fZlk2Q+5 EZuhXZ7pWtZmWZRYrA2RN35np5bHkz3Iq/rJ4Io0dvJ4I9WP0sSzx+zH4 sOH0INqZGsvUIVZVTerneD5yqmYhxS9IsjvFo92y9iB3+GhTcwPapemX1 /Ri9tqAvGixreGEsXgIdaxFw80U3dwBynRzuWVOcaSDf24/lLsBRLpaME g==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988033" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988033" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042676" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042676" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:12 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 04/17] ASoC: pcm: Honor subformat when configuring runtime Date: Wed, 23 Aug 2023 10:05:33 +0200 Message-Id: <20230823080546.2224713-5-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: 2IEMTATKOUOETG25HKZHEY75FV2EJLDK X-Message-ID-Hash: 2IEMTATKOUOETG25HKZHEY75FV2EJLDK X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Subformat options are ignored when setting up hardware parameters and assigning PCM stream capabilities. Account for them to allow for granular format selection. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- include/sound/soc.h | 1 + sound/soc/soc-pcm.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index fa2337a3cf4c..05148d4ed0fd 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -619,6 +619,7 @@ enum snd_soc_trigger_order { struct snd_soc_pcm_stream { const char *stream_name; u64 formats; /* SNDRV_PCM_FMTBIT_* */ + u64 subformats; /* SNDRV_PCM_SUBFMTBIT_* */ unsigned int rates; /* SNDRV_PCM_RATE_* */ unsigned int rate_min; /* min rate */ unsigned int rate_max; /* max rate */ diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 3aa6b988cb4b..bceb90f0198d 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -526,6 +526,7 @@ static void soc_pcm_hw_init(struct snd_pcm_hardware *hw) hw->channels_min = 0; hw->channels_max = UINT_MAX; hw->formats = ULLONG_MAX; + hw->subformats = ULLONG_MAX; } static void soc_pcm_hw_update_rate(struct snd_pcm_hardware *hw, @@ -554,6 +555,12 @@ static void soc_pcm_hw_update_format(struct snd_pcm_hardware *hw, hw->formats &= p->formats; } +static void soc_pcm_hw_update_subformat(struct snd_pcm_hardware *hw, + struct snd_soc_pcm_stream *p) +{ + hw->subformats &= p->subformats; +} + /** * snd_soc_runtime_calc_hw() - Calculate hw limits for a PCM stream * @rtd: ASoC PCM runtime @@ -592,6 +599,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, soc_pcm_hw_update_chan(hw, cpu_stream); soc_pcm_hw_update_rate(hw, cpu_stream); soc_pcm_hw_update_format(hw, cpu_stream); + soc_pcm_hw_update_subformat(hw, cpu_stream); } cpu_chan_min = hw->channels_min; cpu_chan_max = hw->channels_max; @@ -613,6 +621,7 @@ int snd_soc_runtime_calc_hw(struct snd_soc_pcm_runtime *rtd, soc_pcm_hw_update_chan(hw, codec_stream); soc_pcm_hw_update_rate(hw, codec_stream); soc_pcm_hw_update_format(hw, codec_stream); + soc_pcm_hw_update_subformat(hw, codec_stream); } /* Verify both a valid CPU DAI and a valid CODEC DAI were found */ @@ -637,6 +646,7 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream) { struct snd_pcm_hardware *hw = &substream->runtime->hw; struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); + u64 subformats = hw->subformats; u64 formats = hw->formats; /* @@ -648,6 +658,8 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream) if (formats) hw->formats &= formats; + if (subformats) + hw->subformats &= subformats; } static int soc_pcm_components_open(struct snd_pcm_substream *substream) @@ -1676,6 +1688,7 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream) struct snd_pcm_hardware *hw = &runtime->hw; struct snd_soc_dai *dai; int stream = substream->stream; + u64 subformats = hw->subformats; u64 formats = hw->formats; int i; @@ -1683,6 +1696,8 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream) if (formats) hw->formats &= formats; + if (subformats) + hw->subformats &= subformats; for_each_rtd_cpu_dais(fe, i, dai) { struct snd_soc_pcm_stream *cpu_stream; @@ -1699,6 +1714,7 @@ static void dpcm_runtime_setup_fe(struct snd_pcm_substream *substream) soc_pcm_hw_update_rate(hw, cpu_stream); soc_pcm_hw_update_chan(hw, cpu_stream); soc_pcm_hw_update_format(hw, cpu_stream); + soc_pcm_hw_update_subformat(hw, cpu_stream); } } @@ -1736,6 +1752,7 @@ static void dpcm_runtime_setup_be_format(struct snd_pcm_substream *substream) codec_stream = snd_soc_dai_get_pcm_stream(dai, stream); soc_pcm_hw_update_format(hw, codec_stream); + soc_pcm_hw_update_subformat(hw, codec_stream); } } } From patchwork Wed Aug 23 08:05:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361770 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2DEB7EE49AE for ; Wed, 23 Aug 2023 08:10:30 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2D07BDED; Wed, 23 Aug 2023 10:09:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2D07BDED DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778228; bh=BKqPQl2ZjHS6OyDVhM24CIsCZyTPuLorAcuX5jbMfGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=r2P8qZvXjlMcK4MzdbLTQ3O0cCEH8BzM3WO+/9nzHZ4wRhEbLLIeRY4Y/12dLojWs QSO0QpDEnREWLfzZC6aXQNkOY8BSGuWamsEn7dR6NYFX0hygYdVFLlGW6bcP78Ge3A CQC4n7c0m6lMYQPcDY1pH4ALuxfTM1cq0MpXl5Uc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5AAD7F805C5; Wed, 23 Aug 2023 10:07:42 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 670E8F805C1; Wed, 23 Aug 2023 10:07:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B0774F80536; Wed, 23 Aug 2023 10:06:38 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 DCB87F8023B for ; Wed, 23 Aug 2023 10:06:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DCB87F8023B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=bZqCctEr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777978; x=1724313978; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BKqPQl2ZjHS6OyDVhM24CIsCZyTPuLorAcuX5jbMfGM=; b=bZqCctErSeL5X20niaHlp/TPepmCg8SsztVeldxGYjDZcRx7wek2DmNm E5kTLlgxD1xKM6JBBMA48FSUUbju1k3DaDSVQppocYv1dAewyNU+vgZz9 56sDNewwLIAB9/3F3JEHMw3NaCdIY1TU+lrB0s3qAozrKB9vZvL6a7TM3 VzHfOn/c9ECS/FkmD+xkv3FBXeSGtQ9eXaAGOghIsxIGIRkt0Ov9YUp1Y 4K+dDQEYPSoQxoJO4h+VyzWbF009XEy8m2KFooVV1HJVBiGwssrEEQsWx SqDIx06N0b666qUJPLldktcRAjEy8Pe6cPhiVwOj/idHBfaR7g3mqVurI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988050" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988050" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042684" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042684" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:14 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 05/17] ALSA: hda: Upgrade stream-format infrastructure Date: Wed, 23 Aug 2023 10:05:34 +0200 Message-Id: <20230823080546.2224713-6-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: DFRPT2RSEK4N3TLXOM7DNGOASQUQ6CNI X-Message-ID-Hash: DFRPT2RSEK4N3TLXOM7DNGOASQUQ6CNI X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Introduce a set of functions that facilite SDxFMT-related calculations in atomic manner: snd_hdac_format_normalize() - format converter. S20_LE, S24_LE and their unsigned and BE friends are invalid from HDAudio perspective but still can be specified as function argument due to compatibility reasons. snd_hdac_stream_format_bps() - obtain just the bits-per-sample value. Does not ignore subformat and msbits parameters. snd_hdac_stream_format() and snd_hdac_spdif_stream_format() - obtain the SDxFMT value given the audio format parameters. The former is stripped away of spdif-related information. Useful for users that do not care about them. Signed-off-by: Cezary Rojewski --- include/sound/hdaudio.h | 5 ++ sound/hda/hdac_device.c | 124 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index 000fc72aaece..a7c2f02110fa 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -140,6 +140,11 @@ int snd_hdac_get_connections(struct hdac_device *codec, hda_nid_t nid, hda_nid_t *conn_list, int max_conns); int snd_hdac_get_sub_nodes(struct hdac_device *codec, hda_nid_t nid, hda_nid_t *start_id); +unsigned int snd_hdac_stream_format_bps(snd_pcm_format_t format, snd_pcm_subformat_t subformat, + unsigned int maxbps); +unsigned int snd_hdac_stream_format(unsigned int channels, unsigned int bps, unsigned int rate); +unsigned int snd_hdac_spdif_stream_format(unsigned int channels, unsigned int bps, + unsigned int rate, unsigned short spdif_ctls); unsigned int snd_hdac_calc_stream_format(unsigned int rate, unsigned int channels, snd_pcm_format_t format, diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index eb4ece908bca..13e27d38f2fe 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "local.h" static void setup_fg_nodes(struct hdac_device *codec); @@ -725,6 +726,129 @@ static const struct hda_rate_tbl rate_bits[] = { { 0 } /* terminator */ }; +static snd_pcm_format_t snd_hdac_format_normalize(snd_pcm_format_t format) +{ + switch (format) { + case SNDRV_PCM_FORMAT_S20_LE: + case SNDRV_PCM_FORMAT_S24_LE: + return SNDRV_PCM_FORMAT_S32_LE; + + case SNDRV_PCM_FORMAT_U20_LE: + case SNDRV_PCM_FORMAT_U24_LE: + return SNDRV_PCM_FORMAT_U32_LE; + + case SNDRV_PCM_FORMAT_S20_BE: + case SNDRV_PCM_FORMAT_S24_BE: + return SNDRV_PCM_FORMAT_S32_BE; + + case SNDRV_PCM_FORMAT_U20_BE: + case SNDRV_PCM_FORMAT_U24_BE: + return SNDRV_PCM_FORMAT_U32_BE; + + default: + return format; + } +} + +/** + * snd_hdac_stream_format_bps - obtain bits per sample value. + * @format: the PCM format. + * @subformat: the PCM subformat. + * @maxbps: the maximum bits per sample. + * + * Return: The number of bits per sample. + */ +unsigned int snd_hdac_stream_format_bps(snd_pcm_format_t format, snd_pcm_subformat_t subformat, + unsigned int maxbps) +{ + struct snd_pcm_hw_params params; + unsigned int bps; + + memset(¶ms, 0, sizeof(params)); + + params_set_format(¶ms, snd_hdac_format_normalize(format)); + snd_mask_set(hw_param_mask(¶ms, SNDRV_PCM_HW_PARAM_SUBFORMAT), + (__force unsigned int)subformat); + + bps = snd_pcm_hw_params_bps(¶ms); + if (maxbps) + return min(bps, maxbps); + return bps; +} +EXPORT_SYMBOL_GPL(snd_hdac_stream_format_bps); + +/** + * snd_hdac_stream_format - convert format parameters to SDxFMT value. + * @channels: the number of channels. + * @bps: bits per sample. + * @rate: the sample rate. + * + * Return: The format bitset or zero if invalid. + */ +unsigned int snd_hdac_stream_format(unsigned int channels, unsigned int bps, unsigned int rate) +{ + unsigned int val = 0; + int i; + + for (i = 0; rate_bits[i].hz; i++) { + if (rate_bits[i].hz == rate) { + val = rate_bits[i].hda_fmt; + break; + } + } + + if (!rate_bits[i].hz) + return 0; + + if (channels == 0 || channels > 8) + return 0; + val |= channels - 1; + + switch (bps) { + case 8: + val |= AC_FMT_BITS_8; + break; + case 16: + val |= AC_FMT_BITS_16; + break; + case 20: + val |= AC_FMT_BITS_20; + break; + case 24: + val |= AC_FMT_BITS_24; + break; + case 32: + val |= AC_FMT_BITS_32; + break; + default: + return 0; + } + + return val; +} +EXPORT_SYMBOL_GPL(snd_hdac_stream_format); + +/** + * snd_hdac_spdif_stream_format - convert format parameters to SDxFMT value. + * @channels: the number of channels. + * @bps: bits per sample. + * @rate: the sample rate. + * @spdif_ctls: HD-audio SPDIF status bits (0 if irrelevant). + * + * Return: The format bitset or zero if invalid. + */ +unsigned int snd_hdac_spdif_stream_format(unsigned int channels, unsigned int bps, + unsigned int rate, unsigned short spdif_ctls) +{ + unsigned int val = snd_hdac_stream_format(channels, bps, rate); + + if (val && spdif_ctls & AC_DIG1_NONAUDIO) + val |= AC_FMT_TYPE_NON_PCM; + + return val; +} +EXPORT_SYMBOL_GPL(snd_hdac_spdif_stream_format); + /** * snd_hdac_calc_stream_format - calculate the format bitset * @rate: the sample rate From patchwork Wed Aug 23 08:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361765 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DF440EE49A0 for ; Wed, 23 Aug 2023 08:09:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CC73B85D; Wed, 23 Aug 2023 10:08:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CC73B85D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778158; bh=lk101+Pz+wVeoUEp8O7sm38EcYYseJljCF2jp3GvBj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ladYLmZxPrjoCbIHekmHVDXVrEuI/8umQlr5J4gHVksXfgWyo9wUuihUzXVp8sf8X 51TdBn2TaSrfTrj3+D+MeK56WYHS+VYFF+7H0iRS66JMBtoKqEk+KacmWXVNl0x4JP b99A3NHnf4jQ3K4BmtZOf7qrik5G4FugXtqDfJAo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 90F3AF8056F; Wed, 23 Aug 2023 10:07:31 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 10E32F80570; Wed, 23 Aug 2023 10:07:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 716C9F80536; Wed, 23 Aug 2023 10:06:25 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 05F89F8025F for ; Wed, 23 Aug 2023 10:06:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 05F89F8025F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=jNMIXRY+ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777981; x=1724313981; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lk101+Pz+wVeoUEp8O7sm38EcYYseJljCF2jp3GvBj8=; b=jNMIXRY+5BOk4EJIHauQGX2rpNLFMB7mJs9JsA3uwobZqi6vU7ENJVWq rJpye/RcDuXfA0xsxwSY2/dcSs7f2BtI+nfIkwdCe2JpZNkxHavMbZ/+T yZsAUNqw+i8ORNyOnT7759IAR+YQ/zlR55HEy100z/FPUQxOMbtLm2YT+ 2b86BscJw+HtpiSkGQ4F63fzk1m6BoFrZqEHEJfGwhv2mI0PxOcPQjxC+ bAe63QhdC53EbrqbWjUGR5AwuQp7e/FA1yQmFJHn5+JB7xD5KEkzFTbhz 4KnF6VIUE7+rzcKie3fmkZR0wrZ2CERjdatC62BUXWAPt6KltW6cwwteg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988061" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988061" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042697" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042697" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:16 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 06/17] ALSA: hda: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:35 +0200 Message-Id: <20230823080546.2224713-7-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: DV4URX6JVMJ4T5PWDIJQDURLQUEJGM2M X-Message-ID-Hash: DV4URX6JVMJ4T5PWDIJQDURLQUEJGM2M X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski --- sound/pci/hda/hda_controller.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index 406779625fb5..0646ef0afd49 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c @@ -151,7 +151,7 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) struct azx_dev *azx_dev = get_azx_dev(substream); struct hda_pcm_stream *hinfo = to_hda_pcm_stream(substream); struct snd_pcm_runtime *runtime = substream->runtime; - unsigned int format_val, stream_tag; + unsigned int format_val, stream_tag, bps; int err; struct hda_spdif_out *spdif = snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid); @@ -165,11 +165,9 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) } snd_hdac_stream_reset(azx_stream(azx_dev)); - format_val = snd_hdac_calc_stream_format(runtime->rate, - runtime->channels, - runtime->format, - hinfo->maxbps, - ctls); + bps = snd_hdac_stream_format_bps(runtime->format, SNDRV_PCM_SUBFORMAT_STD, hinfo->maxbps); + + format_val = snd_hdac_spdif_stream_format(runtime->channels, bps, runtime->rate, ctls); if (!format_val) { dev_err(chip->card->dev, "invalid format_val, rate=%d, ch=%d, format=%d\n", From patchwork Wed Aug 23 08:05:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361766 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4D360EE49A0 for ; Wed, 23 Aug 2023 08:09:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4FF03950; Wed, 23 Aug 2023 10:08:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4FF03950 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778169; bh=iB3uazZYeoZCECjbN043tKQgzjYej+bFUsdYgjIYkMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MfJqfVYEqgFGo0N8yyOndPoW6O0iiFsbdG0OKOJhos40/K9jVjANTB9rs5XHa5Zif giSzIRBo1YaucZ/V9NDfGVq/ZrJILLVsnme8NOz7cEIOKY3UYSdf3RFDgmdvDqHNBY evgViE8oGCrB0XN/Nw4Ee9tLbW9YC9UKVK0fR6oY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 71C6DF8057B; Wed, 23 Aug 2023 10:07:33 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B28ACF8057A; Wed, 23 Aug 2023 10:07:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 21AC0F804DA; Wed, 23 Aug 2023 10:06:27 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 B186AF804F3 for ; Wed, 23 Aug 2023 10:06:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B186AF804F3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VrGCoqDV DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777984; x=1724313984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iB3uazZYeoZCECjbN043tKQgzjYej+bFUsdYgjIYkMM=; b=VrGCoqDVrICMPvZSZDW7HKuPgxoDu792Oig7mB11jRRou1DN+IKOYtCu Lv87WhlSLbfivH8Roq1Fbn5N8x2aSLR/9pN0jFyIIsZBES13N2GK4wgr0 /ZSF+9gZNt5a8vhU0jfWgj+U1pW7D7lrjy6djJpMUAYBqoJ+aa6EmYo/3 JNstWpR8itt1hMk4ezoF7X1svP2Hipqifnb7nZRQ+9V33jOvjLv/xuqJ2 liRw5t22cXHx6Y2WW4ZDny8C2zkb1sEVTnSu9SpBLpt+jiUpmpftbNkRn aYjHTfa+rp86EwXlZLAGOSUB2ye8mxKa4eqtdAwfBBpWBO/00AYOMwPKp Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988069" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988069" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042709" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042709" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:18 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 07/17] ALSA: hda/hdmi: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:36 +0200 Message-Id: <20230823080546.2224713-8-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: HOLWCH6ZU3L2QU2W5666BRNVKUN42SEC X-Message-ID-Hash: HOLWCH6ZU3L2QU2W5666BRNVKUN42SEC X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski --- sound/pci/hda/patch_hdmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index c476b16144cb..de8da647465f 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c @@ -1655,7 +1655,6 @@ static void hdmi_present_sense_via_verbs(struct hdmi_spec_per_pin *per_pin, #define I915_SILENT_RATE 48000 #define I915_SILENT_CHANNELS 2 -#define I915_SILENT_FORMAT SNDRV_PCM_FORMAT_S16_LE #define I915_SILENT_FORMAT_BITS 16 #define I915_SILENT_FMT_MASK 0xf @@ -1668,8 +1667,8 @@ static void silent_stream_enable_i915(struct hda_codec *codec, per_pin->dev_id, I915_SILENT_RATE); /* trigger silent stream generation in hw */ - format = snd_hdac_calc_stream_format(I915_SILENT_RATE, I915_SILENT_CHANNELS, - I915_SILENT_FORMAT, I915_SILENT_FORMAT_BITS, 0); + format = snd_hdac_stream_format(I915_SILENT_CHANNELS, I915_SILENT_FORMAT_BITS, + I915_SILENT_RATE); snd_hda_codec_setup_stream(codec, per_pin->cvt_nid, I915_SILENT_FMT_MASK, I915_SILENT_FMT_MASK, format); usleep_range(100, 200); From patchwork Wed Aug 23 08:05:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361767 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B1124EE49A0 for ; Wed, 23 Aug 2023 08:09:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 24B3383E; Wed, 23 Aug 2023 10:08:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 24B3383E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778188; bh=uFo3JTP2alB99rkg19E443MKdeHnjsbmxR/ux1VI5Z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cXHFFzmdrFhfpirQJlLziwtYsUZLY2FdSf2Y9V5rLYkWCh4B13+OCAqS3gFj57ij/ 1B4pdwgAKH1pUfW/QzH8UWF9FD9sYps3EDxCgRyIh7mXiGzLmA47fzE6BIZHSIoFB7 EEuwTAEowt9oyhUXA7yEzoLLxWG/PpFWsN72qylo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D0B60F805AA; Wed, 23 Aug 2023 10:07:35 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6C641F805A0; Wed, 23 Aug 2023 10:07:35 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2BC9F804DA; Wed, 23 Aug 2023 10:06:27 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 B7F58F800D1 for ; Wed, 23 Aug 2023 10:06:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B7F58F800D1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BPjEDpnm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777984; x=1724313984; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uFo3JTP2alB99rkg19E443MKdeHnjsbmxR/ux1VI5Z8=; b=BPjEDpnm1SGB5NDefzxo90jonhGIKcFTKOSO66M0Hx0wJD0OYww5uLva rDk3lyL1JUHgIDqeegSirIaUrtz7/7ivPA1oDwel7fiV6CxfjknF6fzFi O/yZ8jYDBPZvntlu269kLnnTuUswX9L4YvvyBc9Mnqxp4OvTYdNKk3odc FpPGqpolBJwTGTzsQ1n5eiCAt9+489GyiKkN0CWAiK3qtI1tJH7Xxr7Wx +EckhIluvGe42tTd3UoHXsrNnIJiJb4bDnSgFFUh+bO+jCXvWBO5Iu3eh qT27mmIo+4AYtUn7hRsvLyTQqT85t6N4ATS6HfsxxTG/6YdKDtr+C62Qh A==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988083" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988083" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042718" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042718" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:20 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 08/17] ALSA: hda/ca0132: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:37 +0200 Message-Id: <20230823080546.2224713-9-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: DYLIF24OXMMTXFIJTBMVBHPU6IOL2D4D X-Message-ID-Hash: DYLIF24OXMMTXFIJTBMVBHPU6IOL2D4D X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski --- sound/pci/hda/patch_ca0132.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 748a3c40966e..aa312441604f 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c @@ -3022,8 +3022,7 @@ static int dma_convert_to_hda_format(struct hda_codec *codec, { unsigned int format_val; - format_val = snd_hdac_calc_stream_format(sample_rate, - channels, SNDRV_PCM_FORMAT_S32_LE, 32, 0); + format_val = snd_hdac_stream_format(channels, 32, sample_rate); if (hda_format) *hda_format = (unsigned short)format_val; From patchwork Wed Aug 23 08:05:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361769 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6483EEE49AE for ; Wed, 23 Aug 2023 08:10:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 69A91A4C; Wed, 23 Aug 2023 10:09:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 69A91A4C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778211; bh=ILFzcmSh7Eexk6gyQ1o+eO1ISYweJG5SrkJm+elIkOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=N8JbMVnB5n0at8GAXDQ2T5WDb6j2X7DxFO5Llq1b/nuR3bK1VaeZSvCKrUsDUHezF +C3RAPbI5tDS7GKgttMWSvCimpFZqqmdn9Q+7H4gcbJL7hJ/gBOIO+mqUC2ibnqp7e JARSGteuUzWWwHarXESsXTL4Tr5mOxSRqu1ADL9g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id F2AFEF80158; Wed, 23 Aug 2023 10:07:40 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9A0F0F805B4; Wed, 23 Aug 2023 10:07:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 03555F80537; Wed, 23 Aug 2023 10:06:35 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 35856F800D1 for ; Wed, 23 Aug 2023 10:06:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 35856F800D1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=UdW2UQHL DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777989; x=1724313989; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ILFzcmSh7Eexk6gyQ1o+eO1ISYweJG5SrkJm+elIkOk=; b=UdW2UQHLHGsMWUvLojqktA4rsJ8EeixlOR/RmJWTatcQiHSr9ApjsclN VyQH98Aje3wsuEEDrgn0D66ibH61kDd5Uje0mi9XOE6ciFjCaH4W5AgkW MCu2xUEndQemJJwn0h1JaYKRQZE7QpCng2WCZmDGjcf4lji0K2HvO3TYP JtXfFnZpW2Yqvib1EAPFq2tOdE92yszQxLsFCO9vNP1UXG49LlEfcjIrY /h/qAok7kXGC/BU18ofuNxntwfcPsdSyPkNHuJzEeTLN8ry6CkgCAD9XF tW59zYiRYnjW2t0HsYN3dw3oFfCDNOwVscxiSCARKO7oD/f2QpSPXUWZj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988098" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988098" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042724" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042724" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:23 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 09/17] ASoC: codecs: hda: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:38 +0200 Message-Id: <20230823080546.2224713-10-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: JEZ45SAS5FDY4QDWJRUB3FQYIHGHDXG2 X-Message-ID-Hash: JEZ45SAS5FDY4QDWJRUB3FQYIHGHDXG2 X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. While at it, complete PCM stream initialization with subformat options. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/codecs/hda-dai.c | 6 ++++-- sound/soc/codecs/hda.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/hda-dai.c b/sound/soc/codecs/hda-dai.c index 5371ff086261..20b070c66c6f 100644 --- a/sound/soc/codecs/hda-dai.c +++ b/sound/soc/codecs/hda-dai.c @@ -76,13 +76,15 @@ static int hda_codec_dai_prepare(struct snd_pcm_substream *substream, struct snd struct hdac_stream *stream; struct hda_codec *codec; unsigned int format; + unsigned int bps; int ret; codec = dev_to_hda_codec(dai->dev); stream = substream->runtime->private_data; stream_info = snd_soc_dai_get_dma_data(dai, substream); - format = snd_hdac_calc_stream_format(runtime->rate, runtime->channels, runtime->format, - runtime->sample_bits, 0); + + bps = snd_hdac_stream_format_bps(runtime->format, runtime->subformat, stream_info->maxbps); + format = snd_hdac_stream_format(runtime->channels, bps, runtime->rate); ret = snd_hda_codec_prepare(codec, stream_info, stream->stream_tag, format, substream); if (ret < 0) { diff --git a/sound/soc/codecs/hda.c b/sound/soc/codecs/hda.c index d57b043d6bfe..d2117e36ddd1 100644 --- a/sound/soc/codecs/hda.c +++ b/sound/soc/codecs/hda.c @@ -52,6 +52,7 @@ static int hda_codec_create_dais(struct hda_codec *codec, int pcm_count, stream->channels_max = pcm->stream[dir].channels_max; stream->rates = pcm->stream[dir].rates; stream->formats = pcm->stream[dir].formats; + stream->subformats = pcm->stream[dir].subformats; stream->sig_bits = pcm->stream[dir].maxbps; capture_dais: @@ -71,6 +72,7 @@ static int hda_codec_create_dais(struct hda_codec *codec, int pcm_count, stream->channels_max = pcm->stream[dir].channels_max; stream->rates = pcm->stream[dir].rates; stream->formats = pcm->stream[dir].formats; + stream->subformats = pcm->stream[dir].subformats; stream->sig_bits = pcm->stream[dir].maxbps; } From patchwork Wed Aug 23 08:05:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361772 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 81BF8EE49AE for ; Wed, 23 Aug 2023 08:11:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7DBB0DE5; Wed, 23 Aug 2023 10:10:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7DBB0DE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778262; bh=N3yofAoikWdXEKnZoR/6aUXSzneVygpzbhr2X4MlXxI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XnO4skRilwRMF+/FO0j2UT6EDmyPGno/BOtGuOYOM30arVHUsZNP0ie6FI55B1i9k hhzAkmiu9Pccm534FDfmYO49ZJ5hhMd/v+My6/7j3laIrqqNr9Vstm5+zMQnOUdj+j /6OAMnVpA4pcUHsCeW2tKqp90QX5bQhbZi7iCJII= Received: by alsa1.perex.cz (Postfix, from userid 50401) id ECE96F805E1; Wed, 23 Aug 2023 10:07:44 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6CD36F805E3; Wed, 23 Aug 2023 10:07:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CE4F0F80536; Wed, 23 Aug 2023 10:06:42 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 3B83CF80022 for ; Wed, 23 Aug 2023 10:06:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3B83CF80022 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=KHF9elHO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777991; x=1724313991; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=N3yofAoikWdXEKnZoR/6aUXSzneVygpzbhr2X4MlXxI=; b=KHF9elHO4U3EVMR9Vgk4E2ZnBgITk1mbQ1B6dgqoK8V4HZCaOvkqsTss LcVH5iPYsReXoJ6+eDNS1Vc73aoL8bPkhZU7vsdmVoImttKN/yvY47LTC DIwwA7qwFoU7M3itlq5NW+iRtHxnYxu0DPORzU5nXFxGk/OaSFDX74ih1 mcVjJEbo4r14JAszuH3bBVzfaUTu+Kbg99KM1AcdHpukWBIBg8F8hw2++ aXl79bYM6JqDHqI8+46pPu2+nop2gPhRYnl+9Ekf1EjraAyGMBtMSu9j+ 9UoT6Yp4yVy0bswoqTxo2NI7HpHjKzs6GiVDjvjYtOlRU5HZPBtwXLi5F g==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988106" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988106" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042736" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042736" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:25 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 10/17] ASoC: codecs: hdac_hda: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:39 +0200 Message-Id: <20230823080546.2224713-11-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: DEYIXNQ7Q7T24BODE7FDIIQCNIN27QAB X-Message-ID-Hash: DEYIXNQ7Q7T24BODE7FDIIQCNIN27QAB X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/codecs/hdac_hda.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index be66853afbe2..7e308dac07d4 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -207,18 +207,16 @@ static int hdac_hda_dai_hw_params(struct snd_pcm_substream *substream, struct hdac_hda_priv *hda_pvt; unsigned int format_val; unsigned int maxbps; + unsigned int bps; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) maxbps = dai->driver->playback.sig_bits; else maxbps = dai->driver->capture.sig_bits; + bps = snd_hdac_stream_format_bps(params_format(params), SNDRV_PCM_SUBFORMAT_STD, maxbps); hda_pvt = snd_soc_component_get_drvdata(component); - format_val = snd_hdac_calc_stream_format(params_rate(params), - params_channels(params), - params_format(params), - maxbps, - 0); + format_val = snd_hdac_stream_format(params_channels(params), bps, params_rate(params)); if (!format_val) { dev_err(dai->dev, "invalid format_val, rate=%d, ch=%d, format=%d, maxbps=%d\n", From patchwork Wed Aug 23 08:05:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361774 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id BF4F8EE49A0 for ; Wed, 23 Aug 2023 08:11:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A54CEA4E; Wed, 23 Aug 2023 10:10:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A54CEA4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778292; bh=AVcQVAR0f8bmAJ2XCNv41aRcT8G6ctYlRQYBCNx8XB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=qSfwCtHehHlQn06vEdVRe5PacBI/khbtH54D1dfKv6y5ZNEEODw5LVyfA7sJ7H6ld 4U9NYQazVdRb1XcWMcAXVVMgrY9o1BOS04tg0q6p1vBHC3gSB+TcJRMVOEfQQyiWv6 YyckwabVGZd3VhqaasXvI40s9e5JijpiZo0C4KEg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2FF53F805EB; Wed, 23 Aug 2023 10:07:49 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 3351EF805EB; Wed, 23 Aug 2023 10:07:48 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C1A40F800D1; Wed, 23 Aug 2023 10:06:43 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 F3D59F804DA for ; Wed, 23 Aug 2023 10:06:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F3D59F804DA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=CcqbhDyW DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777992; x=1724313992; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AVcQVAR0f8bmAJ2XCNv41aRcT8G6ctYlRQYBCNx8XB8=; b=CcqbhDyWJY7DbmYKjgG0FdaUoFu8Crq8d70j+6XsjLrZSXxOuTlSm/CV YBey6fuG3jKA7u0jsFahtKpDBbvoSMWnSFo9LLonltCaoeYwysA1zxyqm SITn5H/hehFpwYpw6zLPM4JCf0FR2xofov/SnpGucpYMUBxtn9vEChnbO GiXZV12TI/ULe374V3+P2UPWcUKNnIH8yz9Xfzf8a2oaWWgenRzT3iz2/ Nat7Cxp635fUAJelxQZS57GEVfA0qGuwzo915hPVaZ5g0NdB2QNTGg+gY 5j8jyJZEPeJ8ip6QRvhiV+ZIT9rragNMCmUt1o8vjq4eAK0LY0HD3WcBx w==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988115" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988115" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042747" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042747" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:27 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 11/17] ASoC: codecs: hdac_hdmi: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:40 +0200 Message-Id: <20230823080546.2224713-12-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: 4DCVXZTLBP5VUDU3ISSONZAX3A6PAK3K X-Message-ID-Hash: 4DCVXZTLBP5VUDU3ISSONZAX3A6PAK3K X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index fb3f8a565485..44837462dcd3 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -468,13 +468,14 @@ static int hdac_hdmi_set_hw_params(struct snd_pcm_substream *substream, struct hdac_hdmi_priv *hdmi = snd_soc_dai_get_drvdata(dai); struct hdac_hdmi_dai_port_map *dai_map; struct hdac_hdmi_pcm *pcm; + unsigned int bps; int format; dai_map = &hdmi->dai_map[dai->id]; - format = snd_hdac_calc_stream_format(params_rate(hparams), - params_channels(hparams), params_format(hparams), - dai->driver->playback.sig_bits, 0); + bps = snd_hdac_stream_format_bps(params_format(hparams), SNDRV_PCM_SUBFORMAT_STD, + dai->driver->playback.sig_bits); + format = snd_hdac_stream_format(params_channels(hparams), bps, params_rate(hparams)); pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt); if (!pcm) From patchwork Wed Aug 23 08:05:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361776 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8FBADEE49A0 for ; Wed, 23 Aug 2023 08:12:00 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A01EBDF8; Wed, 23 Aug 2023 10:11:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A01EBDF8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778318; bh=dx91wGcbcKiYReuN+nPdxxpptTHA9nnw+fhAZ4Q7cmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=EYHo+id7MJAnnQVrmencI6gReZ9Gh1eYQdHTh8HJidORNUuRi/zrBT0T1GHKXqz8M lCi1Hwx5e8d0ZiJuhsbdCBdQRTXRnKXaEj9BI8t+Htz3GPQn05VyxU30+PJuw+C3bg zSIPllfI5mVb3LcPoxZJrpgBNCOPUMw2AKC5isV4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 47C3DF805FE; Wed, 23 Aug 2023 10:07:53 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6174DF805FE; Wed, 23 Aug 2023 10:07:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 71223F8023B; Wed, 23 Aug 2023 10:06:47 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 27889F8025F for ; Wed, 23 Aug 2023 10:06:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 27889F8025F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ER+gXRPZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777993; x=1724313993; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dx91wGcbcKiYReuN+nPdxxpptTHA9nnw+fhAZ4Q7cmk=; b=ER+gXRPZlVcNvnf2hOKJd0qc2D4hiVhmCyNxSH03ie33iN1jmykd3eO+ WKHVz5ksP6gIlLyg3oR5x62Zlz2jSY/LQrz96RzHDkICaxVpl3x/TG4I1 anG+RB5EbJOyusl3w7RIUDE+aPWKX8VrLmBON3cSA1lXVGyTbVzDqF2HT gsOYNxZQIAS04cDOfQjyIxiHuXeE6Nyhvv2/6MdM2/NXOSnHSS2aGopGd 4QlSLxr7t5h8bS9I3T6FCacV3BEJVUlCTgbattReo+O5ppugAJBrfNcU9 0GUALIT0p5TrOUmhXQ7GgZ/TJDGM0mf7LIS2RRaq+JL+WxC7wuVxMxsER w==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988121" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988121" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042757" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042757" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:29 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 12/17] ASoC: Intel Skylake: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:41 +0200 Message-Id: <20230823080546.2224713-13-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: 7YQ3Z4YNWMXN57JORM4BYRBCQYG3BL5V X-Message-ID-Hash: 7YQ3Z4YNWMXN57JORM4BYRBCQYG3BL5V X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index ac3dc8c63c26..4613a1335819 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -128,6 +128,7 @@ int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params) unsigned int format_val; struct hdac_stream *hstream; struct hdac_ext_stream *stream; + unsigned int bps; int err; hstream = snd_hdac_get_stream(bus, params->stream, @@ -138,8 +139,8 @@ int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params) stream = stream_to_hdac_ext_stream(hstream); snd_hdac_ext_stream_decouple(bus, stream, true); - format_val = snd_hdac_calc_stream_format(params->s_freq, - params->ch, params->format, params->host_bps, 0); + bps = snd_hdac_stream_format_bps(params->format, SNDRV_PCM_SUBFORMAT_STD, params->host_bps); + format_val = snd_hdac_stream_format(params->ch, bps, params->s_freq); dev_dbg(dev, "format_val=%d, rate=%d, ch=%d, format=%d\n", format_val, params->s_freq, params->ch, params->format); @@ -177,6 +178,7 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) struct hdac_ext_stream *stream; struct hdac_ext_link *link; unsigned char stream_tag; + unsigned int bps; hstream = snd_hdac_get_stream(bus, params->stream, params->link_dma_id + 1); @@ -185,8 +187,9 @@ int skl_pcm_link_dma_prepare(struct device *dev, struct skl_pipe_params *params) stream = stream_to_hdac_ext_stream(hstream); snd_hdac_ext_stream_decouple(bus, stream, true); - format_val = snd_hdac_calc_stream_format(params->s_freq, params->ch, - params->format, params->link_bps, 0); + + bps = snd_hdac_stream_format_bps(params->format, SNDRV_PCM_SUBFORMAT_STD, params->link_bps); + format_val = snd_hdac_stream_format(params->ch, bps, params->s_freq); dev_dbg(dev, "format_val=%d, rate=%d, ch=%d, format=%d\n", format_val, params->s_freq, params->ch, params->format); From patchwork Wed Aug 23 08:05:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361777 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 6C31BEE49AE for ; Wed, 23 Aug 2023 08:12:24 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4F0FD84D; Wed, 23 Aug 2023 10:11:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4F0FD84D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778342; bh=z1C/1ra+Jw69lBFjbEpEPLpWSIEF15eimBoH/bFoe6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=XmPQzaj3mMafAje16zQJJvYLalGGe80wv3ruI2Y+gsz0IfHW1LvkJXsFIwnqgop62 6DN8qcpG4lc9ghzeBVvR++c4iPsxFmXcyYJgzKiuX9WAXdgnf+81qlwOqQ7zWkLXKv Zjeeq7pwFxSOOjtz795B2oWIpenixqrCnAeuCvp4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id BBC65F80607; Wed, 23 Aug 2023 10:07:54 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 132BAF80610; Wed, 23 Aug 2023 10:07:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 539E3F8023B; Wed, 23 Aug 2023 10:06:49 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 CFDF5F804F3 for ; Wed, 23 Aug 2023 10:06:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CFDF5F804F3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=kkjfOqei DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777995; x=1724313995; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=z1C/1ra+Jw69lBFjbEpEPLpWSIEF15eimBoH/bFoe6M=; b=kkjfOqeimcmQhjXUH0lWM6TLoddVPA7V1kKmYuN4pNzWdiBYnAayjxf/ KlT9BZIJ9Pw1kgJ4AIBSGgLcdm1Viouc5dxGgojEsti8XI7EYaNcbwgpN KjhJR6Gp2ylpSrrQ8Fd//NXrbR0akHjFrr0LmCWGJaUUjME2MngLRm4un 3K5pNdAMzYROBjh4JKFqgg2BRPgdb7QVUm9uypYddvPhsANVeN6Grl89u lUUDmUERDPSQJCHTeDqLzIa9tk8jgGW8OKUIsufcWTnQWF4WgrOjheQLf cj4eTApzEyvQd533S1FbrdxqLw+S9cZ5rJsLxw53e277RWfm03GkZoKm3 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988126" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988126" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042768" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042768" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:31 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 13/17] ASoC: SOF: Intel: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:42 +0200 Message-Id: <20230823080546.2224713-14-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: EJPEXZFP7TNE2DLOFV7QWYRJQ7SAW564 X-Message-ID-Hash: EJPEXZFP7TNE2DLOFV7QWYRJQ7SAW564 X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/sof/intel/hda-dai-ops.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai-ops.c b/sound/soc/sof/intel/hda-dai-ops.c index 494ced2b746e..18e06712372f 100644 --- a/sound/soc/sof/intel/hda-dai-ops.c +++ b/sound/soc/sof/intel/hda-dai-ops.c @@ -213,9 +213,10 @@ static unsigned int hda_calc_stream_format(struct snd_sof_dev *sdev, link_bps = codec_dai->driver->playback.sig_bits; else link_bps = codec_dai->driver->capture.sig_bits; + link_bps = snd_hdac_stream_format_bps(params_format(params), SNDRV_PCM_SUBFORMAT_STD, + link_bps); - format_val = snd_hdac_calc_stream_format(params_rate(params), params_channels(params), - params_format(params), link_bps, 0); + format_val = snd_hdac_stream_format(params_channels(params), link_bps, params_rate(params)); dev_dbg(sdev->dev, "format_val=%#x, rate=%d, ch=%d, format=%d\n", format_val, params_rate(params), params_channels(params), params_format(params)); @@ -238,11 +239,11 @@ static unsigned int generic_calc_stream_format(struct snd_sof_dev *sdev, struct snd_pcm_hw_params *params) { unsigned int format_val; + unsigned int bps; - format_val = snd_hdac_calc_stream_format(params_rate(params), params_channels(params), - params_format(params), - params_physical_width(params), - 0); + bps = snd_hdac_stream_format_bps(params_format(params), SNDRV_PCM_SUBFORMAT_STD, + params_physical_width(params)); + format_val = snd_hdac_stream_format(params_channels(params), bps, params_rate(params)); dev_dbg(sdev->dev, "format_val=%#x, rate=%d, ch=%d, format=%d\n", format_val, params_rate(params), params_channels(params), params_format(params)); @@ -258,6 +259,7 @@ static unsigned int dmic_calc_stream_format(struct snd_sof_dev *sdev, snd_pcm_format_t format; unsigned int channels; unsigned int width; + unsigned int bps; channels = params_channels(params); format = params_format(params); @@ -269,10 +271,8 @@ static unsigned int dmic_calc_stream_format(struct snd_sof_dev *sdev, width = 32; } - format_val = snd_hdac_calc_stream_format(params_rate(params), channels, - format, - width, - 0); + bps = snd_hdac_stream_format_bps(format, SNDRV_PCM_SUBFORMAT_STD, width); + format_val = snd_hdac_stream_format(channels, bps, params_rate(params)); dev_dbg(sdev->dev, "format_val=%#x, rate=%d, ch=%d, format=%d\n", format_val, params_rate(params), channels, format); From patchwork Wed Aug 23 08:05:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361784 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 4642CEE49A0 for ; Wed, 23 Aug 2023 08:12:47 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 55DBDE0F; Wed, 23 Aug 2023 10:11:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 55DBDE0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778365; bh=izA1n1DCgfjUl0ghl/g49H55RJ/WcWaXKKm0lXOBEiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=F2jhkkKJFMROaXir2jUbOgwxAZ8OLE61plvMo+MmVx0mz4jXC2AUBMhmgp+aCBwSN lO/FNk3jIG4rLO5kYSA9qpCVm1GtEv0r1Vm8nUWE9s6MWToYwRtYzP3xGf1YGV9qI/ Hndu0tKTlGSzfUcRh/JR9ggu4j0qu791o7n1S/a8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A8EAFF80611; Wed, 23 Aug 2023 10:07:57 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 311CEF80616; Wed, 23 Aug 2023 10:07:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0CF3CF8023B; Wed, 23 Aug 2023 10:06:50 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 1E890F800F5 for ; Wed, 23 Aug 2023 10:06:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1E890F800F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=agVaz8Wg DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692777999; x=1724313999; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=izA1n1DCgfjUl0ghl/g49H55RJ/WcWaXKKm0lXOBEiI=; b=agVaz8Wgl+NRLFBvELDY0C6obeLS+zzWlytDjHHXHwxYhUGS1SHB7Xdg wonu9T2jLj1TzyMs8yhG0sAP6D/sxeNibQVkSHgbYFxwm8b+XdZY76FcW bWChFsIXweik/C/GUhkm/KWLlaWDvrGPacClY1FWIN9c2FqbWy55viN0m FD7sydzbGOmvQeuLpNpNXVqUqHhk7/wpIRNKl1hji+qT+ACqu4gEcz4PL GoQtv/jFHb6dJgf0pfRBO27167ZCio5po7l43ZkGjJDH13MzFK6Ids/H7 Y09/VNn76sz1qFN+7zTRILzPAFXB3A9aXVHVfbu7AkgEAq3fFi0PSg5fv A==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988134" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988134" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042783" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042783" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:33 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 14/17] ASoC: Intel: avs: Switch to new stream-format interface Date: Wed, 23 Aug 2023 10:05:43 +0200 Message-Id: <20230823080546.2224713-15-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: SXKV3POFF2O7G4VJUIUKFOB7JAT2DCOD X-Message-ID-Hash: SXKV3POFF2O7G4VJUIUKFOB7JAT2DCOD X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/intel/avs/loader.c | 4 ++-- sound/soc/intel/avs/path.c | 2 +- sound/soc/intel/avs/pcm.c | 19 ++++++++++++++----- sound/soc/intel/avs/probes.c | 3 +-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/avs/loader.c b/sound/soc/intel/avs/loader.c index 56bb0a59249d..2e3dd3d86b16 100644 --- a/sound/soc/intel/avs/loader.c +++ b/sound/soc/intel/avs/loader.c @@ -371,7 +371,7 @@ int avs_hda_load_basefw(struct avs_dev *adev, struct firmware *fw) hstream = hdac_stream(estream); /* code loading performed with default format */ - sdfmt = snd_hdac_calc_stream_format(48000, 1, SNDRV_PCM_FORMAT_S32_LE, 32, 0); + sdfmt = snd_hdac_stream_format(1, 32, 48000); ret = snd_hdac_dsp_prepare(hstream, sdfmt, fw->size, &dmab); if (ret < 0) goto release_stream; @@ -438,7 +438,7 @@ int avs_hda_load_library(struct avs_dev *adev, struct firmware *lib, u32 id) stream = hdac_stream(estream); /* code loading performed with default format */ - sdfmt = snd_hdac_calc_stream_format(48000, 1, SNDRV_PCM_FORMAT_S32_LE, 32, 0); + sdfmt = snd_hdac_stream_format(1, 32, 48000); ret = snd_hdac_dsp_prepare(stream, sdfmt, lib->size, &dmab); if (ret < 0) goto release_stream; diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index adbe23a47847..be9e455ee0a2 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -87,7 +87,7 @@ static bool avs_test_hw_params(struct snd_pcm_hw_params *params, return (params_rate(params) == fmt->sampling_freq && params_channels(params) == fmt->num_channels && params_physical_width(params) == fmt->bit_depth && - params_width(params) == fmt->valid_bit_depth); + snd_pcm_hw_params_bps(params) == fmt->valid_bit_depth); } static struct avs_tplg_path * diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 1fbb2c2fadb5..ea6b784f2067 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -335,20 +335,25 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn { struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); struct snd_pcm_runtime *runtime = substream->runtime; - struct hdac_ext_stream *link_stream = runtime->private_data; + struct snd_soc_pcm_stream *stream_info; + struct hdac_ext_stream *link_stream; struct hdac_ext_link *link; struct hda_codec *codec; struct hdac_bus *bus; unsigned int format_val; + unsigned int bps; int ret; + link_stream = runtime->private_data; if (link_stream->link_prepared) return 0; codec = dev_to_hda_codec(asoc_rtd_to_codec(rtd, 0)->dev); bus = &codec->bus->core; - format_val = snd_hdac_calc_stream_format(runtime->rate, runtime->channels, runtime->format, - runtime->sample_bits, 0); + stream_info = snd_soc_dai_get_pcm_stream(dai, substream->stream); + bps = snd_hdac_stream_format_bps(runtime->format, runtime->subformat, + stream_info->sig_bits); + format_val = snd_hdac_stream_format(runtime->channels, bps, runtime->rate); snd_hdac_ext_stream_decouple(bus, link_stream, true); snd_hdac_ext_stream_reset(link_stream); @@ -601,11 +606,13 @@ static int avs_dai_fe_hw_free(struct snd_pcm_substream *substream, struct snd_so static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_stream *stream_info; struct avs_dma_data *data; struct avs_dev *adev = to_avs_dev(dai->dev); struct hdac_ext_stream *host_stream; struct hdac_bus *bus; unsigned int format_val; + unsigned int bps; int ret; data = snd_soc_dai_get_dma_data(dai, substream); @@ -618,8 +625,10 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so snd_hdac_ext_stream_decouple(bus, data->host_stream, true); snd_hdac_stream_reset(hdac_stream(host_stream)); - format_val = snd_hdac_calc_stream_format(runtime->rate, runtime->channels, runtime->format, - runtime->sample_bits, 0); + stream_info = snd_soc_dai_get_pcm_stream(dai, substream->stream); + bps = snd_hdac_stream_format_bps(runtime->format, runtime->subformat, + stream_info->sig_bits); + format_val = snd_hdac_stream_format(runtime->channels, bps, runtime->rate); ret = snd_hdac_stream_set_params(hdac_stream(host_stream), format_val); if (ret < 0) diff --git a/sound/soc/intel/avs/probes.c b/sound/soc/intel/avs/probes.c index 4cab8c6c4576..7d0aab3f2ada 100644 --- a/sound/soc/intel/avs/probes.c +++ b/sound/soc/intel/avs/probes.c @@ -140,8 +140,7 @@ static int avs_probe_compr_set_params(struct snd_compr_stream *cstream, bps = snd_pcm_format_physical_width(format); if (bps < 0) return bps; - format_val = snd_hdac_calc_stream_format(params->codec.sample_rate, params->codec.ch_out, - format, bps, 0); + format_val = snd_hdac_stream_format(params->codec.ch_out, bps, params->codec.sample_rate); ret = snd_hdac_stream_set_params(hdac_stream(host_stream), format_val); if (ret < 0) return ret; From patchwork Wed Aug 23 08:05:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361775 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 79EE3EE49A0 for ; Wed, 23 Aug 2023 08:11:56 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A13D6DF9; Wed, 23 Aug 2023 10:11:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A13D6DF9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778313; bh=vlSuAzI0VSYvtV5qB1Pi+gU8WtqdtkXIdcafebGk+tY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=SOyDyZrqjh8EwydveNLR+PlDVu+0QXDKJJpjoHz+o2LsQJWCghiRhYmh275DO4cx8 0vDzPO4bnAx3oYJdQ92Ipu8Hz9Zcv8/9+NhNkn+yePPeJc/g2CQXykPyDLAJ5wagqf 3t6EzvZzpJ7bGHp5dOmnxPa1xUkrLBlvlv3kanqM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3F9A8F80600; Wed, 23 Aug 2023 10:07:50 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C21E1F805FD; Wed, 23 Aug 2023 10:07:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 07867F8023B; Wed, 23 Aug 2023 10:06:46 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 D8DC5F80158 for ; Wed, 23 Aug 2023 10:06:39 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D8DC5F80158 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QknyBh7l DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692778001; x=1724314001; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vlSuAzI0VSYvtV5qB1Pi+gU8WtqdtkXIdcafebGk+tY=; b=QknyBh7l84OAKlIRbgHOFGx4ZGZQpPRNRFNCqAEDNukpyCloeUgKGz2o xrgH5fdRQ/kG06lDbk7i6IQ57FTtQbjq4U2injd16E3cORu516TfKSfxA sl5Mx/t0XidrY01rqISS8qDzl54ZjQN/2pqPJuY5ibzGNmMLzhN9DwV8S LMVsTMd5yXwIPY4ASQaI6gwOHdkNw31ZmoViwfc7wGm4ps2xH8aIjSe+S jLtj7xbOGbfcbXrDQHaZ6pK89g2UMC/qBCoO4JS5JsxelVIgSVkXNZPRf OsUCpvpEoIZi4WA0xCVYHdAf6tb0vqySOKRVV7+VnjyygZwsJHLvVMcvj w==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988145" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988145" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042815" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042815" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:36 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 15/17] ALSA: hda: Drop snd_hdac_calc_stream_format() Date: Wed, 23 Aug 2023 10:05:44 +0200 Message-Id: <20230823080546.2224713-16-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: LHLFWVBHY6WTEHXXI5GIENDZXRZDGPEK X-Message-ID-Hash: LHLFWVBHY6WTEHXXI5GIENDZXRZDGPEK X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: There are no users of the function. Signed-off-by: Cezary Rojewski --- include/sound/hdaudio.h | 5 ---- sound/hda/hdac_device.c | 61 ----------------------------------------- 2 files changed, 66 deletions(-) diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h index a7c2f02110fa..24d689b95cac 100644 --- a/include/sound/hdaudio.h +++ b/include/sound/hdaudio.h @@ -145,11 +145,6 @@ unsigned int snd_hdac_stream_format_bps(snd_pcm_format_t format, snd_pcm_subform unsigned int snd_hdac_stream_format(unsigned int channels, unsigned int bps, unsigned int rate); unsigned int snd_hdac_spdif_stream_format(unsigned int channels, unsigned int bps, unsigned int rate, unsigned short spdif_ctls); -unsigned int snd_hdac_calc_stream_format(unsigned int rate, - unsigned int channels, - snd_pcm_format_t format, - unsigned int maxbps, - unsigned short spdif_ctls); int snd_hdac_query_supported_pcm(struct hdac_device *codec, hda_nid_t nid, u32 *ratesp, u64 *formatsp, u64 *subformatsp, unsigned int *bpsp); bool snd_hdac_is_supported_format(struct hdac_device *codec, hda_nid_t nid, diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index 13e27d38f2fe..612d780d69f4 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c @@ -849,67 +849,6 @@ unsigned int snd_hdac_spdif_stream_format(unsigned int channels, unsigned int bp } EXPORT_SYMBOL_GPL(snd_hdac_spdif_stream_format); -/** - * snd_hdac_calc_stream_format - calculate the format bitset - * @rate: the sample rate - * @channels: the number of channels - * @format: the PCM format (SNDRV_PCM_FORMAT_XXX) - * @maxbps: the max. bps - * @spdif_ctls: HD-audio SPDIF status bits (0 if irrelevant) - * - * Calculate the format bitset from the given rate, channels and th PCM format. - * - * Return zero if invalid. - */ -unsigned int snd_hdac_calc_stream_format(unsigned int rate, - unsigned int channels, - snd_pcm_format_t format, - unsigned int maxbps, - unsigned short spdif_ctls) -{ - int i; - unsigned int val = 0; - - for (i = 0; rate_bits[i].hz; i++) - if (rate_bits[i].hz == rate) { - val = rate_bits[i].hda_fmt; - break; - } - if (!rate_bits[i].hz) - return 0; - - if (channels == 0 || channels > 8) - return 0; - val |= channels - 1; - - switch (snd_pcm_format_width(format)) { - case 8: - val |= AC_FMT_BITS_8; - break; - case 16: - val |= AC_FMT_BITS_16; - break; - case 20: - case 24: - case 32: - if (maxbps >= 32 || format == SNDRV_PCM_FORMAT_FLOAT_LE) - val |= AC_FMT_BITS_32; - else if (maxbps >= 24) - val |= AC_FMT_BITS_24; - else - val |= AC_FMT_BITS_20; - break; - default: - return 0; - } - - if (spdif_ctls & AC_DIG1_NONAUDIO) - val |= AC_FMT_TYPE_NON_PCM; - - return val; -} -EXPORT_SYMBOL_GPL(snd_hdac_calc_stream_format); - static unsigned int query_pcm_param(struct hdac_device *codec, hda_nid_t nid) { unsigned int val = 0; From patchwork Wed Aug 23 08:05:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361785 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8907FEE49A0 for ; Wed, 23 Aug 2023 08:12:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B712CDEE; Wed, 23 Aug 2023 10:12:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B712CDEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778371; bh=pxBNXO64K9unZiTOdk/OKUaxm1RkB61pKYVuva7LQyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=mVlxIqbx6eTuDiSpP+ZxI9mAiZgQJBeYat3XSPISZIn8daMCcGw9vdZ460KIpME5L qt7IWkvogzzTRKGqwFoaaPonE6NthQm14cQIywrGOaUcSMSssazHAV42TtKmozwRDO HjFdZC+U7vL3Nu5GUpyEGakHT2TTg9nWA6dAabVo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9FB68F80623; Wed, 23 Aug 2023 10:07:59 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 042BCF80621; Wed, 23 Aug 2023 10:07:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1F7EEF8022B; Wed, 23 Aug 2023 10:06:52 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 B9D53F800D1 for ; Wed, 23 Aug 2023 10:06:43 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B9D53F800D1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=gXW9IMdR DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692778004; x=1724314004; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pxBNXO64K9unZiTOdk/OKUaxm1RkB61pKYVuva7LQyo=; b=gXW9IMdRUE79IMJvCb0t86rZF/OudTZnhSjAP1bxAB/hnDFv5i4DTJMT C2kH+uhnW/MEmwcRh18aR74J/Euxo2qzaywV8PWxkZPdtrual/yblxXM6 63DwzpMLIXgO/w4ZWjw59kKDZXu32Y2PrP3yUMcPlfxIjNo7FqyNZCZEh DO8yQBkol40Dain2OSNy4HP+6GQqd8fVC83pPeo2+0azY8GjjMy/3a+nM vwvHRgtc238CG0t5ZVx3VRN0NJdIplIQ1hJ8E2Jcv8bEfG5W+YQKho1CZ TRblJDeYawo09O3I6tHBC9K44J+Y6DVca/Sivz0EqAPrRmGEzFNqmR2ZY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988155" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988155" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042854" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042854" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:38 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 16/17] ASoC: Intel: avs: Kill S24_LE in HDAudio streaming Date: Wed, 23 Aug 2023 10:05:45 +0200 Message-Id: <20230823080546.2224713-17-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: G2TSL4BIRT2TF6L2TLAQVBL7OSVVTWKQ X-Message-ID-Hash: G2TSL4BIRT2TF6L2TLAQVBL7OSVVTWKQ X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Eliminate all occurrences of S24_LE within the HDAudio related pcm code, both HOST and LINK side. Replace those with MSBITS subformats to allow for granular selection when S32_LE is the format of choice. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/intel/avs/pcm.c | 12 +++++++++--- sound/soc/intel/avs/topology.c | 9 ++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index ea6b784f2067..22f897db6fce 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -1055,8 +1055,10 @@ static const struct snd_pcm_hardware avs_pcm_hardware = { SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .subformats = SNDRV_PCM_SUBFMTBIT_MSBITS_20 | + SNDRV_PCM_SUBFMTBIT_MSBITS_24 | + SNDRV_PCM_SUBFMTBIT_MSBITS_32, .buffer_bytes_max = AZX_MAX_BUF_SIZE, .period_bytes_min = 128, .period_bytes_max = AZX_MAX_BUF_SIZE / 2, @@ -1286,16 +1288,20 @@ static const struct snd_soc_dai_driver hda_cpu_dai = { .channels_max = 8, .rates = SNDRV_PCM_RATE_8000_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .subformats = SNDRV_PCM_SUBFMTBIT_MSBITS_20 | + SNDRV_PCM_SUBFMTBIT_MSBITS_24 | + SNDRV_PCM_SUBFMTBIT_MSBITS_32, }, .capture = { .channels_min = 1, .channels_max = 8, .rates = SNDRV_PCM_RATE_8000_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE | - SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE, + .subformats = SNDRV_PCM_SUBFMTBIT_MSBITS_20 | + SNDRV_PCM_SUBFMTBIT_MSBITS_24 | + SNDRV_PCM_SUBFMTBIT_MSBITS_32, }, }; diff --git a/sound/soc/intel/avs/topology.c b/sound/soc/intel/avs/topology.c index 45d0eb2a8e71..3dab3c3efe3b 100644 --- a/sound/soc/intel/avs/topology.c +++ b/sound/soc/intel/avs/topology.c @@ -1456,8 +1456,15 @@ static int avs_dai_load(struct snd_soc_component *comp, int index, struct snd_soc_dai_driver *dai_drv, struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai) { - if (pcm) + u64 subformats = SNDRV_PCM_SUBFMTBIT_MSBITS_20 | + SNDRV_PCM_SUBFMTBIT_MSBITS_24; + + if (pcm) { dai_drv->ops = &avs_dai_fe_ops; + dai_drv->capture.subformats |= subformats; + dai_drv->playback.subformats |= subformats; + } + return 0; } From patchwork Wed Aug 23 08:05:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13361786 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 35F72EE49A0 for ; Wed, 23 Aug 2023 08:13:12 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 68935DEB; Wed, 23 Aug 2023 10:12:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 68935DEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1692778390; bh=gHyPJ3l7zvgqH5EYgzVMSb18tIgvF5ZMBgcOmAps6Nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=VZ/GahZDBxsuX4S3RGLnYTDnVMVxIKHfY5xiiugHNd4naSEhccJwnXPk7dH6vwLjU X2In/3w5cHitzJMRfDfdo10qeVpqGHaO4bkChxA8jER0d5F7OAAieg6VtlBWkBXsFq 5JPj6LhoiLOIjJJM1xGiht8yRa/d9dd6Sihvk1Y0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 782F8F80635; Wed, 23 Aug 2023 10:08:02 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CE8DCF80631; Wed, 23 Aug 2023 10:08:01 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AF4D6F80158; Wed, 23 Aug 2023 10:06:54 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) (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 B7274F80022 for ; Wed, 23 Aug 2023 10:06:45 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B7274F80022 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=YXv59FNN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692778006; x=1724314006; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gHyPJ3l7zvgqH5EYgzVMSb18tIgvF5ZMBgcOmAps6Nw=; b=YXv59FNN57Ax7lJhuBedikhbw+VjCZTwP0f4HiYuc7aJi/NEXjEOtieN k+NCujS1S0NYCzcx80Wbh6dY0pPDZytkLTB+1lDUPCnKyMl+suSR8TLqu FsIwl5PDOpg9vyOuchbllclGxHzndDHshg3rkZK+1M2DYTefOfJ7ixoRU NQCb/Ho0eDXX7kVaMA/kKvtfWY+EpcBbubrsK1D78/WeLuhUjfwJWooOJ cwY0hmR9Cdt340Ds+fBda7ovNRENxv34vf6Bb6X3WePFamZisKqH0MiRr d7495zNgeIvwXKb7vv7iCJ/f9/gQSCslyLiFGJ5es15kCnYDdwAa/NKaO w==; X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="372988168" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="372988168" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Aug 2023 01:06:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10810"; a="766042896" X-IronPort-AV: E=Sophos;i="6.01,195,1684825200"; d="scan'208";a="766042896" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by orsmga008.jf.intel.com with ESMTP; 23 Aug 2023 01:06:40 -0700 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH 17/17] ASoC: Intel: avs: Unhardcode HDAudio BE DAI drivers description Date: Wed, 23 Aug 2023 10:05:46 +0200 Message-Id: <20230823080546.2224713-18-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823080546.2224713-1-cezary.rojewski@intel.com> References: <20230823080546.2224713-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: NRU4GP66PRBVS6THE72LA6CIZVHF6COR X-Message-ID-Hash: NRU4GP66PRBVS6THE72LA6CIZVHF6COR X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: To not expose more than in fact is supported by the codec, update CPU DAI initialization procedure to rely on codec capabilities instead of hardcoding them. This includes subformat which is currently ignored. As capabilities for HDMI streams are initialized on PCM open, leave it as is for now. Signed-off-by: Cezary Rojewski Acked-by: Mark Brown --- sound/soc/intel/avs/pcm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 22f897db6fce..895eba3db6f0 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -17,6 +17,7 @@ #include "avs.h" #include "path.h" #include "topology.h" +#include "../../codecs/hda.h" struct avs_dma_data { struct avs_tplg_path_template *template; @@ -1378,6 +1379,15 @@ static int avs_component_hda_probe(struct snd_soc_component *component) ret = -ENOMEM; goto exit; } + + if (!hda_codec_is_display(codec)) { + dais[i].playback.formats = pcm->stream[0].formats; + dais[i].playback.subformats = pcm->stream[0].subformats; + dais[i].playback.rates = pcm->stream[0].rates; + dais[i].playback.channels_min = pcm->stream[0].channels_min; + dais[i].playback.channels_max = pcm->stream[0].channels_max; + dais[i].playback.sig_bits = pcm->stream[0].maxbps; + } } if (pcm->stream[1].substreams) { @@ -1388,6 +1398,15 @@ static int avs_component_hda_probe(struct snd_soc_component *component) ret = -ENOMEM; goto exit; } + + if (!hda_codec_is_display(codec)) { + dais[i].capture.formats = pcm->stream[1].formats; + dais[i].capture.subformats = pcm->stream[1].subformats; + dais[i].capture.rates = pcm->stream[1].rates; + dais[i].capture.channels_min = pcm->stream[1].channels_min; + dais[i].capture.channels_max = pcm->stream[1].channels_max; + dais[i].capture.sig_bits = pcm->stream[1].maxbps; + } } dai = snd_soc_register_dai(component, &dais[i], false);