From patchwork Thu Apr 4 11:17:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10885469 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 E5A4C139A for ; Thu, 4 Apr 2019 11:31:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB2FC208C2 for ; Thu, 4 Apr 2019 11:31:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD13328A3D; Thu, 4 Apr 2019 11:31:54 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 78D8628994 for ; Thu, 4 Apr 2019 11:31:53 +0000 (UTC) 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 20043161F; Thu, 4 Apr 2019 13:20:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 20043161F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1554376903; bh=zz2cCiDavF4Sxv4DaZgL6g3YzTyf7xKnYKSPXu6hAso=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=e+A/CsykBpE9JGZwgDoe2f/faQzpGdZWKW/RptY3MDjAwJpvsCKGRaNSDD9YJO1s/ R8pSk7+Wvg+CbwG9znZ11shdIxmd0llOR7qCk4Rw3jgdRMmhcLPL5tSUS1h8e3y56K ZzBotxaZyRoryWsX4s/onIUPNy2g16PUGDYqAXlo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7C4C4F8972C; Thu, 4 Apr 2019 13:18:04 +0200 (CEST) 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 BB703F8971E; Thu, 4 Apr 2019 13:17:57 +0200 (CEST) Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 24EE4F89718 for ; Thu, 4 Apr 2019 13:17:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 24EE4F89718 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="0S+5YM/0" Received: by mail-wr1-x442.google.com with SMTP id y7so3219015wrn.11 for ; Thu, 04 Apr 2019 04:17:53 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=njYuZs0QQDpdwULWDM30jmxjNG8Fc5VRgpPkmqI8/tg=; b=0S+5YM/0pFsWqe0GLi2cBiX4o0bic1u2T7zVWJIgG1n5M6BB03QtaDEjJWEm7Vx2pR EcgDxDSrSSVf01WXzWAKTcGRAXamlJM4gIyRYY5INah/m9lF9zXv+NRVlQTfvev/5SEq Uu1zh2W9FXWMMAw2PDw1+qqkvMYxa14qEaj9oBtz23mNSCvOTRlbj1EtA879jt/isfwu TGpStKvevelZrysBcRYnvKBrcnw5B0w2PBv4xU0EmVsNGFBB+PmH2hGgXZl5X47PmZ8Z FT5fEpEXpu5GBk9s8d27wX1e6D0oFDsjKmUB85i36ZxkMRGpcPMuHBcqS/Wz1bBP9qH9 G/CA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=njYuZs0QQDpdwULWDM30jmxjNG8Fc5VRgpPkmqI8/tg=; b=fzOqkrQ4MiNr6VDB56y03nP8yILq11bv/c6eWIoxgA+5hbltvr+yOIpsIjRdleVtVn rNpnFNfb6pudF2ak2/MPGymKGt3kxSszjAq3roNXrKOSWWLCrXnHfrwHViMP8xBCEV+0 TPHcvvBrtFAS48B+t0gJ3zMQvXt9FMa7MLauNHKmqZWLf0/XrCTCtbkCGqtWiBoRsJSU GIFvYrjby754IAkMmD+1evUudmaclLuyPABKgULhxeXz+6HbYZ0qiChQVt1HLV2I57mK xaaXrnloEEOY3hVtixr3VglzJUPTPUeIZjFQ6hT9Jvpil1lPX5abKBfQtBljy1GE0T5i 7Krg== X-Gm-Message-State: APjAAAXmZLoxDcdDgJOsYB6DKQcTvRQKgmve95CNKa+RxpTlB3in+DQV h08pjWgPsL9CT4EPCD6hoZTs/g== X-Google-Smtp-Source: APXvYqzkiOI57ShWfPqvIEVkCyjm17C0ol6GaeDdt2KXAeDHcBYfsedCbIv2iTgknoTePhi47ecm2w== X-Received: by 2002:adf:f7c2:: with SMTP id a2mr1681722wrq.242.1554376672697; Thu, 04 Apr 2019 04:17:52 -0700 (PDT) Received: from boomer.local ([2a01:e34:eeb6:4690:106b:bae3:31ed:7561]) by smtp.googlemail.com with ESMTPSA id z23sm9024771wma.0.2019.04.04.04.17.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2019 04:17:51 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Date: Thu, 4 Apr 2019 13:17:32 +0200 Message-Id: <20190404111733.28705-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190404111733.28705-1-jbrunet@baylibre.com> References: <20190404111733.28705-1-jbrunet@baylibre.com> MIME-Version: 1.0 Cc: Maxime Jourdan , devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Kevin Hilman , linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, Jerome Brunet Subject: [alsa-devel] [PATCH 5/6] ASoC: meson: axg-tdm-formatter: rework quirks settings 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" X-Virus-Scanned: ClamAV using ClamSMTP The g12a tdmout requires a different signal skew offset than the axg. With this change, the skew offset is added as a parameter of the tdm formatters to prepare the addition of the g12a support. Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-tdm-formatter.c | 6 ++++-- sound/soc/meson/axg-tdm-formatter.h | 11 +++++++++-- sound/soc/meson/axg-tdmin.c | 16 +++++++++++----- sound/soc/meson/axg-tdmout.c | 16 +++++++++++----- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/sound/soc/meson/axg-tdm-formatter.c b/sound/soc/meson/axg-tdm-formatter.c index 43e390f9358a..0c6cce5c5773 100644 --- a/sound/soc/meson/axg-tdm-formatter.c +++ b/sound/soc/meson/axg-tdm-formatter.c @@ -68,7 +68,7 @@ EXPORT_SYMBOL_GPL(axg_tdm_formatter_set_channel_masks); static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter) { struct axg_tdm_stream *ts = formatter->stream; - bool invert = formatter->drv->invert_sclk; + bool invert = formatter->drv->quirks->invert_sclk; int ret; /* Do nothing if the formatter is already enabled */ @@ -85,7 +85,9 @@ static int axg_tdm_formatter_enable(struct axg_tdm_formatter *formatter) return ret; /* Setup the stream parameter in the formatter */ - ret = formatter->drv->ops->prepare(formatter->map, formatter->stream); + ret = formatter->drv->ops->prepare(formatter->map, + formatter->drv->quirks, + formatter->stream); if (ret) return ret; diff --git a/sound/soc/meson/axg-tdm-formatter.h b/sound/soc/meson/axg-tdm-formatter.h index cf947caf3cb1..9ef98e955cb2 100644 --- a/sound/soc/meson/axg-tdm-formatter.h +++ b/sound/soc/meson/axg-tdm-formatter.h @@ -14,18 +14,25 @@ struct regmap; struct snd_soc_dapm_widget; struct snd_kcontrol; +struct axg_tdm_formatter_hw { + unsigned int skew_offset; + bool invert_sclk; +}; + struct axg_tdm_formatter_ops { struct axg_tdm_stream *(*get_stream)(struct snd_soc_dapm_widget *w); void (*enable)(struct regmap *map); void (*disable)(struct regmap *map); - int (*prepare)(struct regmap *map, struct axg_tdm_stream *ts); + int (*prepare)(struct regmap *map, + const struct axg_tdm_formatter_hw *quirks, + struct axg_tdm_stream *ts); }; struct axg_tdm_formatter_driver { const struct snd_soc_component_driver *component_drv; const struct regmap_config *regmap_cfg; const struct axg_tdm_formatter_ops *ops; - bool invert_sclk; + const struct axg_tdm_formatter_hw *quirks; }; int axg_tdm_formatter_set_channel_masks(struct regmap *map, diff --git a/sound/soc/meson/axg-tdmin.c b/sound/soc/meson/axg-tdmin.c index bbac44c81688..a790f925a4ef 100644 --- a/sound/soc/meson/axg-tdmin.c +++ b/sound/soc/meson/axg-tdmin.c @@ -107,21 +107,22 @@ static void axg_tdmin_disable(struct regmap *map) regmap_update_bits(map, TDMIN_CTRL, TDMIN_CTRL_ENABLE, 0); } -static int axg_tdmin_prepare(struct regmap *map, struct axg_tdm_stream *ts) +static int axg_tdmin_prepare(struct regmap *map, + const struct axg_tdm_formatter_hw *quirks, + struct axg_tdm_stream *ts) { - unsigned int val = 0; + unsigned int val, skew = quirks->skew_offset; /* Set stream skew */ switch (ts->iface->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_DSP_A: - val |= TDMIN_CTRL_IN_BIT_SKEW(3); + skew += 1; break; case SND_SOC_DAIFMT_LEFT_J: case SND_SOC_DAIFMT_RIGHT_J: case SND_SOC_DAIFMT_DSP_B: - val = TDMIN_CTRL_IN_BIT_SKEW(2); break; default: @@ -130,6 +131,8 @@ static int axg_tdmin_prepare(struct regmap *map, struct axg_tdm_stream *ts) return -EINVAL; } + val = TDMIN_CTRL_IN_BIT_SKEW(skew); + /* Set stream format mode */ switch (ts->iface->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -204,7 +207,10 @@ static const struct axg_tdm_formatter_driver axg_tdmin_drv = { .component_drv = &axg_tdmin_component_drv, .regmap_cfg = &axg_tdmin_regmap_cfg, .ops = &axg_tdmin_ops, - .invert_sclk = false, + .quirks = &(const struct axg_tdm_formatter_hw) { + .invert_sclk = false, + .skew_offset = 2, + }, }; static const struct of_device_id axg_tdmin_of_match[] = { diff --git a/sound/soc/meson/axg-tdmout.c b/sound/soc/meson/axg-tdmout.c index f73368ee1088..3984818e2a7c 100644 --- a/sound/soc/meson/axg-tdmout.c +++ b/sound/soc/meson/axg-tdmout.c @@ -124,21 +124,22 @@ static void axg_tdmout_disable(struct regmap *map) regmap_update_bits(map, TDMOUT_CTRL0, TDMOUT_CTRL0_ENABLE, 0); } -static int axg_tdmout_prepare(struct regmap *map, struct axg_tdm_stream *ts) +static int axg_tdmout_prepare(struct regmap *map, + const struct axg_tdm_formatter_hw *quirks, + struct axg_tdm_stream *ts) { - unsigned int val = 0; + unsigned int val, skew = quirks->skew_offset; /* Set the stream skew */ switch (ts->iface->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: case SND_SOC_DAIFMT_DSP_A: - val |= TDMOUT_CTRL0_INIT_BITNUM(1); break; case SND_SOC_DAIFMT_LEFT_J: case SND_SOC_DAIFMT_RIGHT_J: case SND_SOC_DAIFMT_DSP_B: - val |= TDMOUT_CTRL0_INIT_BITNUM(2); + skew += 1; break; default: @@ -147,6 +148,8 @@ static int axg_tdmout_prepare(struct regmap *map, struct axg_tdm_stream *ts) return -EINVAL; } + val = TDMOUT_CTRL0_INIT_BITNUM(skew); + /* Set the slot width */ val |= TDMOUT_CTRL0_BITNUM(ts->iface->slot_width - 1); @@ -234,7 +237,10 @@ static const struct axg_tdm_formatter_driver axg_tdmout_drv = { .component_drv = &axg_tdmout_component_drv, .regmap_cfg = &axg_tdmout_regmap_cfg, .ops = &axg_tdmout_ops, - .invert_sclk = true, + .quirks = &(const struct axg_tdm_formatter_hw) { + .invert_sclk = true, + .skew_offset = 1, + }, }; static const struct of_device_id axg_tdmout_of_match[] = {