From patchwork Wed Mar 25 21:29:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 11458709 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB19492A for ; Wed, 25 Mar 2020 21:43:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7365F2070A for ; Wed, 25 Mar 2020 21:43:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="ADRv3ueN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7365F2070A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 9EDC21667; Wed, 25 Mar 2020 22:42:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9EDC21667 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1585172585; bh=qiYY/ZtPAHBDYBBHj6fs+4fSTdpycFRPP8tUCYaqJ7Y=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ADRv3ueN5X4FkUh7x4QlHXop2vsmIUxEXRJQPiCVIKzHsqYkakRCLV9jCkyN3CHTC toV5Mvw26MbkS8biMaLFTq4OxGOFJ5r5119MS4Ftgas2NLIZ256Wd/2CoiKPViZsIU QJcKrcHsBDEaBTlKq82DRpNjBMhpC5u7Sg1u4szg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 270F7F8028F; Wed, 25 Mar 2020 22:42:21 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 17863F8011E; Wed, 25 Mar 2020 22:39:40 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 4295BF800EF for ; Wed, 25 Mar 2020 22:29:33 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4295BF800EF IronPort-SDR: BM0xnR6AKXptoQCjdduQm8lI2I9R+chJVEgg7dT3sjC2dt+yR+LTqbE0xevFsiDUd6IRGbO2cE dkDLUjpY1ubQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2020 14:29:16 -0700 IronPort-SDR: gli4SWSuAIOSKmj7LF61q2T486neciKM3cXL3uP5yONXSLtWNKif0AONwd2kSG6D7gFU4SaHyM I3/dUN+WPHng== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,305,1580803200"; d="scan'208";a="393759855" Received: from abeljans.amr.corp.intel.com (HELO pbossart-mobl3.amr.corp.intel.com) ([10.251.233.195]) by orsmga004.jf.intel.com with ESMTP; 25 Mar 2020 14:29:15 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH 1/2] ASoC: rt1308-sdw: add set_tdm_slot() support Date: Wed, 25 Mar 2020 16:29:04 -0500 Message-Id: <20200325212905.28145-2-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200325212905.28145-1-pierre-louis.bossart@linux.intel.com> References: <20200325212905.28145-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: tiwai@suse.de, broonie@kernel.org, Pierre-Louis Bossart 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" Add ability to select which of the channels is used, or both, in case two RT1308 amplifiers are located on the same link. Signed-off-by: Pierre-Louis Bossart --- sound/soc/codecs/rt1308-sdw.c | 23 +++++++++++++++++++++++ sound/soc/codecs/rt1308-sdw.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c index d930f60cb797..8763192434c4 100644 --- a/sound/soc/codecs/rt1308-sdw.c +++ b/sound/soc/codecs/rt1308-sdw.c @@ -507,6 +507,28 @@ static void rt1308_sdw_shutdown(struct snd_pcm_substream *substream, kfree(stream); } +static int rt1308_sdw_set_tdm_slot(struct snd_soc_dai *dai, + unsigned int tx_mask, + unsigned int rx_mask, + int slots, int slot_width) +{ + struct snd_soc_component *component = dai->component; + struct rt1308_sdw_priv *rt1308 = + snd_soc_component_get_drvdata(component); + + if (tx_mask) + return -EINVAL; + + if (slots > 2) + return -EINVAL; + + rt1308->rx_mask = rx_mask; + rt1308->slots = slots; + /* slot_width is not used since it's irrelevant for SoundWire */ + + return 0; +} + static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { @@ -597,6 +619,7 @@ static const struct snd_soc_dai_ops rt1308_aif_dai_ops = { .hw_free = rt1308_sdw_pcm_hw_free, .set_sdw_stream = rt1308_set_sdw_stream, .shutdown = rt1308_sdw_shutdown, + .set_tdm_slot = rt1308_sdw_set_tdm_slot, }; #define RT1308_STEREO_RATES SNDRV_PCM_RATE_48000 diff --git a/sound/soc/codecs/rt1308-sdw.h b/sound/soc/codecs/rt1308-sdw.h index c9341e70d6cf..c5ce75666dcc 100644 --- a/sound/soc/codecs/rt1308-sdw.h +++ b/sound/soc/codecs/rt1308-sdw.h @@ -160,6 +160,8 @@ struct rt1308_sdw_priv { struct sdw_bus_params params; bool hw_init; bool first_hw_init; + int rx_mask; + int slots; }; struct sdw_stream_data { From patchwork Wed Mar 25 21:29:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Louis Bossart X-Patchwork-Id: 11458707 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D674192A for ; Wed, 25 Mar 2020 21:42:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6EB6F2070A for ; Wed, 25 Mar 2020 21:42:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="KlN7vGNI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EB6F2070A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 ADB191661; Wed, 25 Mar 2020 22:42:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ADB191661 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1585172566; bh=dG8nlJmjN7t26VXvSzvGTw2motg9M/45XH+BAO0xdX8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=KlN7vGNI/6W5EMb96JSylGcLkSi7IyAZA2xJwcl6N+cnoeIZBsPfXEOm70otbRo7V ibI88cd8R6fCFTfb9R9ZFUqpRPuhp1SPDYb/eydmwYQrrLym8qe5BCdW1kzgWGnGb/ Fn1Uro/GeLVHoyC8j5yssyWOzHgmXHPyBc8IGhMQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B7F4DF8028D; Wed, 25 Mar 2020 22:42:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3029FF8028E; Wed, 25 Mar 2020 22:39:40 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 CB67FF80158 for ; Wed, 25 Mar 2020 22:29:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CB67FF80158 IronPort-SDR: lmuYRefM3WOzk3Z2fN0EfgeQOM+W1hBvZSP9F8sssY+fJGeqSS9ZXoQHlWNPL+lXLBA80t9rj1 uamqJ/mMK1wQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2020 14:29:17 -0700 IronPort-SDR: jIezQuQEHXSgkpbkecr7EY9jAqLHmDgwFcH3A2UWkvp6r14fle9lXNMjGzNkOoV2OP3BhMvz6N Q+NJfbw0/Izw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,305,1580803200"; d="scan'208";a="393759860" Received: from abeljans.amr.corp.intel.com (HELO pbossart-mobl3.amr.corp.intel.com) ([10.251.233.195]) by orsmga004.jf.intel.com with ESMTP; 25 Mar 2020 14:29:16 -0700 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Subject: [PATCH 2/2] ASoC: rt1308-sdw: use slot and rx_mask to configure stream Date: Wed, 25 Mar 2020 16:29:05 -0500 Message-Id: <20200325212905.28145-3-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200325212905.28145-1-pierre-louis.bossart@linux.intel.com> References: <20200325212905.28145-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: tiwai@suse.de, broonie@kernel.org, Pierre-Louis Bossart 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" If the DAI was configured with a set_tdm_slots() call, use the information. A platform or machine driver may configure each amplifier to extract different bitSlots from the frame, or extract the same data and use processing to generate the relevant output. The latter case is easier to handle in case of orientation changes. Signed-off-by: Pierre-Louis Bossart --- sound/soc/codecs/rt1308-sdw.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/rt1308-sdw.c b/sound/soc/codecs/rt1308-sdw.c index 8763192434c4..a5a7e46de246 100644 --- a/sound/soc/codecs/rt1308-sdw.c +++ b/sound/soc/codecs/rt1308-sdw.c @@ -539,7 +539,7 @@ static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream, struct sdw_port_config port_config; enum sdw_data_direction direction; struct sdw_stream_data *stream; - int retval, port, num_channels; + int retval, port, num_channels, ch_mask; dev_dbg(dai->dev, "%s %s", __func__, dai->name); stream = snd_soc_dai_get_dma_data(dai, substream); @@ -559,13 +559,20 @@ static int rt1308_sdw_hw_params(struct snd_pcm_substream *substream, 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.frame_rate = params_rate(params); - stream_config.ch_count = params_channels(params); + stream_config.ch_count = num_channels; 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.ch_mask = ch_mask; port_config.num = port; retval = sdw_stream_add_slave(rt1308->sdw_slave, &stream_config,