From patchwork Mon May 15 10:33:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 13241243 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 E26DCC77B75 for ; Mon, 15 May 2023 10:35:10 +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 891D31E7; Mon, 15 May 2023 12:34:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 891D31E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1684146908; bh=PzQ1+C3Lh0ZemRTOUhxLoLdIDWF6WwW4mkxtnL6k3f0=; 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=sad+GS4kHQo8SasTv+Of2/1F7wiOzFiCepxv8NEGtA4mDMmb/36QI0lkNKORWaY73 THvWCjYzIK+CzWU8b+2jWDjhkzXiVaADTYRDybCOL34cUV7HDgLFKpqLmMp9FPtoMl OviHpPy5GSMLDlBanB9Hugvv2oszEMOxPpTm77tA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 65482F805A0; Mon, 15 May 2023 12:33:12 +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 4CBC9F805A9; Mon, 15 May 2023 12:33:11 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1C0EDF8016D; Mon, 15 May 2023 12:32:59 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 109D6F8016D for ; Mon, 15 May 2023 12:32:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 109D6F8016D 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=jjwa39ez DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684146770; x=1715682770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PzQ1+C3Lh0ZemRTOUhxLoLdIDWF6WwW4mkxtnL6k3f0=; b=jjwa39ezUc+NA36gZozk0ihkZYTYrzbYyO/dPB5e3O1Gk+vXvh3sIz+P RmGFFo51SmdrCym+LRcwdbrr5lFWq5sSDXPq3h3+FQb11AQZlpSfsPZkH aBOAXQWpDPke5ymrfWXDLG3d8yjqt4jiYxvndYNSd253/BH82pN6Uaeeh qwpnOExQTbjfzEez/E0CR4fcn5is8VLD/pIKOyOKvRFSuOUvo5KcjNWuJ bssG9CppdCcY2Y4GTOg5phMJIP8p2dfiFG8QwIYMPZJlUyJZprYm9wGnW OtDiQG2FuzPS6NQEsw8TsFJtXltj5fnfcSawQjOBIAWhcRG0oV1GRVurf Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="351200343" X-IronPort-AV: E=Sophos;i="5.99,276,1677571200"; d="scan'208";a="351200343" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2023 03:32:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10710"; a="694967638" X-IronPort-AV: E=Sophos;i="5.99,276,1677571200"; d="scan'208";a="694967638" Received: from lpilolli-mobl.ger.corp.intel.com (HELO pujfalus-desk.ger.corp.intel.com) ([10.252.48.230]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2023 03:32:43 -0700 From: Peter Ujfalusi To: lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, pierre-louis.bossart@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, yung-chuan.liao@linux.intel.com Subject: [PATCH 1/9] ASoC: SOF: ipc4-topology: Handle input/output audio format special case Date: Mon, 15 May 2023 13:33:28 +0300 Message-Id: <20230515103336.16132-2-peter.ujfalusi@linux.intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515103336.16132-1-peter.ujfalusi@linux.intel.com> References: <20230515103336.16132-1-peter.ujfalusi@linux.intel.com> MIME-Version: 1.0 Message-ID-Hash: AVGN6KOA7TFY54QJFPFPZ72WFC6IVLGS X-Message-ID-Hash: AVGN6KOA7TFY54QJFPFPZ72WFC6IVLGS X-MailFrom: peter.ujfalusi@linux.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: From: Ranjani Sridharan When there is only one input/output format specified in topology, there is no need to search for a matching format, simply pick the available one. This is in preparation to modify and split the selection logic for the input and output audio formats. Signed-off-by: Ranjani Sridharan Reviewed-by: Bard Liao Reviewed-by: Pierre-Louis Bossart Signed-off-by: Peter Ujfalusi --- sound/soc/sof/ipc4-topology.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/ipc4-topology.c b/sound/soc/sof/ipc4-topology.c index 059eebf0a687..3e59551b2367 100644 --- a/sound/soc/sof/ipc4-topology.c +++ b/sound/soc/sof/ipc4-topology.c @@ -1039,7 +1039,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, u32 channels; u32 rate; int sample_valid_bits; - int i; + int i = 0; if (!pin_fmts) { dev_err(sdev->dev, "no reference formats for %s\n", swidget->widget->name); @@ -1066,6 +1066,10 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, return -EINVAL; } + /* pick the only available input format */ + if (available_fmt->num_input_formats == 1) + goto in_fmt; + /* * Search supported audio formats with pin index 0 to match rate, channels ,and * sample_valid_bytes from runtime params @@ -1093,6 +1097,7 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, return -EINVAL; } +in_fmt: /* copy input format */ if (available_fmt->num_input_formats && i < available_fmt->num_input_formats) { memcpy(&base_config->audio_fmt, &available_fmt->input_pin_fmts[i].audio_fmt, @@ -1105,6 +1110,10 @@ static int sof_ipc4_init_audio_fmt(struct snd_sof_dev *sdev, sof_ipc4_dbg_audio_format(sdev->dev, &available_fmt->input_pin_fmts[i], 1); } + /* pick the only available output format */ + if (available_fmt->num_output_formats == 1) + i = 0; + if (available_fmt->num_output_formats && i < available_fmt->num_output_formats) base_config->obs = available_fmt->output_pin_fmts[i].buffer_size;