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: 145185 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp16444ljw; Mon, 27 Aug 2018 07:21:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbNFwcJ9YD1RKG3upCCbVcWslNqOWGnrIKzV3s4/Lf86TlY0PuhferThPESspv7B/mwu6r5 X-Received: by 2002:a1c:910d:: with SMTP id t13-v6mr5450017wmd.15.1535379680688; Mon, 27 Aug 2018 07:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535379680; cv=none; d=google.com; s=arc-20160816; b=zJ7+iJIvOIHT8d+EWxacuwJasEBRYlhZIkxD6SxlwelTlXzYrx3nw9AgVolVjcBbDG rcj84OK8WPeQRQir/w/OmP3DHqd+HxOzIazq9euoDpjKWd086C7P4YqPwgT36TeB4JkA /+SnY80DGuOM4pYuWP/At8Ai3KM/BMKTX9qMzP5wM8elqk3xPHfjpE/+fs7BOjDc92na 1Unixi2bBB0E3iN3XMMkuJNfKZA30Yftjg0I76/fTAxBmc855vxw0O1uW7h3wXHIV6C1 I2tkhmKZCqlHpnDaRmOELz15ohlVaeLA2XOJQZOYW0kIJdufvNpvn6iZMMJbfGOfia3I +tMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=iQLCWhC40eG2PBzpfwOwAENE56mhguyIyaJ2t17b9xc=; b=iZnrXdlbZTegndz87z6+jUQITRiRbXANzlPOs0zusV7yzsd/698I4uW52XsAv1QiYI T3gx3dK8ljIvS24N68LVAqyL6OxwA0Rh6wFrJcJx2D62TN6PbaTzHJeo2DLLy22I4ymy 4nxKdEBng9u/0nKIqoKrP1ddMdS9AXuxI0nGUKHALHXbJ83eHqBm+ENYLE25y+oo5hss lmYs8IRSJlxu0msD8+HZYHBiFf7gVVJrDaEtMUJ05wmvqmo9agRmIscGyiNkEfl+EYrx w74e6anV8JNNTEwGg9bK5SMsrPE4CbpvWpmPD3j6eE2sUIKGieyiMd44wdu86I88VRBr Iiiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=vf0DiFJw; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id t82-v6si6971993wme.177.2018.08.27.07.21.20; Mon, 27 Aug 2018 07:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=vf0DiFJw; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_SOFTFAIL, T_DKIMWL_WL_MED autolearn=disabled version=3.4.0 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-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 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(-) -- 2.17.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel 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);