mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Charles Keepax <ckeepax@opensource.cirrus.com>, broonie@kernel.org
Cc: lgirdwood@gmail.com, yung-chuan.liao@linux.intel.com,
	pierre-louis.bossart@linux.dev, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, patches@opensource.cirrus.com
Subject: Re: [PATCH] ASoC: SDCA: Combine width_find_mask() and get_word_mask()
Date: Mon, 23 Nov 2026 17:42:33 +0000	[thread overview]
Message-ID: <90f6a16a-2d50-4453-bb3e-b4c60f4d2d82@oss.qualcomm.com> (raw)
In-Reply-To: <20261123115205.3498244-1-ckeepax@opensource.cirrus.com>

On 11/23/26 11:52 AM, Charles Keepax wrote:
> Both of these functions take a bit width and return the ALSA mask
> bits for that width. Remove get_word_mask() and use width_find_mask()
> in all cases.
> 
> As part of this the function is expanded with a few additional
> formats. The big endian versions are added to the mask, for
> the original dai driver users of width_find_mask() these would
> be added by the ASoC core, however that isn't true when used for
> ALSA constraint users of get_word_mask(). The 3LE versions are also
> added as the memory size shouldn't be a factor once on the SoundWire
> bus. Finally, support for the unsigned formats is removed relative
> to get_word_mask(), these are not commonly used and the SoundWire
> specification has no obvious mechanism to indicate if they are
> supported. So better these are only added once a user comes forward.
> 
> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
> ---
Tested on Snapdragon T14s Gen7.

Tested-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>

--srini

>  sound/soc/sdca/sdca_asoc.c | 56 ++++++++++++--------------------------
>  1 file changed, 18 insertions(+), 38 deletions(-)
> 
> diff --git a/sound/soc/sdca/sdca_asoc.c b/sound/soc/sdca/sdca_asoc.c
> index aaa84156f20a8..d58be660ced7f 100644
> --- a/sound/soc/sdca/sdca_asoc.c
> +++ b/sound/soc/sdca/sdca_asoc.c
> @@ -1214,19 +1214,28 @@ static u64 width_find_mask(unsigned int bits)
>  {
>  	switch (bits) {
>  	case 0:
> -		return SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |
> -		       SNDRV_PCM_FMTBIT_S20_LE | SNDRV_PCM_FMTBIT_S24_LE |
> -		       SNDRV_PCM_FMTBIT_S32_LE;
> +		return SNDRV_PCM_FMTBIT_S8 |
> +		       SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
> +		       SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE |
> +		       SNDRV_PCM_FMTBIT_S20_LE | SNDRV_PCM_FMTBIT_S20_BE |
> +		       SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE |
> +		       SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |
> +		       SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE |
> +		       SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE;
>  	case 8:
>  		return SNDRV_PCM_FMTBIT_S8;
>  	case 16:
> -		return SNDRV_PCM_FMTBIT_S16_LE;
> +		return SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE;
> +	case 18:
> +		return SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_S18_3BE;
>  	case 20:
> -		return SNDRV_PCM_FMTBIT_S20_LE;
> +		return SNDRV_PCM_FMTBIT_S20_LE | SNDRV_PCM_FMTBIT_S20_BE |
> +		       SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE;
>  	case 24:
> -		return SNDRV_PCM_FMTBIT_S24_LE;
> +		return SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |
> +		       SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE;
>  	case 32:
> -		return SNDRV_PCM_FMTBIT_S32_LE;
> +		return SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE;
>  	default:
>  		return 0;
>  	}
> @@ -1510,35 +1519,6 @@ static int get_cluster_mask(struct device *dev, struct sdca_function_data *funct
>  	return 0;
>  }
>  
> -static u64 get_word_mask(unsigned int width)
> -{
> -	switch (width) {
> -	case 8:
> -		return SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_U8;
> -	case 16:
> -		return SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
> -		       SNDRV_PCM_FMTBIT_U16_LE | SNDRV_PCM_FMTBIT_U16_BE;
> -	case 18:
> -		return SNDRV_PCM_FMTBIT_S18_3LE | SNDRV_PCM_FMTBIT_U18_3LE |
> -		       SNDRV_PCM_FMTBIT_S18_3BE | SNDRV_PCM_FMTBIT_U18_3BE;
> -	case 20:
> -		return SNDRV_PCM_FMTBIT_S20_LE | SNDRV_PCM_FMTBIT_U20_LE |
> -		       SNDRV_PCM_FMTBIT_S20_BE | SNDRV_PCM_FMTBIT_U20_BE |
> -		       SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_U20_3LE |
> -		       SNDRV_PCM_FMTBIT_S20_3BE | SNDRV_PCM_FMTBIT_U20_3BE;
> -	case 24:
> -		return SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |
> -		       SNDRV_PCM_FMTBIT_U24_LE | SNDRV_PCM_FMTBIT_U24_BE |
> -		       SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_U24_3LE |
> -		       SNDRV_PCM_FMTBIT_S24_3BE | SNDRV_PCM_FMTBIT_U24_3BE;
> -	case 32:
> -		return SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |
> -		       SNDRV_PCM_FMTBIT_U32_LE | SNDRV_PCM_FMTBIT_U32_BE;
> -	default:
> -		return 0;
> -	}
> -}
> -
>  static int get_port_masks(struct sdw_slave *sdw, unsigned int port,
>  			  struct snd_pcm_substream *substream,
>  			  u64 *word_mask, unsigned int *ch_mask)
> @@ -1564,7 +1544,7 @@ static int get_port_masks(struct sdw_slave *sdw, unsigned int port,
>  
>  		if (prop[i].num_words) {
>  			for (j = 0; j < prop[i].num_words; j++)
> -				*word_mask |= get_word_mask(prop[i].words[j]);
> +				*word_mask |= width_find_mask(prop[i].words[j]);
>  		} else {
>  			unsigned int max = prop[i].max_word;
>  
> @@ -1572,7 +1552,7 @@ static int get_port_masks(struct sdw_slave *sdw, unsigned int port,
>  				max = 32;
>  
>  			for (j = MAX(1, prop[i].min_word); j <= max; j++)
> -				*word_mask |= get_word_mask(j);
> +				*word_mask |= width_find_mask(j);
>  		}
>  
>  		/* Only handle the number of channels for constraints. */


      reply	other threads:[~2026-11-23 17:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 11:52 Charles Keepax
2026-11-23 17:42 ` Srinivas Kandagatla [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=90f6a16a-2d50-4453-bb3e-b4c60f4d2d82@oss.qualcomm.com \
    --to=srinivas.kandagatla@oss.qualcomm.com \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=yung-chuan.liao@linux.intel.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

all inboxes | Powered by JetHome®