Skip to content

Commit 34257a7

Browse files
committed
Merge series "ASoC: stm32: dfsdm: change rate limits" from Olivier Moysan <[email protected]>:
Widening of the supported rate range in the STM32 DFSDM driver. The rates were previously limited to 8kHz, 16kHz and 32kHz. Allow rate capture in the whole range 8kHz-48kHz as there is no hardware limitation to support it. Actual sample resolution is dependent on audio rate and DFSDM configuration. Add a trace to allow simple check of sample resolution. Olivier Moysan (2): ASoC: stm32: dfsdm: change rate limits ASoC: stm32: dfsdm: add actual resolution trace drivers/iio/adc/stm32-dfsdm-adc.c | 4 ++++ drivers/iio/adc/stm32-dfsdm.h | 2 ++ sound/soc/stm/stm32_adfsdm.c | 8 +++----- 3 files changed, 9 insertions(+), 5 deletions(-) -- 2.17.1
2 parents def69f2 + 41bceb1 commit 34257a7

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

drivers/iio/adc/stm32-dfsdm-adc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ static int stm32_dfsdm_compute_osrs(struct stm32_dfsdm_filter *fl,
293293
max >>= flo->rshift;
294294
}
295295
flo->max = (s32)max;
296+
flo->bits = bits;
296297

297298
pr_debug("%s: fast %d, fosr %d, iosr %d, res 0x%llx/%d bits, rshift %d, lshift %d\n",
298299
__func__, fast, flo->fosr, flo->iosr,
@@ -476,6 +477,9 @@ static int stm32_dfsdm_channels_configure(struct iio_dev *indio_dev,
476477
if (!flo->res)
477478
return -EINVAL;
478479

480+
dev_dbg(&indio_dev->dev, "Samples actual resolution: %d bits",
481+
min(flo->bits, (u32)DFSDM_DATA_RES - 1));
482+
479483
for_each_set_bit(bit, &adc->smask,
480484
sizeof(adc->smask) * BITS_PER_BYTE) {
481485
chan = indio_dev->channels + bit;

drivers/iio/adc/stm32-dfsdm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ enum stm32_dfsdm_sinc_order {
249249
* @rshift: output sample right shift (hardware shift)
250250
* @lshift: output sample left shift (software shift)
251251
* @res: output sample resolution
252+
* @bits: output sample resolution in bits
252253
* @max: output sample maximum positive value
253254
*/
254255
struct stm32_dfsdm_filter_osr {
@@ -257,6 +258,7 @@ struct stm32_dfsdm_filter_osr {
257258
unsigned int rshift;
258259
unsigned int lshift;
259260
u64 res;
261+
u32 bits;
260262
s32 max;
261263
};
262264

sound/soc/stm/stm32_adfsdm.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ static const struct snd_pcm_hardware stm32_adfsdm_pcm_hw = {
4747
SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_PAUSE,
4848
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
4949

50-
.rate_min = 8000,
51-
.rate_max = 32000,
52-
5350
.channels_min = 1,
5451
.channels_max = 1,
5552

@@ -143,8 +140,9 @@ static const struct snd_soc_dai_driver stm32_adfsdm_dai = {
143140
.channels_max = 1,
144141
.formats = SNDRV_PCM_FMTBIT_S16_LE |
145142
SNDRV_PCM_FMTBIT_S32_LE,
146-
.rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |
147-
SNDRV_PCM_RATE_32000),
143+
.rates = SNDRV_PCM_RATE_CONTINUOUS,
144+
.rate_min = 8000,
145+
.rate_max = 48000,
148146
},
149147
.ops = &stm32_adfsdm_dai_ops,
150148
};

0 commit comments

Comments
 (0)