From patchwork Mon Nov 21 13:46:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050961 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 24E5EC4332F for ; Mon, 21 Nov 2022 13:48:08 +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 4712D15E0; Mon, 21 Nov 2022 14:47:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4712D15E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038486; bh=YhMUvmSn60afuseyyGAh3o011Cq0ZmSMs/ZYCFLwzlo=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=rJp/0H3q+/EaF/JtAChO0+uptF3RFPAxbjzNYsqKs6LaTerAtzKVgWpuej1ruJSra sHlmAkiifn4tKFFkHBz4Ru2osISBINA45ygkl9y666SN9NOLq4Atbvr86ENNqg6xsY Rn/d8HTajtOhcpxC3HepWnZ1BASYpFD311MhsOhw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3E464F804AB; Mon, 21 Nov 2022 14:46:29 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7A1A5F8055C; Mon, 21 Nov 2022 14:46:25 +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 54D19F8028D for ; Mon, 21 Nov 2022 14:46:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 54D19F8028D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="ZDRtbm1K" 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 2AL502xG029046; Mon, 21 Nov 2022 07:46:10 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=UZC5mSInUPPVK4ycYDZHi2KangYy7tVfWs8dGEHSWEs=; b=ZDRtbm1KcnZrqBwVElN8vhivn9wQInQFsZ/CdOV5BFu5FVtedIY3vuRmxGXU35/Z3B7p P20LUANlFTJBGSkx39vaL/F53vC/k3Tlgak9tt+UoXMd3tjfn6iDsXpGk0pBs2BeoxgP DKdawjzQsrDMk3r78WRxm60y06zL05oYVbQ3Iawkm8NiV5tiXxI6IfJU/+raeedQcs8+ Bs/f40lmGM2cVPDaubcwsYJ2stXEMjVjQUoU1MEoy41K/LunpZdu2C/d6FyXtGvCKBLS Ot3oadkvUsJTYn3M5bcZTLv1UCPcfYI8Mi9xVkZDFnVBg8J67aS5u/r4IOMs5ztbSH2f WA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:10 -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; Mon, 21 Nov 2022 07:46:08 -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; Mon, 21 Nov 2022 07:46:08 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 942CA468; Mon, 21 Nov 2022 13:46:08 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 1/9] sound: sdw: Add hw_params to SoundWire config helper function Date: Mon, 21 Nov 2022 13:46:00 +0000 Message-ID: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: Vaz_jm_2uXxRfe0ey1WuXc-e0wmr1EsW X-Proofpoint-GUID: Vaz_jm_2uXxRfe0ey1WuXc-e0wmr1EsW 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 vast majority of the current users of the SoundWire framework have almost identical code for converting from hw_params to SoundWire configuration. Whilst complex devices might require more, it is very likely that most new devices will follow the same pattern. Save a little code by factoring this out into a helper function. Signed-off-by: Charles Keepax --- I was a little bit two minds about whether to make this an inline or not, so any thoughts on that would be super welcome. The function does very little, especially given that SNDRV_PCM_STREAM_PLAYBACK == SDW_DATA_DIR_RX so the if is also really just an assignment. Thanks, Charles include/sound/sdw.h | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 include/sound/sdw.h diff --git a/include/sound/sdw.h b/include/sound/sdw.h new file mode 100644 index 0000000000000..6dcdb3228dba6 --- /dev/null +++ b/include/sound/sdw.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * linux/sound/sdw.h -- SoundWire helpers for ALSA/ASoC + * + * Copyright (c) 2022 Cirrus Logic Inc. + * + * Author: Charles Keepax + */ + +#include +#include +#include +#include + +#ifndef __INCLUDE_SOUND_SDW_H +#define __INCLUDE_SOUND_SDW_H + +/** + * snd_sdw_params_to_config() - Conversion from hw_params to SoundWire config + * + * @substream: Pointer to the PCM substream structure + * @params: Pointer to the hardware params structure + * @stream_config: Stream configuration for the SoundWire audio stream + * @port_config: Port configuration for the SoundWire audio stream + * + * This function provides a basic conversion from the hw_params structure to + * SoundWire configuration structures. The user will at a minimum need to also + * set the port number in the port config, but may also override more of the + * setup, or in the case of a complex user, not use this helper at all and + * open-code everything. + */ +static inline void snd_sdw_params_to_config(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct sdw_stream_config *stream_config, + struct sdw_port_config *port_config) +{ + stream_config->frame_rate = params_rate(params); + stream_config->ch_count = params_channels(params); + stream_config->bps = snd_pcm_format_width(params_format(params)); + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + stream_config->direction = SDW_DATA_DIR_RX; + else + stream_config->direction = SDW_DATA_DIR_TX; + + port_config->ch_mask = GENMASK(stream_config->ch_count - 1, 0); +} + +#endif From patchwork Mon Nov 21 13:46:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050959 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 6AD89C4332F for ; Mon, 21 Nov 2022 13:47:36 +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 6A52B868; Mon, 21 Nov 2022 14:46:44 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6A52B868 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038454; bh=UPPmdx65rzJkgaOxrvdU7r7xkYSPQqGacVxm+21s7G8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=CWW2QDHRtGC4e0gzKoy4w+rQdiBfycOwBQQRmvKM1Rt0SO/4blLn8PFtG6EhvAicd 0ngFEEatOuvnqKMlMDOPXN82Fm2RsKJseObn8/vRWlVAJ+kpDnZhmrBiKQly5/WfBT 9DzqNHFZNlr0UX9dyJMWqIZFAjA5lEAfg1AC5drI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 96A55F8055A; Mon, 21 Nov 2022 14:46:21 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6BD36F80558; Mon, 21 Nov 2022 14:46:18 +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 44AC5F800F3 for ; Mon, 21 Nov 2022 14:46:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 44AC5F800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="AAjl9xW1" 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 2AL502xF029046; Mon, 21 Nov 2022 07:46:10 -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=36Qk2o2cOSy9Wte3Pe+ihmxFund0+dvrVRxus9yihoA=; b=AAjl9xW1hAIxme5683v4AgoOSh94t50Xk9LgbyKN+aXA0ALE46vcMm1zyGDVW/Qg/Pyj Dors6EVZeVcXNhtDumBAot/m82IKKjBOPzWjCYBlr5tcooo+UqdL2wZwP8F+nKSy3dQS 3qv8w9F5dW+qEG/bh3HmOC77/7Y+SV/rX6CdIq9uec0SDDaHga8t89BMnn4QqUlMvfBx QymwDfiwAyxAxt2w12zvkCkcgapP39brgVl5OyxWMCw8jayZra8daKgXCUHTmpaevqvg AKh45CnQYCRJzn6Ut79v2VeW7kfXdL05uT2+8Ngjk13n8diUF1xz5IHm/OBlWsSFUSQM VQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:10 -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; Mon, 21 Nov 2022 07:46:08 -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; Mon, 21 Nov 2022 07:46:08 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id A4A03B2F; Mon, 21 Nov 2022 13:46:08 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 2/9] ASoC: max98373-sdw: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:01 +0000 Message-ID: <20221121134608.3713033-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 5Nx2C9BHGvqH89iqTlOLjn8XptSO2XJW X-Proofpoint-GUID: 5Nx2C9BHGvqH89iqTlOLjn8XptSO2XJW 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 conversation 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 --- sound/soc/codecs/max98373-sdw.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/max98373-sdw.c b/sound/soc/codecs/max98373-sdw.c index 899965b19d12d..3cd1be743d9ee 100644 --- a/sound/soc/codecs/max98373-sdw.c +++ b/sound/soc/codecs/max98373-sdw.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -533,10 +534,8 @@ static int max98373_sdw_dai_hw_params(struct snd_pcm_substream *substream, struct snd_soc_component *component = dai->component; struct max98373_priv *max98373 = 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 ret, chan_sz, sampling_rate; @@ -548,28 +547,20 @@ static int max98373_sdw_dai_hw_params(struct snd_pcm_substream *substream, if (!max98373->slave) return -EINVAL; + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; port_config.num = 1; + + if (max98373->slot) { + stream_config.ch_count = max98373->slot; + port_config.ch_mask = max98373->rx_mask; + } } else { - direction = SDW_DATA_DIR_TX; port_config.num = 3; - } - stream_config.frame_rate = params_rate(params); - stream_config.bps = snd_pcm_format_width(params_format(params)); - stream_config.direction = direction; - - if (max98373->slot && direction == SDW_DATA_DIR_RX) { - stream_config.ch_count = max98373->slot; - port_config.ch_mask = max98373->rx_mask; - } else { /* only IV are supported by capture */ - if (direction == SDW_DATA_DIR_TX) - stream_config.ch_count = 2; - else - stream_config.ch_count = params_channels(params); - + stream_config.ch_count = 2; port_config.ch_mask = GENMASK((int)stream_config.ch_count - 1, 0); } From patchwork Mon Nov 21 13:46:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050963 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 6CE3EC4332F for ; Mon, 21 Nov 2022 13:48:32 +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 869C01631; Mon, 21 Nov 2022 14:47:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 869C01631 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038510; bh=R5+4Ph3yw9O6hfQjpGnSZEf7jo4uMThgIWg0k9609zE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Nz3uaqsJmGaFHjHufgYinSOHiE1mjMIpw0U6lvNso1FkT4YBl+d3d1b+kh1vDD4sB BiMxIrBW6dUCBVYWbGFwrV8tPulihd769xo7NDDT0u/BkHA5Ks2Jhvqfas5UIwH6Tz 70uh1L9RCVzqRhEiXExWI0Ke7FGoFdhR8vM69E24= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8F855F80571; Mon, 21 Nov 2022 14:46:30 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 92F0BF80558; Mon, 21 Nov 2022 14:46:25 +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 3DAF8F80149 for ; Mon, 21 Nov 2022 14:46:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3DAF8F80149 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="iCbyTh3Y" 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 2AL502xH029046; Mon, 21 Nov 2022 07:46:11 -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=h+oTKXjYDyudR+qr7rbI+0ql/anOq7qmqTsnTji7nHA=; b=iCbyTh3YznDhvp7Gw3JHQMbZM7ON0giyFoIu21BUWdKew5Yym3jzNT88cG8F5BWs4J4k 5wh3ln9FPfnAAFwKNc1v8wOT62Yhr5H+jExeMnhrFsQ9Rf1VzRzYL1OIDWOler66w3Mz kAjZQbWxHU1Kvf2eXtghvgMWubVB0ajjrrb+RddocgS6pUp9Ho6j0WxbFYlWjeOLlxpG Jfhy8VcqFJ6vcly/bsPL2ba/mhsft/3OtLCAHiqflLOIDT0SeZJbiQ25ts2o2xKap8m4 RIt7V9dyvrY1YuXm7lPPrJYwHQoJbvc6lqGeqe6nEqQiEM5tt1qmrvLC8yYccghmJqjk Ow== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271t-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:11 -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; Mon, 21 Nov 2022 07:46:08 -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; Mon, 21 Nov 2022 07:46:08 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id B2BD8B12; Mon, 21 Nov 2022 13:46:08 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 3/9] ASoC: rt1308-sdw: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:02 +0000 Message-ID: <20221121134608.3713033-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: tdvnHQUn598vsssVzWcn5nD_IZ_OkpgY X-Proofpoint-GUID: tdvnHQUn598vsssVzWcn5nD_IZ_OkpgY 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 conversation 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 --- sound/soc/codecs/rt1308-sdw.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c index 7f4248284f35e..ca2790d63b719 100644 --- a/sound/soc/codecs/rt1308-sdw.c +++ b/sound/soc/codecs/rt1308-sdw.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -553,11 +554,10 @@ static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream, struct snd_soc_component *component = dai->component; struct rt1308_sdw_priv *rt1308 = 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, ch_mask; + int retval; dev_dbg(dai->dev, "%s %s", __func__, dai->name); stream = snd_soc_dai_get_dma_data(dai, substream); @@ -569,30 +569,19 @@ static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* SoundWire specific configuration */ + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); + /* port 1 for playback */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; - port = 1; - } else { + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + port_config.num = 1; + else return -EINVAL; - } if (rt1308->slots) { - num_channels = rt1308->slots; - ch_mask = rt1308->rx_mask; - } else { - num_channels = params_channels(params); - ch_mask = (1 << num_channels) - 1; + stream_config.ch_count = rt1308->slots; + port_config.ch_mask = rt1308->rx_mask; } - stream_config.frame_rate = params_rate(params); - stream_config.ch_count = num_channels; - stream_config.bps = snd_pcm_format_width(params_format(params)); - stream_config.direction = direction; - - port_config.ch_mask = ch_mask; - port_config.num = port; - retval = sdw_stream_add_slave(rt1308->sdw_slave, &stream_config, &port_config, 1, stream->sdw_stream); if (retval) { From patchwork Mon Nov 21 13:46:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050965 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 22F05C4332F for ; Mon, 21 Nov 2022 13:49: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 4B726164D; Mon, 21 Nov 2022 14:48:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4B726164D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038540; bh=Hw2InyRLzLgqNSFl/OrOG/C9s+VQwRhK1XaKtG13u20=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SPRzfW+z5McR1BuJIs2EynVK6jaWfGNeqllWhSmZe6VH8b8R+h9Y1S2zslNdkwIKQ KDqCvr04QRjQNYi4SzLVCzCR3tlCte7Du8gvfHt61seXJcLACcnJVCFKfFu2i+pECo XuH/czxgbdHsOwKSS271nN8rNijo+OKL13NvwV8I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 11B2DF8057D; Mon, 21 Nov 2022 14:46:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BF1A4F8057A; Mon, 21 Nov 2022 14:46:30 +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 5999CF8051B for ; Mon, 21 Nov 2022 14:46:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5999CF8051B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="TXFmIqCa" 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 2AL502xJ029046; Mon, 21 Nov 2022 07:46:12 -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=fCTJeh0mw/ojyxZjuedM8WzieDcDprCTrftqDRrQsyk=; b=TXFmIqCaOxMe1csoGIJf4ngrzAhqj1FhxnoMAr8mOwNnuMc1GpwCwPNJI+WgGYOt/lYS xS0O6rkdbdfnqIkkk7Obw+w1kcCKWQDsMa147Jx6fqox5f61KiqVTC5soS5dfDad8sU4 WvD5MCOSZtIrwq+PucSDDvoqpEpR6Phtvdi4W02JruJLByVNLXF2+VNzTEcbas9CshEB Q3Zo/lwX/yy3oOVvZhM4iH1AOUoiupcjwuFtIoeyMBnXs6RMT/7krpJtSTeh5Iy+zeGL eUjBVpuiV1gnAYoWbWQiXNTnY8BxcheRXixszXzJvO9eNYgJ2QeNdJCiFa8UlzGYzrUq wQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271t-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:12 -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; Mon, 21 Nov 2022 07:46:08 -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; Mon, 21 Nov 2022 07:46:08 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id C317AB38; Mon, 21 Nov 2022 13:46:08 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 4/9] ASoC: rt1316-sdw: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:03 +0000 Message-ID: <20221121134608.3713033-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: N6yPkpAA46SdujEmwplif5c4of2TwyW7 X-Proofpoint-GUID: N6yPkpAA46SdujEmwplif5c4of2TwyW7 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 conversation 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 --- sound/soc/codecs/rt1316-sdw.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/sound/soc/codecs/rt1316-sdw.c b/sound/soc/codecs/rt1316-sdw.c index 2db7ee6c6d334..e6294cc7a9954 100644 --- a/sound/soc/codecs/rt1316-sdw.c +++ b/sound/soc/codecs/rt1316-sdw.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include "rt1316-sdw.h" @@ -530,11 +531,10 @@ static int rt1316_sdw_hw_params(struct snd_pcm_substream *substream, struct snd_soc_component *component = dai->component; struct rt1316_sdw_priv *rt1316 = 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, ch_mask; + int retval; dev_dbg(dai->dev, "%s %s", __func__, dai->name); stream = snd_soc_dai_get_dma_data(dai, substream); @@ -546,25 +546,13 @@ static int rt1316_sdw_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* SoundWire specific configuration */ - /* port 1 for playback */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; - port = 1; - } else { - direction = SDW_DATA_DIR_TX; - port = 2; - } - - num_channels = params_channels(params); - ch_mask = (1 << num_channels) - 1; + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); - stream_config.frame_rate = params_rate(params); - stream_config.ch_count = num_channels; - stream_config.bps = snd_pcm_format_width(params_format(params)); - stream_config.direction = direction; - - port_config.ch_mask = ch_mask; - port_config.num = port; + /* port 1 for playback */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + port_config.num = 1; + else + port_config.num = 2; retval = sdw_stream_add_slave(rt1316->sdw_slave, &stream_config, &port_config, 1, stream->sdw_stream); From patchwork Mon Nov 21 13:46:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050958 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 B23E7C4332F for ; Mon, 21 Nov 2022 13:47:13 +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 0B5DB839; Mon, 21 Nov 2022 14:46:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0B5DB839 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038431; bh=zf+R27dYVT9g5b6A85qiZ9qxgaoNAOdiRlcYZY2TFGI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=MhBNjASkw+dORgdShTGn8Zk1ZeZhM4rg5amwumeA687z/isOf2hJsr0UrBfyGwp/B 7CaI2J5Pg0240t3ZPtib1kbHCwoMgGEk9oONPHcWXuknnqbYj1g12xrT7YE9pG+VMa cZOpvUcYBVMgSp+9w8n9qY1apT/fKUqzmdNo7FP8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7BB7BF80542; Mon, 21 Nov 2022 14:46:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 76D3CF80542; Mon, 21 Nov 2022 14:46:18 +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 29F5AF80115 for ; Mon, 21 Nov 2022 14:46:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 29F5AF80115 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="RoYph80y" 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 2ALCr4As002700; Mon, 21 Nov 2022 07:46:10 -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=fCO2pzM4XbweH4RrXkYmXDC32oD6kGCqqQ8AhBAQ95c=; b=RoYph80yIEYpF/iN59u2IC46UKLKUCndWMS5TQn4RaOjdkqEdPG0C/xznXWCT2gstTHs OIZONemLkwYb1aCtFAhk/e4wpEH9j68IKZV6i/sBGn/VSJJmZu1CQEqF0egKYjBEXpHg 9IZCwtXnYnJXidoaCQjOHtsj1zwSLCFdDIvE9fTu65t63HCVx/pL91GzTG329R5Wilmd nVTakM1AyhTr5u7zFCoZp4iXvI4VTvPB9RMWwW81OWoUUyrnqrJ/aziFvE/O+shHoeXb yWFgRytzFQSYYrVc6FJmxSDI7z0brTf8ImXpBMun4lblVgIlDNb/tgCN+88bs1Or4V6Q VA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:10 -0600 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Mon, 21 Nov 2022 07:46:08 -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; Mon, 21 Nov 2022 07:46:08 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id D20A3468; Mon, 21 Nov 2022 13:46:08 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 5/9] ASoC: rt5682-sdw: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:04 +0000 Message-ID: <20221121134608.3713033-5-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: _R4LtnYvBfWuCLMkGtmthR35Fry7zt7F X-Proofpoint-GUID: _R4LtnYvBfWuCLMkGtmthR35Fry7zt7F 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 conversation 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 --- sound/soc/codecs/rt5682-sdw.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/sound/soc/codecs/rt5682-sdw.c b/sound/soc/codecs/rt5682-sdw.c index c1a94229dc7e3..d8a573dcb771b 100644 --- a/sound/soc/codecs/rt5682-sdw.c +++ b/sound/soc/codecs/rt5682-sdw.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -130,11 +131,10 @@ static int rt5682_sdw_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct rt5682_priv *rt5682 = 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_p = 0, val_c = 0, osr_p = 0, osr_c = 0; dev_dbg(dai->dev, "%s %s", __func__, dai->name); @@ -147,22 +147,12 @@ static int rt5682_sdw_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* SoundWire specific configuration */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; - port = 1; - } else { - direction = SDW_DATA_DIR_TX; - port = 2; - } + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); - 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; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + port_config.num = 1; + else + port_config.num = 2; retval = sdw_stream_add_slave(rt5682->slave, &stream_config, &port_config, 1, stream->sdw_stream); From patchwork Mon Nov 21 13:46:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050960 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 94084C433FE for ; Mon, 21 Nov 2022 13:48:03 +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 C941DAE8; Mon, 21 Nov 2022 14:47:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C941DAE8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038481; bh=dlkpqMUG0NWtLiskP+bmgH576xlPlUvIZfYjbBJF/Mo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=utu8DFy+KMbFHdoLVKax9a6R6Ixpf8imShlSrH9VmcLcxhzaa6dBh3MAMvHpj2M78 1gtHGnunE1XskgK8W9U76jYhsvIILE67gwres5tDfeEUqRiQhYf8vGF1IBRIxoI4EQ Bw0aJfCtMS88ALoB86avpP97HCPhH64q+tPG5bKQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A9423F8028D; Mon, 21 Nov 2022 14:46:25 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8A164F80563; Mon, 21 Nov 2022 14:46:24 +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 A14D7F804AB for ; Mon, 21 Nov 2022 14:46:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A14D7F804AB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="hhCMXQyl" 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 2ALCr4At002700; Mon, 21 Nov 2022 07:46:11 -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=Enns8Li2mP98sesAIEB3YlH0EbUWIiF9uxeMa/nX8sY=; b=hhCMXQyl9w/4R8zAcr6bgAMM+2Y13+RrSRLJ/XKHdXPIAAiFK3//kLwUeWE4fQGVEsbd s46ShVyScabiQ0+V39+9pXgry8L2BxfqxqQSSxV7xDUBgUTaNArbmilJw9ICEC2O09xT eKolJj1h7EdUrg/7l6Iu2ahpP67QEOgfeDubj4PNGo3yWGDnZ5sVswyjUz2JbkWFDr1w YtOrEsDz30cYJtgZbUPCZ1WIurXtdD7d6vkt1sG5veJCuPDUqGyf22/IJoF1/Jcs+EU9 MEAxFPugcpZvQfL21575me3jrPxmJKYARBWUVUFYDwr6AaBK8FzlmpnfR+0GOZ5mUXfi YQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271u-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:10 -0600 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Mon, 21 Nov 2022 07:46:08 -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; Mon, 21 Nov 2022 07:46:08 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id E1E0611AF; Mon, 21 Nov 2022 13:46:08 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 6/9] ASoC: rt700: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:05 +0000 Message-ID: <20221121134608.3713033-6-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: NLeC1cVrfFraoSbg0aFSlgq-LsKgDWF4 X-Proofpoint-GUID: NLeC1cVrfFraoSbg0aFSlgq-LsKgDWF4 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 conversation 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 --- sound/soc/codecs/rt700.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/sound/soc/codecs/rt700.c b/sound/soc/codecs/rt700.c index 055c3ae974d80..6534c9b514428 100644 --- a/sound/soc/codecs/rt700.c +++ b/sound/soc/codecs/rt700.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -910,11 +911,10 @@ static int rt700_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct rt700_priv *rt700 = 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); @@ -927,35 +927,25 @@ static int rt700_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* SoundWire specific configuration */ + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); + /* This code assumes port 1 for playback and port 2 for capture */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; - port = 1; - } else { - direction = SDW_DATA_DIR_TX; - port = 2; - } + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + port_config.num = 1; + else + port_config.num = 2; switch (dai->id) { case RT700_AIF1: break; case RT700_AIF2: - port += 2; + port_config.num += 2; break; default: dev_err(component->dev, "Invalid DAI id %d\n", dai->id); 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(rt700->slave, &stream_config, &port_config, 1, stream->sdw_stream); if (retval) { From patchwork Mon Nov 21 13:46:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050966 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 BE2FDC43219 for ; Mon, 21 Nov 2022 13:49:22 +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 D43E7164F; Mon, 21 Nov 2022 14:48:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D43E7164F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038560; bh=6XUBSfqA/AYQJH+lqOy7CqiKFUESx/kcE+KE1N5qCN0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=SGNANLOKji3Cj5V93kjhS9+8/PK6t5sBxKkwNg/9hnk7dxk3/NeUFgTERaNbssPC0 lQxT4Eknwlr/H8y68PRF3J9RgsYfunObLwrRZo98bXZYo7vpM1a5f3CXFJN7W3eR6a NYGjHjxBkLkJ3QSPu0y1TLvLe0lz9ya/iusZuFgA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9D179F8057F; Mon, 21 Nov 2022 14:46:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9EF0BF8057D; Mon, 21 Nov 2022 14:46:31 +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 220D2F80519 for ; Mon, 21 Nov 2022 14:46:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 220D2F80519 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="mqk7bO2g" 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 2AL502xK029046; Mon, 21 Nov 2022 07:46:13 -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=rU8D4IIGgYuq3+CJd6vO8qhlUC6r6iU2cG2WHbN6SkE=; b=mqk7bO2g3CYxw4HSM7cvLKu2+gJAaMBwLXI47V4kd20tVgI/R6/QaClTpaOC969xxCN/ NaFm2hatBFUECKlhwyD+DV3GEASdZ8timbQQjk8uML9yKJWrdN9z0rONo8KUYcPFO2zq ZE1YhxMUTtApzw4ayNvyV44//FwiWKptozTUKTxcACbMQzUCbu1Bh8snZHcU/zWOZswm nFss00LVV8TtGvUjHZs10BgSABYsOzWbTDMDlUcbczjyAumuiVHqYDBiXoAYdS8JJWtI jvrOc6EBQhrHnBxeex7+H4uICVatsEA+YlHf0wnTGTuePzCQek4Vddjua4QkAKsXcWud Hw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271t-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:13 -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; Mon, 21 Nov 2022 07:46:09 -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; Mon, 21 Nov 2022 07:46:09 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id F16AFB2F; Mon, 21 Nov 2022 13:46:08 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 7/9] ASoC: rt711: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:06 +0000 Message-ID: <20221121134608.3713033-7-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: eS9KVEaOggY7Nq8qjtYpYBQLViVK7LRU X-Proofpoint-GUID: eS9KVEaOggY7Nq8qjtYpYBQLViVK7LRU 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 conversation 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 --- 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) { From patchwork Mon Nov 21 13:46:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050964 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 3DA50C4332F for ; Mon, 21 Nov 2022 13:48:55 +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 4ED711634; Mon, 21 Nov 2022 14:48:03 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4ED711634 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038533; bh=p370Bod8sHzxiBjycP+m1ewUGok0gLAP50vbhkP9F6w=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=bU7mcGpLOsAj+Qg0qqxAJRP/c5wils+joRtdYN87sqlcenS9668WGW/AzCb9Wwn0t zO7d83m4MgF7/KYvQIlhm2HrcYq2AHSualHdUU60aXCpe4eGZsUH1ec7nSooBig5Xz TseHzG/bEx0lEKgZgMO+rb4T9aXdE7zb+D/Oz1Qc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 49CEBF8057A; Mon, 21 Nov 2022 14:46:31 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D51D7F80563; Mon, 21 Nov 2022 14:46:25 +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 D3C1AF804D0 for ; Mon, 21 Nov 2022 14:46:13 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D3C1AF804D0 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="IBcnNuq4" 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 2AL502xI029046; Mon, 21 Nov 2022 07:46:12 -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=YyUimI9eFGYqPah/Gdj8TT7o8ghUxAih2hDvOpwwbvI=; b=IBcnNuq4WagWpH6YftYVh7Nn/uqnwWlYlTpBmpO3wvRAlyKj5Zn/RlzEnNyhbH8HrtJJ 2tJUIGNrE0gvMlpLINdOLsXJ6bZwPx24QjmPx6/pgmQHOoXy4o4G+q3OZOug6uolWT9N dC1bAcfCiPckjxKLHL+PcIwG37u6OAjk1DMXNCiP3qKhvx1cfpGhKM/oNu+bykauwma4 ZdTD1C9CaTkMnAGoc5ftPaPzsU6u/7NXo5PwBQDnTcalTEkdjQGHfEn8m4pVsToTrOUF l8FV1ZSMhEguvWx2sR72N9W+sc5zEjRHT8xKwU7joIq/kjzuGymQzZ9tufY+bnDbY/gl EA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271t-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:12 -0600 Received: from ediex02.ad.cirrus.com (198.61.84.81) 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; Mon, 21 Nov 2022 07:46:09 -0600 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.20 via Frontend Transport; Mon, 21 Nov 2022 07:46:09 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 0CDA3468; Mon, 21 Nov 2022 13:46:09 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 8/9] ASoC: rt715: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:07 +0000 Message-ID: <20221121134608.3713033-8-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: d0mB6CQ5Itw1siJLBVTskpWWWuBfdSMc X-Proofpoint-GUID: d0mB6CQ5Itw1siJLBVTskpWWWuBfdSMc 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 conversation 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 --- sound/soc/codecs/rt715-sdca.c | 25 ++++++++----------------- sound/soc/codecs/rt715.c | 25 ++++++++----------------- 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/sound/soc/codecs/rt715-sdca.c b/sound/soc/codecs/rt715-sdca.c index ce8bbc76199a8..1fca7a3f46eac 100644 --- a/sound/soc/codecs/rt715-sdca.c +++ b/sound/soc/codecs/rt715-sdca.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -820,11 +821,10 @@ static int rt715_sdca_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct rt715_sdca_priv *rt715 = 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 rt715_sdw_stream_data *stream; - int retval, port, num_channels; + int retval; unsigned int val; stream = snd_soc_dai_get_dma_data(dai, substream); @@ -835,16 +835,16 @@ static int rt715_sdca_pcm_hw_params(struct snd_pcm_substream *substream, if (!rt715->slave) return -EINVAL; + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); + switch (dai->id) { case RT715_AIF1: - direction = SDW_DATA_DIR_TX; - port = 6; + port_config.num = 6; rt715_sdca_index_write(rt715, RT715_VENDOR_REG, RT715_SDW_INPUT_SEL, 0xa500); break; case RT715_AIF2: - direction = SDW_DATA_DIR_TX; - port = 4; + port_config.num = 4; rt715_sdca_index_write(rt715, RT715_VENDOR_REG, RT715_SDW_INPUT_SEL, 0xaf00); break; @@ -853,15 +853,6 @@ static int rt715_sdca_pcm_hw_params(struct snd_pcm_substream *substream, 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(rt715->slave, &stream_config, &port_config, 1, stream->sdw_stream); if (retval) { diff --git a/sound/soc/codecs/rt715.c b/sound/soc/codecs/rt715.c index e93240521c74e..917a04092da27 100644 --- a/sound/soc/codecs/rt715.c +++ b/sound/soc/codecs/rt715.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -801,11 +802,10 @@ static int rt715_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct rt715_priv *rt715 = 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; stream = snd_soc_dai_get_dma_data(dai, substream); @@ -816,15 +816,15 @@ static int rt715_pcm_hw_params(struct snd_pcm_substream *substream, if (!rt715->slave) return -EINVAL; + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); + switch (dai->id) { case RT715_AIF1: - direction = SDW_DATA_DIR_TX; - port = 6; + port_config.num = 6; rt715_index_write(rt715->regmap, RT715_SDW_INPUT_SEL, 0xa500); break; case RT715_AIF2: - direction = SDW_DATA_DIR_TX; - port = 4; + port_config.num = 4; rt715_index_write(rt715->regmap, RT715_SDW_INPUT_SEL, 0xa000); break; default: @@ -832,15 +832,6 @@ static int rt715_pcm_hw_params(struct snd_pcm_substream *substream, 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(rt715->slave, &stream_config, &port_config, 1, stream->sdw_stream); if (retval) { From patchwork Mon Nov 21 13:46:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13050962 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 0DF7AC4332F for ; Mon, 21 Nov 2022 13:48:23 +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 3DCDD843; Mon, 21 Nov 2022 14:47:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3DCDD843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669038501; bh=2O57JahAN3O2LdDiqy0KAFnsMdtqPHWLTiFxPJWUDA8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=pNPtrV3ygLiSEftCFefiebE673RVjInq2+RZTk4485J6h0sE8tE1FyuwtQkWfGPq4 q2MocL5+qT1LcxMWUeCTnHd7lcNrwJuZw7H23GGr4rIiGxyedV0m+D67UUt326JYGL vRbTDXBMl6tAXLxa6TGCq6SfAkZq6u6jjsjMq4g8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CEE7CF80566; Mon, 21 Nov 2022 14:46:29 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9F9BEF804AB; Mon, 21 Nov 2022 14:46:25 +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 60DDAF804B1 for ; Mon, 21 Nov 2022 14:46:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 60DDAF804B1 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="C6e3VNC8" 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 2ALCr4Au002700; Mon, 21 Nov 2022 07:46:11 -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=IXoJsLgVV8KoT5bdUWXzMuKi/OwhJnj1jrXFa4ZwmG8=; b=C6e3VNC80JZL2OR1zO98IbzhJxitIr1jTU4Q9jHHoR4v9i6XZx2OIB9+fuKNyurkhdff u4IaJbtRWogCnx0ysagu0+KV7BoQwWPrZ9yCAlD+Elj1Rumo7snDFp/cpZyje29YrcP6 uZQrysjKkPv4XhHBhwOEGCVxu/9WrlvH6vzCSk58DGcCBVDzYXzbwPCDKAFK95/1ejog uFm5f+IpDDF1j7/pfUiUjDMtWT36viWgl+xPsbnQan9J+Cdf00FIk+XLVaYXKQHmKkS0 m+bl9LBFDHHYzf4afGG4BYIRklmCgV+3V+zdCIJjOLVzmeNazxd9ejkePJw0dOPTWPJr Yg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3kxvet271u-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 07:46:11 -0600 Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.20; Mon, 21 Nov 2022 07:46:09 -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; Mon, 21 Nov 2022 07:46:09 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 1B3D4B12; Mon, 21 Nov 2022 13:46:09 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH 9/9] ASoC: sdw-mockup: Switch to new snd_sdw_params_to_config helper Date: Mon, 21 Nov 2022 13:46:08 +0000 Message-ID: <20221121134608.3713033-9-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> References: <20221121134608.3713033-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: izBofi0513b-mCHjUmzrZN2f1-N6_MF- X-Proofpoint-GUID: izBofi0513b-mCHjUmzrZN2f1-N6_MF- 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 conversation 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 --- sound/soc/codecs/sdw-mockup.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/sdw-mockup.c b/sound/soc/codecs/sdw-mockup.c index 288b55368d2a4..af52f2728854b 100644 --- a/sound/soc/codecs/sdw-mockup.c +++ b/sound/soc/codecs/sdw-mockup.c @@ -16,6 +16,7 @@ #include #include #include +#include #include struct sdw_mockup_priv { @@ -80,12 +81,9 @@ static int sdw_mockup_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_component *component = dai->component; struct sdw_mockup_priv *sdw_mockup = 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 num_channels; - int port; int ret; stream = snd_soc_dai_get_dma_data(dai, substream); @@ -96,22 +94,12 @@ static int sdw_mockup_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* SoundWire specific configuration */ - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - direction = SDW_DATA_DIR_RX; - port = 1; - } else { - direction = SDW_DATA_DIR_TX; - port = 8; - } - - 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; + snd_sdw_params_to_config(substream, params, &stream_config, &port_config); - num_channels = params_channels(params); - port_config.ch_mask = (1 << num_channels) - 1; - port_config.num = port; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + port_config.num = 1; + else + port_config.num = 8; ret = sdw_stream_add_slave(sdw_mockup->slave, &stream_config, &port_config, 1, stream->sdw_stream);