From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=31.217.193.162 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796160139; b=SdAQj3o1QkwYUzzVgJ/lVAtvZCx/ceE/9bT3K1tF+rKXOwjnLTz6ORJr+8qDwP35qbYv +RvmNxeTMO3VRILgaZSv/4NZA2dlo0qoB6lk3zzltyxrcgM4RCiylf2U3HraeqiCEDjz3 AHN8f6HTVySkQHA46sqs10C5lsGQKp10eJ4wJZ7w7eDns4H1iIQorgWO/jaYtURLeEkgI 5+1X/5pkgFoS/azszkYjg5C0PgQ2Yg+0lMIvYIwbpHUGKboFxC7XcUcPin5ZArQ6T1Sw8 2mn6HXbyQIY6esVS7iTZEZ/5DePDbZv/rtfT0AcvHqH2UHsUba3Pk1YiQIT0mq8kTZg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796160139; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:Date:MIME-Version: User-Agent:Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding: X-Hostingpalvelu-MailScanner-Information: X-Hostingpalvelu-MailScanner-ID:X-Hostingpalvelu-MailScanner: X-Hostingpalvelu-MailScanner-SpamCheck: X-Hostingpalvelu-MailScanner-From:X-Spam-Status:X-Spam-Flag: X-AntiAbuse; bh=l28pBYor53J47ov14kftc7UnepsWlMHm+Kf9Oookn/Q=; b=TfqXnzb+Qwd8TnSawxP1Mp5OM6CfTBAtEbc2AZRzhxfYdJIiC3kUKAyc90luwZ5srjFG LoKbk/nDeoFYSiSGiIjTAqPccMgBhYLHPxuFoQnMbPZjaf2s0lLa5Ne7BF6foz1Q0iy+G Pao3T5kodrC9yrrovhPmdsSeJRvXUwDLaJ0zVs0nyqvhojB6MSnnkGSUA4cCD5NPr4Ikw rjvwXVJmUsgDmqpaoOaFSzGgWPng/TcTT+iNDbS8elZYZUZ+TWufz3XPNqo5X8XIH+3Rk QqxtgtpOFi9XV6zUswGJdnmR0+ZKssIh/qq9qrV1fTtDwKk24zRW5XE++5BFkMXEqHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bitmer.com; spf=pass smtp.mailfrom=bitmer.com; dkim=pass header.d=bitmer.com header.i=@bitmer.com header.a=rsa-sha256 header.s=default header.b=TDe1xI9p; arc=none smtp.remote-ip=31.217.193.162 Received: from wp23.hostingpalvelu.fi (wp23.hostingpalvelu.fi [31.217.193.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 453C8606A680 for ; Tue, 1 Dec 2026 21:22:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 453C8606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bitmer.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bitmer.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=bitmer.com header.i=@bitmer.com header.a=rsa-sha256 header.s=default header.b=TDe1xI9p DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bitmer.com; s=default; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=l28pBYor53J47ov14kftc7UnepsWlMHm+Kf9Oookn/Q=; b=TDe1xI9pJhq0BbeeBCSWWNx7iV 7gCO2lJmo9JO3bf8aPeddh/DqGsx9mI4RJQw2y8QIVOWLPFh2w8b/Bglc5r2FTxiJ+F+p8RY7p40G In9HE8aOmnAWXBtpBfXLaDxPR79pIseZSIuUtOWY2UxOa/4Fa9MbJCHITvaOv09pg06n1w/GQuo7r JD8HNOTWDq/XnI1YDNWuqhl7jBvUGlswAWwEsm99LFV9Iizz2N+7X8CDuWVLJ79AH0oITRyqKg84N CnGFNCja8aGn0NZeFcCxM/YNivZHd2VPeqB+6CfDbRlxigHv3KqryNn5m3BSQVrYM83/Jx8MOQJD0 zd8sR5kg==; Received: from 91-153-158-177.elisa-laajakaista.fi ([91.153.158.177]:39754 helo=[192.168.0.14]) by wp23.hostingpalvelu.fi with esmtpsa (TLS1.3) tls TLS_AES_128_GCM_SHA256 (Exim 4.97.1) (envelope-from ) id 1xYVIX-0000000DJ0s-0Nvo; Tue, 01 Dec 2026 22:22:01 +0100 Message-ID: Date: Tue, 1 Dec 2026 23:22:00 +0200 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] ASoC: ti: omap-mcbsp: Implement set_tdm_slot To: Joseph Telaak , Sen Wang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Cc: linux-sound@vger.kernel.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261130-omap-mcbsp-tdm-slot-v3-0-f2ab4752fb03@telaak.dev> <20261130-omap-mcbsp-tdm-slot-v3-2-f2ab4752fb03@telaak.dev> Content-Language: en-US From: Jarkko Nikula In-Reply-To: <20261130-omap-mcbsp-tdm-slot-v3-2-f2ab4752fb03@telaak.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Hostingpalvelu-MailScanner-Information: Please contact the ISP for more information X-Hostingpalvelu-MailScanner-ID: 1xYVIX-0000000DJ0s-0Nvo X-Hostingpalvelu-MailScanner: Found to be clean X-Hostingpalvelu-MailScanner-SpamCheck: not spam, SpamAssassin (score=0.711, required 5, ALL_TRUSTED -1.00, KAM_DMARC_QUARANTINE 1.50, KAM_DMARC_STATUS 0.01, KAM_MANYTO 0.20, TVD_RCVD_IP 0.00) X-Hostingpalvelu-MailScanner-From: jarkko.nikula@bitmer.com X-Spam-Flag: NO X-AntiAbuse: Primary Hostname - wp23.hostingpalvelu.fi ; Original Domain - vger.kernel.org ; Sender Address Domain - bitmer.com Hi On 12/1/26 2:01 AM, Joseph Telaak wrote: > As bit clock and frame provider, McBSP sizes the frame from the SRG > input, the set_clkdiv() divider and the rate. Only a machine driver can > call set_clkdiv(), so with simple-audio-card or audio-graph-card the > divider stays 1 and the bit clock runs at the full SRG input: 96 MHz on > OMAP3, a 2000-bit frame at 48 kHz. > > Implement set_tdm_slot() so these cards can ask for a frame of slots x > slot_width bit clocks with dai-tdm-slot-num and dai-tdm-slot-width. > hw_params() then picks the divider for the rate. McBSP sends a frame's > words back to back, so a sample must fill its slot and the channels fill > the active slots, which must be the low ones. Both directions share the > frame, so non-empty TX and RX masks need the same number of slots, and > I2S or left-justified need two slots. Slots McBSP can't do are refused > when they are set, and a slot count I2S can't use at open. As clock > consumer, the slots are checked but have no effect. > > startup() pins the channels and sample width to the slots. If the sysclk > was set outside a stream, as simple-audio-card does at init, it also > limits the rates to those the sysclk divides to within 0.1%, the IEC > 60958 level II clock tolerance. hw_params() checks the stream against > the slots and the sysclk, including one a card sets in hw_params(). With > the SRG on CLKS, the fclk mux on OMAP2 and later, the sysclk must be > that clock's rate: McBSP has no MCLK output, so simple-card's mclk-fs, > which passes rate x fs, is refused instead of giving a wrong bit clock. > This is checked in hw_params(), not in set_dai_sysclk(): > simple-audio-card sets the sysclk before the format and the slots. > > Both directions share the sample rate generator: once a stream is > configured, until its hw_free(), the other direction must use the same > rate and the sysclk can't change, not even for that stream's next > hw_params(). Otherwise a stream on its own reprograms McBSP on each > hw_params(). The slots can't change while McBSP is configured. This > applies only when McBSP provides both clocks from the SRG, which is why > the core's symmetric_rate isn't used: as clock consumer, the directions > can run at different rates. Without slots nothing changes. > > Tested on an OMAP3630 board whose McBSP4 drives the I2S input of an > ADV7513 with no MCLK, with 2 x 32-bit slots and adv7511 taking S32_LE: a > left-only and a right-only 44.1 kHz tone each play on their own side (96 > MHz / 34 gives 44117.6 Hz). 48 kHz (0.8% off), S16_LE and mono are > refused, and plughw converts them. With simple-audio-card,mclk-fs set to > 256, hw_params() refuses the 11.2896 and 12.288 MHz sysclks. > > Signed-off-by: Joseph Telaak > --- > sound/soc/ti/omap-mcbsp-priv.h | 10 ++ > sound/soc/ti/omap-mcbsp.c | 348 ++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 354 insertions(+), 4 deletions(-) > > diff --git a/sound/soc/ti/omap-mcbsp-priv.h b/sound/soc/ti/omap-mcbsp-priv.h > index 324c5d7d431d..621bb4d17879 100644 > --- a/sound/soc/ti/omap-mcbsp-priv.h > +++ b/sound/soc/ti/omap-mcbsp-priv.h > @@ -275,6 +275,16 @@ struct omap_mcbsp { > unsigned int latency[2]; > int clk_div; > int wlen; > + unsigned int slots; > + unsigned int slot_width; > + unsigned int tx_slots; > + unsigned int rx_slots; > + /* Rate the slots were configured for */ > + unsigned int slot_rate; > + /* Directions configured with slots, BIT(stream) */ > + unsigned int slot_streams; > + /* in_freq was set outside a stream */ > + bool sysclk_static; > > struct pm_qos_request pm_qos_req; > }; > diff --git a/sound/soc/ti/omap-mcbsp.c b/sound/soc/ti/omap-mcbsp.c > index 6e0c7d7359f4..3e74a367dd76 100644 > --- a/sound/soc/ti/omap-mcbsp.c > +++ b/sound/soc/ti/omap-mcbsp.c ... > +/* > + * The sysclk the SRG divides, or 0 if it isn't usable. From CLKS, the fclk > + * mux on OMAP2+, it must be that clock's rate: McBSP has no MCLK output, and > + * simple-card's mclk-fs passes rate x fs. Other SRG inputs are taken as set. > + */ > +static unsigned int omap_mcbsp_slot_sysclk(struct omap_mcbsp *mcbsp) > +{ > + struct omap_mcbsp_reg_cfg *regs = &mcbsp->cfg_regs; > + unsigned long fclk = clk_get_rate(mcbsp->fclk); > + > + if (!mcbsp_omap1() && !(regs->srgr2 & CLKSM) && > + !(regs->pcr0 & SCLKME) && fclk && mcbsp->in_freq != fclk) > + return 0; > + > + return mcbsp->in_freq; > +} I think more cleaner would be to store clk_id in omap_mcbsp_dai_set_dai_sysclk() as omap1 is already validated there and no need to check these register bits here. > + > +/* > + * Slots only apply when McBSP provides the bit clock and the frame, and > + * drives both bit clock pins from the SRG > + */ > +static bool omap_mcbsp_slots_on(struct omap_mcbsp *mcbsp) > +{ > + return mcbsp->slot_width && > + (mcbsp->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) == > + SND_SOC_DAIFMT_BP_FP && > + (mcbsp->cfg_regs.pcr0 & (CLKXM | CLKRM)) == (CLKXM | CLKRM); > +} Is CLKXM | CLKRM test needed? Those should be set when the mcbsp->fmt has SND_SOC_DAIFMT_BP_FP?