ASoC: SDCA: Combine width_find_mask() and get_word_mask()
Subsystems (3)
Charles Keepax
maintainerPATCH 1/1 ASoC: SDCA: Combine width_find_mask() and get_word_mask()
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.
--- sound/soc/sdca/sdca_asoc.c | 56 ++++++++++++-------------------------- 1 file changed, 18 insertions(+), 38 deletions(-)
sound/soc/sdca/sdca_asoc.c +18 -38
@@ -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 *functreturn 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. */
Signature · 1 line
2.47.3
Quoted 15 lines · Charles Keepax
Both of these functions take a bit width and return the ALSA mask bits for that width. Remove
get_word_mask()and usewidth_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 ofget_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 toget_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.
Quoted 2 lines
Signed-off-by Charles Keepax <[email protected]>---
Tested on Snapdragon T14s Gen7.
--srini
Quoted 97 lines
sound/soc/sdca/sdca_asoc.c | 56 ++++++++++++-------------------------- 1 file changed, 18 insertions(+), 38 deletions(-)sound/soc/sdca/sdca_asoc.c +18
-38@@ -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 *functreturn 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. */
Mark Brown
maintainerQuoted 1 line · Charles Keepax
ASoC: SDCA: Combine
width_find_mask()andget_word_mask()
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.5
Thanks!
[1/1] ASoC: SDCA: Combine width_find_mask() and get_word_mask()
https://git.kernel.org/broonie/sound/c/aff174aab7db
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark