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: 161781 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp1465904jan; Thu, 4 Apr 2019 04:18:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT9idmYFET8b01OXzQ3KkW6fumyNckkmkyqdeJ3gNDN98oxpz8nKMgBSYkQ1OPYFBq4S3j X-Received: by 2002:aa7:80c8:: with SMTP id a8mr5197036pfn.193.1554376680123; Thu, 04 Apr 2019 04:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554376680; cv=none; d=google.com; s=arc-20160816; b=0AIz5iUINfdHEfz2FuKmuMNn4ZGl5u7noz2wFNE3Pv6ZmyGtVdAhcrvnV4PeqMre6b 75fao2NKaRhAVFpJry3EatViqX+I3jKpMKqD6WOC1ghy0HjLtL3af6EeFg5thX7viO21 kyexbGcfxJZjWog3N9dfMt62v/JmQTR/Usf33FPv248k7GqDjUB4SQ8Iw5jmaot9ZkB0 /Un0tZFC0uTvjVqi4p4NGiVUVpI107ps2/a4b4hWYwyYqleQHcPj2NxPMU4F/fWxmPtn yxVKyR2qekuQK4bRb6qolU1y5yGPNn619R/Jpo/3AktKVxgazMdy4eFA8jyD/3oMtoK+ d59w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=njYuZs0QQDpdwULWDM30jmxjNG8Fc5VRgpPkmqI8/tg=; b=GQEhPloG8d3yIemPJ3GZ3gYccvWFu1OiC7WPsL1fi8lt2RObFuz70rr3+Ew6Fg4o7Z A2RGkQLqzfOqLrPdyLdfqYqxfnxAYAd/5Bb66HtZ8MpZQRctPA8ywKPmKvMTie4NgwJ/ h9i8klunMmxjV9kTrpPa5mjUhzSlsu2R+u4vHKl0rvAN3qckeWlxxEQbDmz5tZYBiWZB EYUtxZ/eNUyHzjHD9uz+mT6YryRsCIEtdpUyRSZaINf5PmZk1+Xzxqj+iGjR4lPGk2Mf ew4c/Dj1qRMzTPe4zg8vmC5C9NFzuAWg+2xXu5DFZlIu8KE7HglaX48tDAVD17H/kKBu ALHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="0S+5YM/0"; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g59si16847286plb.281.2019.04.04.04.17.59; Thu, 04 Apr 2019 04:18:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b="0S+5YM/0"; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729687AbfDDLR4 (ORCPT + 7 others); Thu, 4 Apr 2019 07:17:56 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37718 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729641AbfDDLRy (ORCPT ); Thu, 4 Apr 2019 07:17:54 -0400 Received: by mail-wr1-f66.google.com with SMTP id w10so3290151wrm.4 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=EL96nUhkfQNEbech65qf7hWCeYa3S888v7Q6r2kOeVQNVtVuLHSvhnxJuZV25pE1Ag KCw0OfXbOkdncxAZuhTNZ6p4n0x6TbSTRkKX0Nw+FWJOfmbHtaG5OhNRsQG4V0xXhQ6G jYuvicWEtgyhmg/c1CWUTIQR7e0vryE+O2sXbvKctl+24Ul9Q2GeEdWiV9Qk9ES1BB4p pI80+PUixArAIpgBiw5KUIz302FqdK6HweyyEqkIw6rlX8MlJjaDev+VPqt+xCiNM1CB rsTGbfYnsyi1vzlfuJQz6ijSYKqqNHb7+WHr29dzoL/JlBHdVDz0FXXBqDqmexA5chQN Ogcg== X-Gm-Message-State: APjAAAVpP8R5xh/QQVUsgaUwV/S+mB9fERxj8PsjBx8KJ6NPagFxtdtn ay3AXW5luOPw5vPvKJfj6tcqFQ== 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 Cc: Jerome Brunet , Kevin Hilman , Maxime Jourdan , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 5/6] ASoC: meson: axg-tdm-formatter: rework quirks settings 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 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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(-) -- 2.20.1 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[] = {