From patchwork Tue Feb 14 21:04:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Flax X-Patchwork-Id: 9572899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD79060586 for ; Tue, 14 Feb 2017 21:05:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9C14283F6 for ; Tue, 14 Feb 2017 21:05:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACF6B28411; Tue, 14 Feb 2017 21:05:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 26E34283F6 for ; Tue, 14 Feb 2017 21:05:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/yNZh+NPGdRvLWYBqizClZtl1z4DUMXwv08Hkppzh+c=; b=iXnEQTJosngZCLfs7QIlsCF14k yPS9hdvoLohBxQyCMr9OpuUl8SbmHajhTIVJp+quHvhc99zASL4akugqpCmlmPJJg+5Qx7wHS0aaE kTItL9RjgcAPhL158mLTbF4dwsDEt56diN4GUsqVCMa/e7ekxT2CPv1rF33VZc1TAvmMsXs0GqhOp Q+mNpKSjZF4SBKXJXGAmZPoR/BvSwKGhGuiXCgMPn7QNvQwT19A7/1INxvNNkSM+YOKpxbwr9Ccrk yMPlPwb+Tw15Yq2rxmIrWqcc45D0e+TzsqbMbHKMQwmWoYyG/148nAqS+CIiNDDMiQeMy49aGOriM xkPf2a0w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cdkHo-0002Mx-Q5; Tue, 14 Feb 2017 21:05:20 +0000 Received: from ipmail04.adl6.internode.on.net ([150.101.137.141]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cdkHj-000113-KJ; Tue, 14 Feb 2017 21:05:17 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2B5DQBZcKNYEM0kwzFdHAEFAQsBgmtoQYEphwSHT492BpRJhBuGHAQCAoF+WAECAQEBAQECBgEBAQEBAzhEhGoGJy8jEFE5ChQHEoleDLFKOoQQh1YBAQEHKIYIj2wFj0OML5IWkQOTFVaBASAUCCIIhQIdgXUsNYoHAQEB Received: from pa49-195-36-205.pa.nsw.optusnet.com.au (HELO localhost.localdomain) ([49.195.36.205]) by ipmail04.adl6.internode.on.net with ESMTP; 15 Feb 2017 07:34:52 +1030 From: Matt Flax To: alsa-devel@alsa-project.org, broonie@kernel.org, florian.meier@koalo.de, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, swarren@wwwdotorg.org, lee@kernel.org, phil@raspberrypi.org, eric@anholt.net, ckeepax@opensource.wolfsonmicro.com Subject: [PATCH v4] ASoC: bcm2835: Add 8 channel (multitrack) capability Date: Wed, 15 Feb 2017 08:04:35 +1100 Message-Id: <1487106275-4260-1-git-send-email-flatmax@flatmax.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486942035-24038-1-git-send-email-flatmax@flatmax.org> References: <1486942035-24038-1-git-send-email-flatmax@flatmax.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170214_130515_879917_746071A4 X-CRM114-Status: GOOD ( 10.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matt Flax MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds multitrack capability if in DSP mode A and the codec is master. In bcm2835_i2s_startup, snd_pcm_hw_constraint_single is used to set channels to 8 if both SND_SOC_DAIFMT_CBM_CFM and SND_SOC_DAIFMT_DSP_A are set. Otherwise, channels are set to 2. These settings are accomplished using the SNDRV_PCM_HW_PARAM_CHANNELS variable. In bcm2835_i2s_shutdown the channels are set to 2 by default. In bcm2835_i2s_hw_params, DSP mode A format is now an option. Before replicating the format variable (from ch2 to ch1) for register loading, requested channels are checked to be either 2 or 8. This can be expanded later to accomodate other channel counts if supported by the sound card hardware. Signed-off-by: Matt Flax Reviewed-by: Charles Keepax Acked-by: Florian Kauer Acked-by: Eric Anholt --- sound/soc/bcm/bcm2835-i2s.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c index 6ba2049..300516d 100644 --- a/sound/soc/bcm/bcm2835-i2s.c +++ b/sound/soc/bcm/bcm2835-i2s.c @@ -296,6 +296,7 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, switch (dev->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_DSP_A: data_delay = 1; break; default: @@ -312,6 +313,7 @@ static int bcm2835_i2s_hw_params(struct snd_pcm_substream *substream, switch (params_channels(params)) { case 2: + case 8: format = BCM2835_I2S_CH1(format) | BCM2835_I2S_CH2(format); format |= BCM2835_I2S_CH1(BCM2835_I2S_CHPOS(ch1pos)); format |= BCM2835_I2S_CH2(BCM2835_I2S_CHPOS(ch2pos)); @@ -526,7 +528,16 @@ static int bcm2835_i2s_startup(struct snd_pcm_substream *substream, regmap_update_bits(dev->i2s_regmap, BCM2835_I2S_CS_A_REG, BCM2835_I2S_STBY, BCM2835_I2S_STBY); - return 0; + /* Set the max channels to 8 if the codec is master and + * we are in DSP A mode. Otherwise only allow 2 channels. + */ + if (dev->fmt & + (SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_DSP_A)) + return snd_pcm_hw_constraint_single(substream->runtime, + SNDRV_PCM_HW_PARAM_CHANNELS, 8); + else + return snd_pcm_hw_constraint_single(substream->runtime, + SNDRV_PCM_HW_PARAM_CHANNELS, 2); } static void bcm2835_i2s_shutdown(struct snd_pcm_substream *substream, @@ -549,6 +560,10 @@ static void bcm2835_i2s_shutdown(struct snd_pcm_substream *substream, * not stop the clock when SND_SOC_DAIFMT_CONT */ bcm2835_i2s_stop_clock(dev); + + /* Default to 2 channels */ + snd_pcm_hw_constraint_single(substream->runtime, + SNDRV_PCM_HW_PARAM_CHANNELS, 2); } static const struct snd_soc_dai_ops bcm2835_i2s_dai_ops = { @@ -576,16 +591,12 @@ static struct snd_soc_dai_driver bcm2835_i2s_dai = { .name = "bcm2835-i2s", .probe = bcm2835_i2s_dai_probe, .playback = { - .channels_min = 2, - .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE }, .capture = { - .channels_min = 2, - .channels_max = 2, .rates = SNDRV_PCM_RATE_8000_192000, .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE