From patchwork Wed Nov 23 16:54:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053969 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 34283C4332F for ; Wed, 23 Nov 2022 16:55:38 +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 65E501687; Wed, 23 Nov 2022 17:54:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 65E501687 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222536; bh=PuuOGxymsLMsucPYkyQiBG6FCBgWUwEcbNyP9hHNCls=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=mpr34Jl8eAeDNmgaHfUfduJyGXobSVpKe6aAdGu9GwxfoETrxQq27t5tfV1vpmqQw uLSnoXlpfqS+YfD18TekevVU70+82LTZNCy+P0QS5NJT4PUrQIiEnEKcSBeZ5J9nv6 8CZVWb1/lmT/Qo8t1FYHYVBzyLHfgjnJwVMxLOQc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 06DCFF80115; Wed, 23 Nov 2022 17:54:46 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8EBD7F80249; Wed, 23 Nov 2022 17:54:43 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 8366DF80249 for ; Wed, 23 Nov 2022 17:54:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8366DF80249 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="mFGyXi9T" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduD006384; Wed, 23 Nov 2022 10:54:35 -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=dIT4dovX4tBpfwMooPH3S+R/rUmodsbPWeReLbp4TlA=; b=mFGyXi9TQXIb5pXmKOPLkne7ujXvwi5conEE6PBQywtLJ7EVHkjMqHvJ4CBuqfmeVmaj AtdDwbKKIaAMVd9ZPA2Nt9VEwlY8UD+uMke5+DiPxTJNjCykngdQSt7zea5Mzp+QDJH+ JyfWMCHx/CuoGOXq0XWzaHl6Zd2nXUX0QMYQM3+mfZxD0NjEhvgmGNLyVJlMFFpv81Z2 cLqG0jTvwzfenxzmiKTtntFxBzGpDgtW4J39s1/X87JGQ5Y4D2vpAFTI8gYusyWjNEYY WZH/jZFPP6b+MBnhGq8i34UsVgvU5orkQKHOEFE/8KFG6w0qEiXsq2JRhdrEc0r/khrh nA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:35 -0600 Received: from ediex02.ad.cirrus.com (198.61.84.81) 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; Wed, 23 Nov 2022 10:54:32 -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; Wed, 23 Nov 2022 10:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 2D820477; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 1/9] sound: sdw: Add hw_params to SoundWire config helper function Date: Wed, 23 Nov 2022 16:54:24 +0000 Message-ID: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dBlVPbT4FzpFjisHavznXKJYPccZcyEQ X-Proofpoint-GUID: dBlVPbT4FzpFjisHavznXKJYPccZcyEQ 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 Changes since v2: - No difference Changes since v1: - Correct spelling error in commit message 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 Wed Nov 23 16:54:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053970 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 055C6C4332F for ; Wed, 23 Nov 2022 16:56: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 32E57169E; Wed, 23 Nov 2022 17:55:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 32E57169E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222560; bh=Az95wzsOT29kwAXwYXCUmPYUNqt1QMf177uUSVx4Ojw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=HVtEPR0Jeqyp+86DVD/8CIhfUhhw6rE8K3EnjYd3iE6Hqaz8oEGAK4kF8bFHCVUFS vPmHOjy32245UXUwvCi6hpn6KSa16n6MHZCQ74oyDUpL07LMicXp3hWj8+QlIJ5V2r KQkuFyjSims8P9g/7vYDSrq4Ifv88IqDiW/jlXTU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 045C3F8055A; Wed, 23 Nov 2022 17:54:47 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id BCD05F80558; Wed, 23 Nov 2022 17:54:43 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 64453F80115 for ; Wed, 23 Nov 2022 17:54:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 64453F80115 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="I6zWkVFG" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduB006384; Wed, 23 Nov 2022 10:54:34 -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=BflGu/lMmvCipmZWlS+qniFTEW293v40mz4xMf709/Y=; b=I6zWkVFG92SD2GsCviDuQAA3RGhdaqmwHWe9j0DQmrSgqApkRSd7LG94QgHr4MRgwRgT cUwrrACfoO7hKNkarNQ3+JdbbBviBAp5Fe8ANZpH2IKPnu51WkjppWQPzSzrF75sx545 rnTLSR1kNE++uHyApFqj1CGsZrTsbDhabPKEi54EppPBs0/CLTXAvBPxlHYIdCMM85Nm nupyn7XQoCFTWpsE99xkppzNrjskEe+5UBmQ5UyDL4eU4T59FI/lbFKTayWimhCNaaLH wO45OQuw+bGZhmcoqx5Lz0omT4Y0XvT86YSjjX5LdcbPiPu7xeCE4pupkgL4yZBG/2cU SQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:34 -0600 Received: from ediex02.ad.cirrus.com (198.61.84.81) 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; Wed, 23 Nov 2022 10:54:32 -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; Wed, 23 Nov 2022 10:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 3D1232BA; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 2/9] ASoC: max98373-sdw: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:25 +0000 Message-ID: <20221123165432.594972-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: qm0kyrx6QaKX0hGqWKxdiBq9L7da5qoP X-Proofpoint-GUID: qm0kyrx6QaKX0hGqWKxdiBq9L7da5qoP 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. Changes since v1: - Correct spelling error in commit message 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 Wed Nov 23 16:54:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053971 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 7DEC7C4332F for ; Wed, 23 Nov 2022 16:56:29 +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 77A7816AB; Wed, 23 Nov 2022 17:55:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 77A7816AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222587; bh=Q1Tf8i33G7AdPhDQetDGgeM3kjLkQqvLu1GolLs7WEM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=IGPmWM8w5JO3kr2SRQk25ivjWSR0xeQ/rd5tqPz+84yIXwddmt7vXwJq2FKCG/twI EeF8ks+KsH00wMkTyWXeFQnu02hUMJWRAP7h5eMQ4ofo3k5uc6OMcLSZ5aHEeXKp1V dGPveVre7FzyHlekcbshqY/5LQ9E6vHM66U2w1Ko= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 220FFF8030F; Wed, 23 Nov 2022 17:54:52 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 673FCF80563; Wed, 23 Nov 2022 17:54:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 80CDEF800BB for ; Wed, 23 Nov 2022 17:54:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 80CDEF800BB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="J8v3mWDP" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduF006384; Wed, 23 Nov 2022 10:54:36 -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=kPnwel1BxSdNg2PoZ7xE2NvwG4Qq2H8cIQbstGHMN9Y=; b=J8v3mWDPmNNwme+/A/vSqtIooxZZLAS1Io5x3m+/Km2L5jkUF9nSvVpavKe5r9IcfO3l BFo1Y4KP/wKS6bnnI9b2ty0fZwyWh4+YvrR0zsqyeHVOJuNGJ6hNfVK93/z4uMXaaWMP zsPSsJisTAlPLIHmqRyAMYjjtIZDUOvaWzwWxnBObqaeM8+JRmxeaG/yCmqrzYbj2KSI 4+VaaDLod0e6H94iatYmB5wCd80nyrr/qZz9OTqW86Xy41iJQcT+PsablxrScpQB3INd 8NoTr5PN8DXQ+z/8XapSvXj2/+Nrto18+xvJpt5ga0OrnMqYgGZNjH9rgPbuCdbYq7zq kA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y2-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:36 -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; Wed, 23 Nov 2022 10:54:32 -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:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 4B9B0B10; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 3/9] ASoC: rt1308-sdw: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:26 +0000 Message-ID: <20221123165432.594972-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: ITGRbMt6xrrHGRpMT3X1xXco-N5AbbOk X-Proofpoint-GUID: ITGRbMt6xrrHGRpMT3X1xXco-N5AbbOk 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. Changes since v1: - Correct spelling error in commit message 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 Wed Nov 23 16:54:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053973 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 53364C433FE for ; Wed, 23 Nov 2022 16:56:48 +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 78A80168F; Wed, 23 Nov 2022 17:55:56 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 78A80168F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222606; bh=YKR8bPiGlEg31hN+Pwm03imsY9Z1mQeJ0my1eoXXMQo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QsxOzBbgHytMtLd+3Wl9qf7bUJLieavFsbYnCxARZETjH1QKAhQw/dZPA3rAtBZjq lQwxdtezvBlMLimvTA0lWFuxfx0DpN3ZpCvJ1VIWtGAr4cuRY15g++3m9tr711m28h 4GVIN9ontRQnTMX+3Vr4gViA1dew8wDEbw+7XD9Y= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 42294F80564; Wed, 23 Nov 2022 17:54:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A8F9DF8055B; Wed, 23 Nov 2022 17:54:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 8A045F8025D for ; Wed, 23 Nov 2022 17:54:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8A045F8025D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="S4qqAxuD" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduC006384; Wed, 23 Nov 2022 10:54:35 -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=+5/JCNyM+AJMXKhFfJ/ML8UlgZYx9Ey+Y5damJbRG4g=; b=S4qqAxuDxDYwXRn4bvF5BM6j6QDx7RVNXXkKuZdb+7N+61nIU/NFYTRZkmaaP+IAuNbp FXtXCRRI8i6DH7xjJsfTEnrTpfSnOMAOO6jW2BWi601h/MKz03Hxc+zBgRx0K+VLxoBO 9T99UfO9RwMVgSmnSynHuvoH8jGxfijxWjUG9oXHiiDVehtCbBS0/9T+O/+RA/aKpO9R bl75g3dAyBRlFD5N18ue2et6Y6PtJ3ZpC+DYesRpshsvG0FCp27ecDUavjJcyYfxqbWZ wJ550lHZ1oGXqPGPAzu0Z8kv5Dvj2klVkyDLEWJiKN9jZS9reLAoj4O93cJIecZx/4b1 Lg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:34 -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:54:32 -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:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 5A7D3B2F; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 4/9] ASoC: rt1316-sdw: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:27 +0000 Message-ID: <20221123165432.594972-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: UXrKF7IG1e0Mvt10ZironzDVxiCvyKwn X-Proofpoint-GUID: UXrKF7IG1e0Mvt10ZironzDVxiCvyKwn 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. Changes since v1: - Correct spelling error in commit message 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 Wed Nov 23 16:54:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053975 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 CE138C433FE for ; Wed, 23 Nov 2022 16:57:25 +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 019A616C8; Wed, 23 Nov 2022 17:56:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 019A616C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222644; bh=Wp4ujXJCwjgoMs590CthzFBpeUha1MDY6Dk8MUsydRs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Qw5xBepBSX2peOl14zAWwJcl6gjfD9+d+8y/nSzgtLybWn/PRzGBp+Nu/MtAJAdmA 9GWBduKPjXNUTwv76/keeVVYwtBZ8UgPWOzMZcYyeqQayuOJBRke9V9k8v6meNmZco 8aCnRWnY/I1DgCHhELlqIbK5egkMpH0MaXw1J7Vc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C7B21F8057C; Wed, 23 Nov 2022 17:54:57 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 59A8BF80425; Wed, 23 Nov 2022 17:54:51 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 DA528F8049C for ; Wed, 23 Nov 2022 17:54:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DA528F8049C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="hnZKLk2G" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduH006384; Wed, 23 Nov 2022 10:54:38 -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=nfAyzypkSl8tXHDBjA35MtQcO4PAoUx/9zbH7C0od/g=; b=hnZKLk2GyfDJMHYzVJ+B2QHQghDNe3mQt3PuTRzyo33npIXGO4P9GiklGASFloJpfzch 4GNQCYfbb5/CwFCmRWBYyPFsqc3JwERnjscC15L8DK4mD+VJfQh03VEV0TRvCdrc/r/v 8yXilbe4PRi9umQZEIcyn1vAKLlPJ5jTJ9uUYIEmgDzXycQt8MHQ85PaIydqRlXir5kf hhl7BvRHt8Mo1cMVmKLyNqSuwS9eYb7Ofl2wbOeaRYixSfv0ASnAjrZ0BQWZAJE9Km1h Xzd9qsQXdmQ+r6SBVpIrVGjp+myatUJEJ3wDTQbQywM6Vj0RGwFwFWXAx/hrCKGWTchI dw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y2-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:37 -0600 Received: from ediex02.ad.cirrus.com (198.61.84.81) 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; Wed, 23 Nov 2022 10:54:32 -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; Wed, 23 Nov 2022 10:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 67F922BA; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 5/9] ASoC: rt5682-sdw: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:28 +0000 Message-ID: <20221123165432.594972-5-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: eHs-mdUNpki09CQLZMN2V6Yi1M1F9EgC X-Proofpoint-GUID: eHs-mdUNpki09CQLZMN2V6Yi1M1F9EgC 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. Changes since v1: - Correct spelling error in commit message 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 Wed Nov 23 16:54:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053974 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 481BCC433FE for ; Wed, 23 Nov 2022 16:56:59 +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 4B2F816C5; Wed, 23 Nov 2022 17:56:07 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4B2F816C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222617; bh=jb1Ewya0Is1lSip/oyU6xRjOg4BLKBZUNret2LoRDq8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lXIy9oec/vBi3+z+w+vNSVtqDz9vnL1RRYR5VvCZcyxy8ruXXMPPaSM5be0vGk9dW +4tL47aFGpv7akAaEviDozsHchNfgQDM7A4KHIcB7RfMXlZhccgNPMNva8WecwpMBU 3MC7ZPJ6WMCJp9E71xihAw6U6FNQtjyaD7TNI7kE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BB896F8056F; Wed, 23 Nov 2022 17:54:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E6AA9F8030F; Wed, 23 Nov 2022 17:54:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 33F8BF80425 for ; Wed, 23 Nov 2022 17:54:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 33F8BF80425 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="E+tWZRqu" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduG006384; Wed, 23 Nov 2022 10:54:37 -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=m4zMIYi/2oihShV6tVLBFA7rfV4X0X3ovtCOMZq46NE=; b=E+tWZRquO2WxbfuFVqHslmY1/ZFlwnhlpecwRy4Av2uuAFD+mLFqznbaGpWrt7tP4mWv pfa4MV/bd1GChiccoQDkEY7ag9pLw5l4CoZnibdpIbkwFPnNp19bJWxFc6ARYHg93ROM WSnP9VFlSQKZAlvoorMh1AiJYFBj+3LXcPV4TVEhyodTL8zA3IJy2QORNa4Mu6cZvzB0 xSJd8orLQsranYy7qORCWLweOw31t8oeJGlyOGUSuu5ut0Gix2hWTN08qk3zAvodD8cm 5+KSDb1H6GXT8vfE8fUF9LUm51LT0tlzh9m9IxD9Ir4QH0U0q1YM+FYuO0UbaPU1wFgp +A== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y2-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:37 -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; Wed, 23 Nov 2022 10:54:32 -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:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 769A0B38; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 6/9] ASoC: rt700: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:29 +0000 Message-ID: <20221123165432.594972-6-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: F3l5p1g9RigKRZ6GXNMCxxF-g06iiVe2 X-Proofpoint-GUID: F3l5p1g9RigKRZ6GXNMCxxF-g06iiVe2 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. Changes since v1: - Correct spelling error in commit message 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 Wed Nov 23 16:54:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053977 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 D2E0AC433FE for ; Wed, 23 Nov 2022 16:57:50 +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 0BCAC16D4; Wed, 23 Nov 2022 17:56:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0BCAC16D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222669; bh=oV0VoVDE8sLbJbnEcKnUqeeAx0WAgYa0WTtpEyuoS9A=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=XoIRP5rqlMVBhGqrEN6AWYdoylfeN2mtGQNW/fE3G9dXQb9w5da9M3JO6diFZ70hz pBUjan0U0fr4Hor6kN4y2RQ6Owb4nM0Sle2LP0r11jlnEmj9azTX5d7ae6p/+Vdx+8 ncqNnBbpWHjRNu9srrQES6BlYu0x99RQ7wWqO2zc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EDD12F805A0; Wed, 23 Nov 2022 17:54:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B6E13F80564; Wed, 23 Nov 2022 17:54:53 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 2EAA9F8052E for ; Wed, 23 Nov 2022 17:54:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2EAA9F8052E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="YwDcBVRe" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduI006384; Wed, 23 Nov 2022 10:54:38 -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=qUanRzk1dQ/Jw6R57HprtSFafC2t2pr8jSCrdDn238Q=; b=YwDcBVReM39zkPo8yH0Yzzqffb+e/re2pWOazlNYsV5SOA2rHn+1cskhEyxrmFFe+QO3 qUfFfMRph9r/TJB/fcjjbeAjP8QTMCGvrxaCo0xQISOlMlU9qdUQeTvX9HTS6S677yTz MPwgiSCqELx4HrQDb8x61xx+qSWgnVUTBL6r36qjPy28p0UzeFTe5JFNEyQFWwL8Nk/Q lndonXyQabDZ6q1mh3TAwGVikEZzkSE7xdyeSIwf8g5cSm5xnp5OcBcxT5O1xhC/FKvv iXgdSaYf3khxXS7mN9iRHam7Xc9rQWGCBiWwHh+xXDVAkWAHw3F4GJz8uF0MPOn3jD7E Vw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y2-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:38 -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; Wed, 23 Nov 2022 10:54:32 -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:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 840E9477; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 7/9] ASoC: rt711: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:30 +0000 Message-ID: <20221123165432.594972-7-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: _W0iwbynrcurzYZeLRqg4t6FN4yESA0p X-Proofpoint-GUID: _W0iwbynrcurzYZeLRqg4t6FN4yESA0p 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. 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) { From patchwork Wed Nov 23 16:54:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053972 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 E29EEC4332F for ; Wed, 23 Nov 2022 16:56:33 +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 2D19916B8; Wed, 23 Nov 2022 17:55:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2D19916B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222592; bh=Hco538caHz3msHr9WLCjMHCT+nL+QyiYbH8Ht/8qDB8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mJtW3bklXl38WEr5x5sjrpHwHF4SJ+5UwEuOPovHzquygvTqTz4av8jc5wIkD/H3D ZHg8lcte5zQmZJnbsLBXpL2kdhUKtZYjgEtJQc80XzRE1NXpwRLF183iNPDE3tMInN hohUnLUKJINaBiBscBQt1ex3pnSa0i8ijlQI6Et8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1B21AF80563; Wed, 23 Nov 2022 17:54:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 84222F8055C; Wed, 23 Nov 2022 17:54:50 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 9D436F8030F for ; Wed, 23 Nov 2022 17:54:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9D436F8030F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="BDobCsXE" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduE006384; Wed, 23 Nov 2022 10:54:35 -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=wgRTssEu2w5Mylljk8yiXJHn5yVxK0sGctk5ConTiHw=; b=BDobCsXEVsA8KIqe7wiuaMMqdt8wMdWgf+9Z4RtzmiProBcaZt+2esq0forVMSvW5F8/ tWQcx9lChFKhFItuaMlUetgCQ5yVT6LFnoUK25VW5w3AtwSAl81m70eaMTHo6AdIqBgV JkAD1vcTAvIiwBJhFv74ZGsmoQgKoDEOVOpZnIFT9XxwC8K/no8C/7WOY3TLojwSoOIl yv0MyaXlMt6VEJIGlMZ8a48WhuesItqMxiPyFJyqfKaNhbKQxkGbtjW43U0dmkHV8MPk iQgS+LiJTtCfM2dTL4kc3LhOHqJkR6+8T/+OT9k3l9WWWBUEFi0OCyCqCouHi6DTO0by cQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y3-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:35 -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:54:32 -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:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 91E22B10; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 8/9] ASoC: rt715: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:31 +0000 Message-ID: <20221123165432.594972-8-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: mvtb-bOpvnVOSj11CO0peHpIR9R8vh6L X-Proofpoint-GUID: mvtb-bOpvnVOSj11CO0peHpIR9R8vh6L 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. Changes since v1: - Correct spelling error in commit message 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 Wed Nov 23 16:54:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13053976 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 B6BCEC4332F for ; Wed, 23 Nov 2022 16:57:38 +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 EEC5216B4; Wed, 23 Nov 2022 17:56:46 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EEC5216B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1669222657; bh=3HuWPMejnXxCXddb/nZmnvUCXnznPqEmb/LxJmRBahg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QOTR4iqmkW37nY2/ow7Ave2qN/10HmGYWBfzauQn4brABmrULS12gCcxCYriZaw5l UbnITkLPZjPUBQPEIRtYsXPCMOTgBYpupP2kiACrcQ7TTBmk1Rqb88zBfnVcFnshN4 t4bq5uKRsZmns/hCRLFJqdVNJf0P0HcmKFFxss+0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 57889F80588; Wed, 23 Nov 2022 17:54:58 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1DB4EF80564; Wed, 23 Nov 2022 17:54:53 +0100 (CET) Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (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 70F4BF804D2 for ; Wed, 23 Nov 2022 17:54:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 70F4BF804D2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="fuw62BhT" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ANFXduJ006384; Wed, 23 Nov 2022 10:54:39 -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=xROx/JlKiBRWUCtcXj6gr9epkTeM6fJWFLju/GJ43NA=; b=fuw62BhT/F1C96UYywCUGxLyIS+g9aF4f0w653HeXtDQ0aK+ELGN7LJYEzuE4qR3MjFX 7YyNx5t+QAbkbRS9E4mk0y3RP6GEOCo8MaetDokoe8/z2pHaUHAPUKLiJSgAscxn20Zm G0KGNpep/arQwiyWe500hSlDpIRewIfbYOWRy2zBx0P0ncT39Ak/aYlArqurM525S1n5 AePL/Rac4VAU03IlGPn3RzUTOpgXuNk0uRDcLUDFolA74g9UuP42oLdOuODwk8XsfKeQ B/QePPu2fTQAMMqXZExFi+WeGiby7BHqHpdp2g7DnE3oh25alk9pdzfEtstSVkZj3qH6 EA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3kxwe6w4y2-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 10:54:39 -0600 Received: from ediex02.ad.cirrus.com (198.61.84.81) 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; Wed, 23 Nov 2022 10:54:32 -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; Wed, 23 Nov 2022 10:54:32 -0600 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 9FD952BA; Wed, 23 Nov 2022 16:54:32 +0000 (UTC) From: Charles Keepax To: , Subject: [PATCH v3 9/9] ASoC: sdw-mockup: Switch to new snd_sdw_params_to_config helper Date: Wed, 23 Nov 2022 16:54:32 +0000 Message-ID: <20221123165432.594972-9-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> References: <20221123165432.594972-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: nmZ8yVWqRWIsun0j7Cr1vDgGNepu6oZP X-Proofpoint-GUID: nmZ8yVWqRWIsun0j7Cr1vDgGNepu6oZP 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 conversion can be handled by the new snd_sdw_params_to_config helper function. Signed-off-by: Charles Keepax --- Changes since v2: - Correct other spelling error, sorry. Changes since v1: - Correct spelling error in commit message 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);