From patchwork Mon Aug 27 14:21:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10577139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0CC11390 for ; Mon, 27 Aug 2018 14:21:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC72329C4C for ; Mon, 27 Aug 2018 14:21:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A016D29C5B; Mon, 27 Aug 2018 14:21:23 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3DCF29C4C for ; Mon, 27 Aug 2018 14:21:22 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5CC8B267849; Mon, 27 Aug 2018 16:21:19 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 501B126784F; Mon, 27 Aug 2018 16:21:17 +0200 (CEST) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by alsa0.perex.cz (Postfix) with ESMTP id 16F812676C9 for ; Mon, 27 Aug 2018 16:21:14 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id c14-v6so8280171wmb.4 for ; Mon, 27 Aug 2018 07:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=K3J/C6PUSNPX+1+GRCl8rpXvyVQLnz/WgMlsu3+XANg=; b=vf0DiFJwRaNotCzttmjhzO+/6CIQvsrTowfK2DdgpQfkhPAQwPrLchYMTYwQrM7b2G vZb5U5HpGQ8kOf3iHQV3BPYnTQSfK/6FzmhyQ5yMW49EGCVLqaeTHauvUlLmVzTJ3ybJ LUiEnC1n5yZ+hpX+4zW8O203FAQnahYOq5Fqrol3EW5ue4VkpcwxtYG+1zX1sb3d2JUr 3nLBi8jfzht11fGep5Ke6aaAzXsT/N0dFTKUgXFhNnhSpJR5RLouO2Svz4o+lNUXAbMy uGP7k8ZWO8n8KzC4LEpiv6dh72xRsOZzUMWrvJ6RpFviSh6i1PVycArod4dszqbU1WhF UHaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K3J/C6PUSNPX+1+GRCl8rpXvyVQLnz/WgMlsu3+XANg=; b=TSiwjH43L5Kxky8UtNR5h66MzFSKX1UNN1jLYDS6uo/0SesQEnUy//PtRvCZP088yn /D1xSOpGMCT4Gd5Q9hFvfz8TgAMURKU4oMpCRQAcrtiZk7L7Q0/fkV3LAtNrdzHDHCFC fyFwHeuDN2fBcPnhXWp8BHcQTeWw/07/jQ9qVl1IwpqtxV+qvO1oB3B+8lqONWl7Mv0t d6jnahtpNKEGuCLylyGCu6RyNzHe6XLFC9mvEIHp/c5yIRGKUDi0yQu679770qaQo44h 4+Nm2nPX3oyFVxrJAGyt5eWakUIRF9IXutvL9V1BnFN+rlQteiiI6WXsJa5fsyQo4JCI NMAg== X-Gm-Message-State: APzg51C7TzuVzHJrsSEdQ6RKAOhZVgjlGvhB0qG2l+F6LcDdpuIGiM8R tqAw046Z0rBMm0Ezj8vyT4FF2Q== X-Google-Smtp-Source: ANB0VdaADToHHkN+eBe+rDUGovJPgFEXMYtgLsWlH8dvc5s8Y3l+Huyrge30zc97EuEyVOFDDajkaQ== X-Received: by 2002:a7b:c04c:: with SMTP id u12-v6mr3627156wmc.24.1535379674517; Mon, 27 Aug 2018 07:21:14 -0700 (PDT) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id 204-v6sm13896316wmh.25.2018.08.27.07.21.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Aug 2018 07:21:14 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman , Carlo Caione Date: Mon, 27 Aug 2018 16:21:07 +0200 Message-Id: <20180827142107.8153-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.17.1 Cc: linux-amlogic@lists.infradead.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jerome Brunet Subject: [alsa-devel] [PATCH] ASoC: meson: axg-tdm: restrict formats depending on slot width X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Restrict the formats possible on the TDM interface depending on the width of the TDM slot and let dpcm merging do the rest. Fixes: d60e4f1e4be5 ("ASoC: meson: add tdm interface driver") Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-tdm-interface.c | 50 +++++++++++++++++------------ 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/sound/soc/meson/axg-tdm-interface.c b/sound/soc/meson/axg-tdm-interface.c index 7b8baf46d968..585ce030b79b 100644 --- a/sound/soc/meson/axg-tdm-interface.c +++ b/sound/soc/meson/axg-tdm-interface.c @@ -42,6 +42,7 @@ int axg_tdm_set_tdm_slots(struct snd_soc_dai *dai, u32 *tx_mask, struct axg_tdm_stream *rx = (struct axg_tdm_stream *) dai->capture_dma_data; unsigned int tx_slots, rx_slots; + unsigned int fmt = 0; tx_slots = axg_tdm_slots_total(tx_mask); rx_slots = axg_tdm_slots_total(rx_mask); @@ -52,38 +53,45 @@ int axg_tdm_set_tdm_slots(struct snd_soc_dai *dai, u32 *tx_mask, return -EINVAL; } - /* - * Amend the dai driver channel number and let dpcm channel merge do - * its job - */ - if (tx) { - tx->mask = tx_mask; - dai->driver->playback.channels_max = tx_slots; - } - - if (rx) { - rx->mask = rx_mask; - dai->driver->capture.channels_max = rx_slots; - } - iface->slots = slots; switch (slot_width) { case 0: - /* defaults width to 32 if not provided */ - iface->slot_width = 32; - break; - case 8: - case 16: - case 24: + slot_width = 32; + /* Fall-through */ case 32: - iface->slot_width = slot_width; + fmt |= SNDRV_PCM_FMTBIT_S32_LE; + /* Fall-through */ + case 24: + fmt |= SNDRV_PCM_FMTBIT_S24_LE; + fmt |= SNDRV_PCM_FMTBIT_S20_LE; + /* Fall-through */ + case 16: + fmt |= SNDRV_PCM_FMTBIT_S16_LE; + /* Fall-through */ + case 8: + fmt |= SNDRV_PCM_FMTBIT_S8; break; default: dev_err(dai->dev, "unsupported slot width: %d\n", slot_width); return -EINVAL; } + iface->slot_width = slot_width; + + /* Amend the dai driver and let dpcm merge do its job */ + if (tx) { + tx->mask = tx_mask; + dai->driver->playback.channels_max = tx_slots; + dai->driver->playback.formats = fmt; + } + + if (rx) { + rx->mask = rx_mask; + dai->driver->capture.channels_max = rx_slots; + dai->driver->capture.formats = fmt; + } + return 0; } EXPORT_SYMBOL_GPL(axg_tdm_set_tdm_slots);