Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3215302ybi; Mon, 17 Jun 2019 19:25:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzBFsp7g5F1qiSiI7BnIz1eFEd5FuwhBQlXoNmpUjZ4w/AaPdqWu9Q7/EFKUE8d4kX9Xsy X-Received: by 2002:a63:2249:: with SMTP id t9mr399346pgm.149.1560824720285; Mon, 17 Jun 2019 19:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560824720; cv=none; d=google.com; s=arc-20160816; b=HyHmnJJwdLz6QLBHBNtbv3RL2O2+tKK3zL5G4D6g02b84aHRUj53FYVzvnxsgNolli FYfglkqAaUu3uQz7dEn8IHumuP7OiThkaF9PQ0I9uleFfS7r3EQuB08DMaKlOX55z7rN BsRV+MG+btF+Syjr7faBR150ndG8xPZJDjIiTP7976Wtd7KkD7RqpBCKwi4GBi3If7po N1mLb0AbVFxdUpdwJ+SZmBVgfBE587jn5nqcC752+imHhrlc54/HDoWqIWKys+Vz3OUX a9l2aVBZhJCB8JNNEtek4qZlao0YoI6CrhnwKtyUnzQb1zHFC+s9ZkmWUqshktzcRyPn z5mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Yw03RFVQcw38KaDua5lfZL2d94vDmgCgBzJoqXkOo3o=; b=kX5FxZIHOXYP5RCw8uwh7vr7tF9/lsboMoLqYjmlXj2z4CkA2jm1BHl4OJ5O5/s9VT VTZKR/TdaLig5G5RwJwAkvJqfP790xU81G/j6eu95epGAZfkAbqL5H6aN6LOCYNHXlhY CcZRLnCiUMUNTy6ANVgcnlNCF0XhyXvU2dx4nxGMN8AkNe5PeMWbZi6qhol5N2IiErmG UiF+Pl/EkrTvmBdBz/w4zCx+C8BnC/lb9/gW+zkXwQpNNNVNgVkDbs8YubgeuyTQ+S5Z kK9UEYKEBuMRKlpO2kynknyKeNYoyCRnw13CGEKdb2HakC7AUPPzV7QsjNihXmy9HrUe XA5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LVk29ML2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si11833094pgs.312.2019.06.17.19.25.04; Mon, 17 Jun 2019 19:25:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LVk29ML2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728101AbfFRCYW (ORCPT + 99 others); Mon, 17 Jun 2019 22:24:22 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36580 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726088AbfFRCYW (ORCPT ); Mon, 17 Jun 2019 22:24:22 -0400 Received: by mail-pl1-f195.google.com with SMTP id k8so4044928plt.3 for ; Mon, 17 Jun 2019 19:24:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Yw03RFVQcw38KaDua5lfZL2d94vDmgCgBzJoqXkOo3o=; b=LVk29ML2Mk7TxhTiFLm8J7/YvF/o+CR7DzBBXQPGajlXfqUxXGXJ4EhHkqq5u4Lc16 YugCinbdUozD6ADaCMon/inXwIx77+du+fQc6e0aD5WwA6cZJQYREkJdz1/MUIWPda3y pJkmCgvOHdNqJt9VZoHIq6UaUIKh9IBP8aybQ= 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:mime-version :content-transfer-encoding; bh=Yw03RFVQcw38KaDua5lfZL2d94vDmgCgBzJoqXkOo3o=; b=ZTKoBrH/YISH7YQGlM3/BrjwCbIg5ZP2QZ7JgMsOz5xRROp8sMAzHsQh6Z2v93eF2q 1/2/4ghw65gj2QsOrOvksFJO8q34T+F5QOQOywNW6T+YbP9RepEzFYntDXwsKkZ62VKi h6yoC06RFy8eLOI6NerTpDKV3nzW4D/l1YyhVPu2bOG2Ret05OMSTrwF5OZIHK8mdnYi awFWY5B7qkzJZGT013+ypS6Gxiv/9uEzxgip6Uuvglf5fyJaaunELdWH4I2T5/1dgzgC ySiS1/m08Gqq/nvnOAlhSuXpkA02w7leWa0+40NPQ5V47tUh5pkzjM3qVqvfRgE9KeBK 9ruA== X-Gm-Message-State: APjAAAU9AFQ6AsVnOnXZ/Vx+D84mLQq6+i1rwMhoC9o2lqF2fUE+9O7O GHGuMPnF58+Gat3rz5dYVTh5y+qzLSE= X-Received: by 2002:a17:902:1566:: with SMTP id b35mr113961401plh.147.1560824660939; Mon, 17 Jun 2019 19:24:20 -0700 (PDT) Received: from localhost ([2401:fa00:1:10:845f:e35d:e30c:4b47]) by smtp.gmail.com with ESMTPSA id y185sm13173222pfy.110.2019.06.17.19.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 19:24:20 -0700 (PDT) From: Yu-Hsuan Hsu To: linux-kernel@vger.kernel.org Cc: Jaroslav Kysela , Takashi Iwai , Jon Hunter , Yu-Hsuan Hsu , Pierre-Louis Bossart , alsa-devel@alsa-project.org, Liam Girdwood , Mark Brown , dgreid@chromium.org, cychiang@chromium.org Subject: [PATCH v6] ASoC: max98090: remove 24-bit format support if RJ is 0 Date: Tue, 18 Jun 2019 10:24:11 +0800 Message-Id: <20190618022411.208156-1-yuhsuan@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The supported formats are S16_LE and S24_LE now. However, S24_LE is not supported when TDM is 0 and it is not in the right justified mode. We should remove 24-bit format in that situation to avoid triggering error. Signed-off-by: Yu-Hsuan Hsu --- Changed the order of the conditional. Remove the snd_pcm_hw_constraint_msbits function. Use removing 24 bits format instead of fixing at 16 bits format. sound/soc/codecs/max98090.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index 7619ea31ab50..9fbb4c31bcf1 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -1909,6 +1909,24 @@ static int max98090_configure_dmic(struct max98090_priv *max98090, return 0; } +static int max98090_dai_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); + unsigned int fmt = max98090->dai_fmt; + + /* + * When TDM = 0, remove 24-bit format support if it is not in right + * justified mode. + */ + if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_RIGHT_J && + !max98090->tdm_slots) + substream->runtime->hw.formats &= ~SNDRV_PCM_FMTBIT_S24_LE; + + return 0; +} + static int max98090_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -2316,6 +2334,7 @@ EXPORT_SYMBOL_GPL(max98090_mic_detect); #define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE) static const struct snd_soc_dai_ops max98090_dai_ops = { + .startup = max98090_dai_startup, .set_sysclk = max98090_dai_set_sysclk, .set_fmt = max98090_dai_set_fmt, .set_tdm_slot = max98090_set_tdm_slot, -- 2.22.0.410.gd8fdbe21b5-goog