From patchwork Wed Nov 23 16:49:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 627933 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 4F41BC4332F for ; Wed, 23 Nov 2022 16:53:02 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7C1E71675; Wed, 23 Nov 2022 17:52:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7C1E71675 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222380; bh=Czzp1UPXde2kFxprFFdQcPR+NILMAHyfDB1Ek/jZ1Ug=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qgyHL5kRBv/X3Tv4bfevtX5vK8nWG6FbXNzRDSXtQwk7Ua4zveFrxyYf7UeCGpfQI Y4GexvoDQL7bmuyvNPljeqDMEujOWXrfsgKwVMLM01uyuBGo5f1ws8/rK0Q0jJK+1g JlCUOcK4P4IMRo/5foTD3Fb5GrVpJhgvTP+v27bM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D0A73F805AB; Wed, 23 Nov 2022 17:50:06 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1FA32F80580; Wed, 23 Nov 2022 17:50:00 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 A5B05F80542 for ; Wed, 23 Nov 2022 17:49:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A5B05F80542 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="UjgJGrTx" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFYpmY019647; Wed, 23 Nov 2022 10:49:43 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=eoKHMJPkAP8VwD9qJAm/L/oeiY3tRwwHhVeEMH+6wwU=; b=UjgJGrTxwLQV0+RHFHb1BbUhs7dIei0S/NspYR/aDzd9e7DmIupjRSpoWg6SbfP1cJTL FuCqx8BnGJk4E1Y3oCKoLIC5DSCwH+D6cHZQ/F9p9UdFQKi/Q2d+1Se3nSwQ84Eftpwe TCj1RxkYpiSr4k2REcESXMOTTcpTJASIAqWwIEmuwnPHOYaZrcYXhIe8fluZ07xoBtdX AyWXrJOGV9XdUa75uGhyFu2QejAGj03BZPDtQI1HvvJgASNvhWDGaX8/+0pS/S5vZZVo izX2cLCcGlFqUYQ3yb0lvMYTcKmmS11yXYiSEL9JJ08BmVc//c5BjEGhIkArEBtHDmFA Nw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet55fe-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:49:42 -0600 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Wed, 23 Nov 2022 10:49:38 -0600 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.20 via Frontend Transport; Wed, 23 Nov 2022 10:49:38 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B00C22BA; Wed, 23 Nov 2022 16:49:38 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v2 7/9] ASoC: rt711: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:49:35 +0000 Message-ID: <20221123164937.594837-7-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123164937.594837-1-ckeepax@opensource.cirrus.com> References: <20221123164937.594837-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: a1NK_GIe_4bO487aJ_lvCqt0m_uuiW-w X-Proofpoint-GUID: a1NK_GIe_4bO487aJ_lvCqt0m_uuiW-w X-Proofpoint-Spam-Reason: safe Cc: oder_chiou@realtek.com, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" The conversion from hw_params to SoundWire config is pretty standard as such most of the conversation can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v1: - Correct spelling error in commit message sound/soc/codecs/rt711-sdca.c | 27 +++++++++------------------ sound/soc/codecs/rt711.c | 27 +++++++++------------------ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/sound/soc/codecs/rt711-sdca.c b/sound/soc/codecs/rt711-sdca.c index 9252681219017..b78dd5994edbf 100644 --- a/sound/soc/codecs/rt711-sdca.c +++ b/sound/soc/codecs/rt711-sdca.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1257,11 +1258,10 @@ static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component); - struct sdw_stream_config stream_config; - struct sdw_port_config port_config; - enum sdw_data_direction direction; + struct sdw_stream_config stream_config = {0}; + struct sdw_port_config port_config = {0}; struct sdw_stream_data *stream; - int retval, port, num_channels; + int retval; unsigned int sampling_rate; dev_dbg(dai->dev, "%s %s", __func__, dai->name); @@ -1274,28 +1274,19 @@ static int rt711_sdca_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* SoundWire specific configuration */ + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; - port = 3; + port_config.num = 3; } else { - direction = SDW_DATA_DIR_TX; if (dai->id == RT711_AIF1) - port = 2; + port_config.num = 2; else if (dai->id == RT711_AIF2) - port = 4; + port_config.num = 4; else return -EINVAL; } - stream_config.frame_rate = params_rate(params); - stream_config.ch_count = params_channels(params); - stream_config.bps = snd_pcm_format_width(params_format(params)); - stream_config.direction = direction; - - num_channels = params_channels(params); - port_config.ch_mask = GENMASK(num_channels - 1, 0); - port_config.num = port; - retval = sdw_stream_add_slave(rt711->slave, &stream_config, &port_config, 1, stream->sdw_stream); if (retval) { diff --git a/sound/soc/codecs/rt711.c b/sound/soc/codecs/rt711.c index 1bf6180891942..78e1da9b07388 100644 --- a/sound/soc/codecs/rt711.c +++ b/sound/soc/codecs/rt711.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -999,11 +1000,10 @@ static int rt711_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component); - struct sdw_stream_config stream_config; - struct sdw_port_config port_config; - enum sdw_data_direction direction; + struct sdw_stream_config stream_config = {0}; + struct sdw_port_config port_config = {0}; struct sdw_stream_data *stream; - int retval, port, num_channels; + int retval; unsigned int val = 0; dev_dbg(dai->dev, "%s %s", __func__, dai->name); @@ -1016,28 +1016,19 @@ static int rt711_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* SoundWire specific configuration */ + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; - port = 3; + port_config.num = 3; } else { - direction = SDW_DATA_DIR_TX; if (dai->id == RT711_AIF1) - port = 4; + port_config.num = 4; else if (dai->id == RT711_AIF2) - port = 2; + port_config.num = 2; else return -EINVAL; } - stream_config.frame_rate = params_rate(params); - stream_config.ch_count = params_channels(params); - stream_config.bps = snd_pcm_format_width(params_format(params)); - stream_config.direction = direction; - - num_channels = params_channels(params); - port_config.ch_mask = (1 << (num_channels)) - 1; - port_config.num = port; - retval = sdw_stream_add_slave(rt711->slave, &stream_config, &port_config, 1, stream->sdw_stream); if (retval) {