Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Olivier Louvignes <olivier@mgcrea.io>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	David Rhodes <david.rhodes@cirrus.com>,
	Richard Fitzgerald <rf@opensource.cirrus.com>,
	linux-sound@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH RFC v2] ASoC: cs43130: Take the frame layout from set_tdm_slot()
Date: Mon, 26 Oct 2026 14:43:43 +0000	[thread overview]
Message-ID: <at9nH2PSFlLpuqNu@opensource.cirrus.com> (raw)
In-Reply-To: <20261023163206.81891-1-olivier@mgcrea.io>

On Fri, Oct 23, 2026 at 06:32:06PM +0200, Olivier Louvignes wrote:
> hw_params() derives the slot width from the frequency given to the DAI's
> set_sysclk(), which it takes for SCLK. Generic cards pass MCLK there: the
> simple-audio-card of a HiBy R1 (Ingenic X1600 as I2S master, 64 bit
> clocks per frame, mclk-fs = 512) hands over 22.5792 MHz, so the driver
> sets up 256-bit slots for a 44.1 kHz stream and the CS43131 plays white
> noise. The card cannot simply leave mclk-fs out: simple-audio-card then
> sets no clock on the I2S controller either, and the codec, as clock
> slave, fails hw_params() with "SCLK freq is not set".
> 
> Add a set_tdm_slot() callback so the card can give the layout instead.
> The two channels go to the first and second slots set in tx_mask, within
> frames of 16 to 64 bits, the sizes the serial port clock tables cover.
> When set, the layout takes precedence over the one derived from
> set_sysclk(); zero slots go back to deriving it.
> 
> Tested on a HiBy R1, on v7.3, with dai-tdm-slot-num = <2> and
> dai-tdm-slot-width = <32> on the codec node.
> 
> Signed-off-by: Olivier Louvignes <olivier@mgcrea.io>
> ---
> +static int cs43130_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
> +				unsigned int rx_mask, int slots, int slot_width)
> +{
> +	struct snd_soc_component *component = dai->component;
> +	struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component);
> +	struct cs43130_dai *cs_dai = &cs43130->dais[dai->id];
> +	unsigned int frm_size = slots * slot_width;
> +
> +	if (!slots) {
> +		cs_dai->slots = 0;
> +		cs_dai->slot_width = 0;
> +		return 0;
> +	}
> +	if (slots < 0 || slot_width < 16 || slot_width > 32 ||
> +	    frm_size > 64 || frm_size % 16)
> +		return -EINVAL;
> +	if (!tx_mask || hweight32(tx_mask) > 2 || tx_mask >= BIT(slots))
> +		return -EINVAL;

Should we not be using rx_mask here? I think set_tdm is usually
centric to the device.

Otherwise, I think this looks good to me.

Thanks,
Charles

      reply	other threads:[~2026-10-26 14:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 16:32 [PATCH RFC v2] ASoC: cs43130: Take the frame layout from set_tdm_slot() Olivier Louvignes
2026-10-26 14:43 ` Charles Keepax [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=at9nH2PSFlLpuqNu@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=david.rhodes@cirrus.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=olivier@mgcrea.io \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox