From nobody Thu Oct 2 10:50:28 2025 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B466313540; Thu, 18 Sep 2025 15:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.17.235.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758210646; cv=none; b=TYnafLZheP+m/aU67C7ktO+ae3sr3+Qokbi3KRrw0+Fb/PCMoED/XxUYVWvcBh5rCAVRzWRHCww6yoEl4a564v7yPzSLVcodthRYSwbUmDKrLASX9acDXuRRHK9bfyDTgbAdmXlJUnkZ+p/dNLMxknY3kcAckK7pYOXtKz0rJsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758210646; c=relaxed/simple; bh=PhCdmcBJPdWMbFjoZdGBw3gyDb5r2JgdoYXKwih9mSw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VP+W8xMAZg4uGLwaOsWsH9PFGHaGANUVoHUmy1qA7Pz3vLKhFAhRZrMeLio7a5399N6o8tBNwwgW766Vfn+MzliP/BW5oMdIwEHQfQvbxhMCIdTaBk3dAn2942aYTMG4n3LajBOdsAJ20BWpuw7xazMiDwT7n+EXBoe4xpdI0zk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu; spf=pass smtp.mailfrom=csgroup.eu; arc=none smtp.client-ip=93.17.235.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub4.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4cSKSR28vLz9sg1; Thu, 18 Sep 2025 17:34:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Z7_lta6qXCna; Thu, 18 Sep 2025 17:34:31 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4cSKSR15xZz9sfv; Thu, 18 Sep 2025 17:34:31 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 15DCD8B767; Thu, 18 Sep 2025 17:34:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id dYGLOMvVr6vT; Thu, 18 Sep 2025 17:34:31 +0200 (CEST) Received: from PO20335.idsi0.si.c-s.fr (unknown [192.168.235.99]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 40FA78B775; Thu, 18 Sep 2025 17:34:30 +0200 (CEST) From: Christophe Leroy To: Herve Codina , Qiang Zhao , Shengjiu Wang , Xiubo Li , Fabio Estevam , Nicolin Chen , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: Christophe Leroy , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org Subject: [PATCH RESEND v3 2/4] ASoc: fsl: fsl_qmc_audio: Ensure audio channels are ordered in TDM bus Date: Thu, 18 Sep 2025 17:34:09 +0200 Message-ID: <4ff40afdf3d032b05dd4af6c0f777d4d4b445a76.1758209158.git.christophe.leroy@csgroup.eu> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1758209657; l=2268; i=christophe.leroy@csgroup.eu; s=20211009; h=from:subject:message-id; bh=PhCdmcBJPdWMbFjoZdGBw3gyDb5r2JgdoYXKwih9mSw=; b=ruBvohcdwTV13JzsoBOhlDufd3DsKpD4cOPOEYuGWSfm6Ozs7idM1/CNZLZUOMe9VBZP4mWZ2 thJrF3KAZaWDljbSlUr+XfoKg14q6ra/HyrJIPSjZZGr0vqZjORgflI X-Developer-Key: i=christophe.leroy@csgroup.eu; a=ed25519; pk=HIzTzUj91asvincQGOFx6+ZF5AoUuP9GdOtQChs7Mm0= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To reduce complexity of interrupt handling in following patch, ensure audio channels are configured in the same order as timeslots on the TDM bus. If we need a given ordering of audio sources in the audio frame, it is possible to re-order codecs on the TDM bus, no need to mix up timeslots in channels. Acked-by: Herve Codina Signed-off-by: Christophe Leroy --- sound/soc/fsl/fsl_qmc_audio.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sound/soc/fsl/fsl_qmc_audio.c b/sound/soc/fsl/fsl_qmc_audio.c index 5614a8b909ed..c0c7ef0a1511 100644 --- a/sound/soc/fsl/fsl_qmc_audio.c +++ b/sound/soc/fsl/fsl_qmc_audio.c @@ -791,12 +791,17 @@ static int qmc_audio_dai_parse(struct qmc_audio *qmc_= audio, struct device_node * struct qmc_dai *qmc_dai, struct snd_soc_dai_driver *qmc_soc_dai_driver) { + struct qmc_chan_ts_info ts_info; struct qmc_chan_info info; unsigned long rx_fs_rate; unsigned long tx_fs_rate; + int prev_last_rx_ts =3D 0; + int prev_last_tx_ts =3D 0; unsigned int nb_tx_ts; unsigned int nb_rx_ts; unsigned int i; + int last_rx_ts; + int last_tx_ts; int count; u32 val; int ret; @@ -879,6 +884,30 @@ static int qmc_audio_dai_parse(struct qmc_audio *qmc_a= udio, struct device_node * return -EINVAL; } } + + ret =3D qmc_chan_get_ts_info(qmc_dai->chans[i].qmc_chan, &ts_info); + if (ret) { + dev_err(qmc_audio->dev, "dai %d get QMC %d channel TS info failed %d\n", + qmc_dai->id, i, ret); + return ret; + } + + last_rx_ts =3D fls64(ts_info.rx_ts_mask); + last_tx_ts =3D fls64(ts_info.tx_ts_mask); + + if (prev_last_rx_ts > last_rx_ts) { + dev_err(qmc_audio->dev, "dai %d QMC chan %d unordered channels (RX time= slot %d before %d)\n", + qmc_dai->id, i, prev_last_rx_ts, last_rx_ts); + return -EINVAL; + } + if (prev_last_tx_ts > last_tx_ts) { + dev_err(qmc_audio->dev, "dai %d QMC chan %d unordered channels (TX time= slot %d before %d)\n", + qmc_dai->id, i, prev_last_tx_ts, last_tx_ts); + return -EINVAL; + } + + prev_last_rx_ts =3D last_rx_ts; + prev_last_tx_ts =3D last_tx_ts; } =20 qmc_dai->nb_chans_avail =3D count; --=20 2.49.0