From patchwork Fri Nov 17 12:06:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 13458887 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8253EC197A0 for ; Fri, 17 Nov 2023 12:04:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229436AbjKQME2 (ORCPT ); Fri, 17 Nov 2023 07:04:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231301AbjKQMEY (ORCPT ); Fri, 17 Nov 2023 07:04:24 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B0E9B9 for ; Fri, 17 Nov 2023 04:04:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700222661; x=1731758661; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+fWRWVCYW5uARD7h3RAGmaEQlLouiu/hBV+2DhtxCOM=; b=CZkVmtFrKRaNQC4SuHJjU8Ya1cd8+K/E1Xe5YeIKgLhBP7P6tayPBZcp /NRHaweU6De/+QwOhf7sCtgiBcqCwct2LZuw6vGffd5UJU6MpbULvpnmI HaMWf4GOFleY6w+caDzL1HAoIKiGZb0yK94GBSdEN4mZkl1RT6NHwAZac 8PNasMjo0KgS3J2wcr6U0fr5DNgcLv1YBQ3InuvX3mIQ3BNoAeTIChaO2 lWqrS2o4kl3IzxFA2GNKwnuVUGfy+f195A1FzYJLMuyg2XyJ4w6V5Imvm 4x1drObmb5YtUiBsWD97ZD6lptw7c02u99g2YTrU9eULncwjQU4vgDcgq A==; X-IronPort-AV: E=McAfee;i="6600,9927,10896"; a="381675253" X-IronPort-AV: E=Sophos;i="6.04,206,1695711600"; d="scan'208";a="381675253" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2023 04:04:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10896"; a="883110186" X-IronPort-AV: E=Sophos;i="6.04,206,1695711600"; d="scan'208";a="883110186" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmsmga002.fm.intel.com with ESMTP; 17 Nov 2023 04:04:18 -0800 From: Cezary Rojewski To: broonie@kernel.org, tiwai@suse.com, perex@perex.cz Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, amadeuszx.slawinski@linux.intel.com, pierre-louis.bossart@linux.intel.com, hdegoede@redhat.com, Cezary Rojewski Subject: [PATCH v5 08/16] ASoC: codecs: hda: Switch to new stream-format interface Date: Fri, 17 Nov 2023 13:06:02 +0100 Message-Id: <20231117120610.1755254-9-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231117120610.1755254-1-cezary.rojewski@intel.com> References: <20231117120610.1755254-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sound@vger.kernel.org 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. Acked-by: Mark Brown Signed-off-by: Cezary Rojewski --- sound/soc/codecs/hda-dai.c | 7 +++++-- sound/soc/codecs/hda.c | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/hda-dai.c b/sound/soc/codecs/hda-dai.c index 5371ff086261..7bd7ddcd810f 100644 --- a/sound/soc/codecs/hda-dai.c +++ b/sound/soc/codecs/hda-dai.c @@ -76,13 +76,16 @@ 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 bits; 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); + + bits = snd_hdac_stream_format_bits(runtime->format, runtime->subformat, + stream_info->maxbps); + format = snd_hdac_stream_format(runtime->channels, bits, 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; }