Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: spacemit: move hw constraints from hw_params to startup

Hardware constraints should be applied in the startup callback rather
than hw_params, as hw_params may be called too late for the constraints
to take effect properly.

Move the channel count and format constraints for I2S and DSP_A/DSP_B
modes into a new startup callback. This also tightens the I2S mode
channel constraint from 1-2 to exactly 2, matching the actual hardware
behavior.

Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Link: https://patch.msgid.link/20260429-k3-i2s-v1-2-2fe99db11ecb@linux.spacemit.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Troy Mitchell and committed by
Mark Brown
6b4afbaa a201aef1

+32 -13
+32 -13
sound/soc/spacemit/k1_i2s.c
··· 106 106 writel(0, i2s->base + SSINTEN); 107 107 } 108 108 109 + static int spacemit_i2s_startup(struct snd_pcm_substream *substream, 110 + struct snd_soc_dai *dai) 111 + { 112 + struct spacemit_i2s_dev *i2s = snd_soc_dai_get_drvdata(dai); 113 + 114 + switch (i2s->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) { 115 + case SND_SOC_DAIFMT_I2S: 116 + snd_pcm_hw_constraint_minmax(substream->runtime, 117 + SNDRV_PCM_HW_PARAM_CHANNELS, 118 + 2, 2); 119 + snd_pcm_hw_constraint_mask64(substream->runtime, 120 + SNDRV_PCM_HW_PARAM_FORMAT, 121 + SNDRV_PCM_FMTBIT_S16_LE); 122 + break; 123 + case SND_SOC_DAIFMT_DSP_A: 124 + case SND_SOC_DAIFMT_DSP_B: 125 + snd_pcm_hw_constraint_minmax(substream->runtime, 126 + SNDRV_PCM_HW_PARAM_CHANNELS, 127 + 1, 1); 128 + snd_pcm_hw_constraint_mask64(substream->runtime, 129 + SNDRV_PCM_HW_PARAM_FORMAT, 130 + SNDRV_PCM_FMTBIT_S32_LE); 131 + break; 132 + default: 133 + dev_dbg(i2s->dev, "unexpected format type"); 134 + return -EINVAL; 135 + } 136 + 137 + return 0; 138 + } 139 + 109 140 static int spacemit_i2s_hw_params(struct snd_pcm_substream *substream, 110 141 struct snd_pcm_hw_params *params, 111 142 struct snd_soc_dai *dai) ··· 188 157 dma_data->maxburst = 32; 189 158 dma_data->addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 190 159 } 191 - 192 - snd_pcm_hw_constraint_minmax(substream->runtime, 193 - SNDRV_PCM_HW_PARAM_CHANNELS, 194 - 1, 2); 195 - snd_pcm_hw_constraint_mask64(substream->runtime, 196 - SNDRV_PCM_HW_PARAM_FORMAT, 197 - SNDRV_PCM_FMTBIT_S16_LE); 198 160 break; 199 161 case SND_SOC_DAIFMT_DSP_A: 200 162 case SND_SOC_DAIFMT_DSP_B: 201 - snd_pcm_hw_constraint_minmax(substream->runtime, 202 - SNDRV_PCM_HW_PARAM_CHANNELS, 203 - 1, 1); 204 - snd_pcm_hw_constraint_mask64(substream->runtime, 205 - SNDRV_PCM_HW_PARAM_FORMAT, 206 - SNDRV_PCM_FMTBIT_S32_LE); 207 163 break; 208 164 default: 209 165 dev_dbg(i2s->dev, "unexpected format type"); ··· 321 303 static const struct snd_soc_dai_ops spacemit_i2s_dai_ops = { 322 304 .probe = spacemit_i2s_dai_probe, 323 305 .remove = spacemit_i2s_dai_remove, 306 + .startup = spacemit_i2s_startup, 324 307 .hw_params = spacemit_i2s_hw_params, 325 308 .set_sysclk = spacemit_i2s_set_sysclk, 326 309 .set_fmt = spacemit_i2s_set_fmt,