Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1273483pxa; Fri, 28 Aug 2020 08:18:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKyA9nBEe+AEhftCsjR9ivNfoajYM6MyIID+ICIG1cbN8hY7a9DoV5+pk0nu3a9U/gpCdB X-Received: by 2002:a50:fe0a:: with SMTP id f10mr2320946edt.264.1598627900346; Fri, 28 Aug 2020 08:18:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598627900; cv=none; d=google.com; s=arc-20160816; b=qZZIEg6HSPSo1IzEiZXgl76XR0fCCcxwF5Xwsuq4Oy9Nk8MQAYpv72tvE5XwtyM7do /lxXXJWj2cGaT10fG862bvC0qQUjF+RHutkD0ePpGe4Vzcfj3GFJ+VcIEDu4+U9eDyNF pb923bnk94EzxkOBDad+vNd8duYd+k1WObIhkpAVols68yroBEdYsYsNcb6DirPBa8Sw 4ziPx8bQXSZ5XLcTzW7hPMFzSIpTlNgpha5M0zB6ZbWZWJSHcq1PnEIedl7OlemDiL10 hSbmfAJoPnoPPs4h5kJBRnOTFODDf6boQ5MhTP6LiIxLX78iVCXwdMHfDA+1lpnawut3 tauA== 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=6XO7ADdhJqpOQN7r6IzL9NHcOCfqqL0xalqP8Zr9AVw=; b=R7EOkNpyRlcNwayj1rKkc0sR55buPswEY3JGZOp9x+yGEbHMdXe7cGl8wjBjLlFSHJ 41VlzsLkCFVdLEe54X+dU/kYXuWP07ekxR2qV8bTo3fqy44xVzzt0wPi9XJnXeu5x9ER F44D3+1ze3+nz0nV5iQA+flU+SX3cKW0DVEyIjsT5Um+bWh5bF7WN8ekVH2+oKkf3DqF qsQh5o8i/TdsLmLNzDA/6LBSMgAKmeIj7qmsP8sTvg+KEb2RTt/y0UGySSwXQNwZ9u1X msLYyErHnAEyZ/6Rq2TkcZetUG5zAOG5UwQDA6lmwohF2lRju08XLwSxoeVlhrIJSKOO 1EVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=F8plumSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g3si877694ejj.248.2020.08.28.08.17.55; Fri, 28 Aug 2020 08:18:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=F8plumSa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727993AbgH1POz (ORCPT + 99 others); Fri, 28 Aug 2020 11:14:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbgH1POw (ORCPT ); Fri, 28 Aug 2020 11:14:52 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2F15C061264 for ; Fri, 28 Aug 2020 08:14:51 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id a65so1250472wme.5 for ; Fri, 28 Aug 2020 08:14:51 -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:mime-version :content-transfer-encoding; bh=6XO7ADdhJqpOQN7r6IzL9NHcOCfqqL0xalqP8Zr9AVw=; b=F8plumSakJirsH7lNu+Hn/G7X19AHjzTM5ONVDRwW97YDaWp3eg5szWB9CGtJhU1Vl xDFBvsnLlFHfbRlyNJtUC4tBi4s/mV1k4Rb02oFIBor+rPQeL/cg6t4Cew5Gn5mWJpIE Vt9KWC3iVYvkuyvrFRynD11z7LAMVPS+NI9tnBG14HFtnOHW6LVuCYnX33VWdWOsXr5e qFu28wlsnB7Y9L5unZLg6f+471jLdM9fe5jHwFkhnxxvaPAzYGZRjDgNUWQ6qtm+iBJt x/eqVD/jlV7ybQwhqzNXBTd6BUWYCR8zG7Co5wjqsfBCECYSt9kbIJ4zzWAjtCSaqkcb kGMQ== 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=6XO7ADdhJqpOQN7r6IzL9NHcOCfqqL0xalqP8Zr9AVw=; b=fPTNgOzn99g8lcRhFS1c7hwJohen1uMMdlPXlCQ72Y490sexLg6yggOy1mVN260E2j X9lgS1ng0tgv3dMT4LChAlFKeh0aWt8wnHMf1u7RZZxI+aNp4P7hJVe7TXeMjF1vw5OE 8MSnA955n+J+3Z0Sd9vIf8Om87flbuLASq69xaHWstQf44iaWHqEAzacYC3G1YAZz4t1 lokvadyFOvAADqr9e5pbcXzW40zWVbEqtafoKZ42pNCnNxL4Pt4nN9akj5u/A53OPkg8 WWvBYALe3frzALFQ1imCR0xTjJ8GVZIQ3anMNVKRvYHSsS8ho0lNEgN7oXDjlXO73MrF wBZA== X-Gm-Message-State: AOAM532eyrGfOhnDEGoDd/LPdIfPfyGgE5OGDzSLhYIwzJ0GuTXpzNPM SVzFux27CDYxQNV7FWu9Y4Vrvw== X-Received: by 2002:a1c:7215:: with SMTP id n21mr2039022wmc.156.1598627690389; Fri, 28 Aug 2020 08:14:50 -0700 (PDT) Received: from starbuck.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id b8sm2877677wmh.48.2020.08.28.08.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2020 08:14:49 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood Cc: Jerome Brunet , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, Kevin Hilman , Nicolas Belin Subject: [PATCH] ASoC: meson: axg-toddr: fix channel order on g12 platforms Date: Fri, 28 Aug 2020 17:14:38 +0200 Message-Id: <20200828151438.350974-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On g12 and following platforms, The first channel of record with more than 2 channels ends being placed randomly on an even channel of the output. On these SoCs, a bit was added to force the first channel to be placed at the beginning of the output. Apparently the behavior if the bit is not set is not easily predictable. According to the documentation, this bit is not present on the axg series. Set the bit on g12 and fix the problem. Fixes: a3c23a8ad4dc ("ASoC: meson: axg-toddr: add g12a support") Reported-by: Nicolas Belin Signed-off-by: Jerome Brunet --- sound/soc/meson/axg-toddr.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sound/soc/meson/axg-toddr.c b/sound/soc/meson/axg-toddr.c index e711abcf8c12..d6adf7edea41 100644 --- a/sound/soc/meson/axg-toddr.c +++ b/sound/soc/meson/axg-toddr.c @@ -18,6 +18,7 @@ #define CTRL0_TODDR_SEL_RESAMPLE BIT(30) #define CTRL0_TODDR_EXT_SIGNED BIT(29) #define CTRL0_TODDR_PP_MODE BIT(28) +#define CTRL0_TODDR_SYNC_CH BIT(27) #define CTRL0_TODDR_TYPE_MASK GENMASK(15, 13) #define CTRL0_TODDR_TYPE(x) ((x) << 13) #define CTRL0_TODDR_MSB_POS_MASK GENMASK(12, 8) @@ -189,10 +190,31 @@ static const struct axg_fifo_match_data axg_toddr_match_data = { .dai_drv = &axg_toddr_dai_drv }; +static int g12a_toddr_dai_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct axg_fifo *fifo = snd_soc_dai_get_drvdata(dai); + int ret; + + ret = axg_toddr_dai_startup(substream, dai); + if (ret) + return ret; + + /* + * Make sure the first channel ends up in the at beginning of the output + * As weird as it looks, without this the first channel may be misplaced + * in memory, with a random shift of 2 channels. + */ + regmap_update_bits(fifo->map, FIFO_CTRL0, CTRL0_TODDR_SYNC_CH, + CTRL0_TODDR_SYNC_CH); + + return 0; +} + static const struct snd_soc_dai_ops g12a_toddr_ops = { .prepare = g12a_toddr_dai_prepare, .hw_params = axg_toddr_dai_hw_params, - .startup = axg_toddr_dai_startup, + .startup = g12a_toddr_dai_startup, .shutdown = axg_toddr_dai_shutdown, }; -- 2.25.4