Skip to content

Commit 2f43a23

Browse files
committed
Merge remote-tracking branch 'asoc/topic/pcm' into for-tiwai
2 parents 7cfa7b5 + 55dcdb5 commit 2f43a23

7 files changed

Lines changed: 59 additions & 18 deletions

File tree

‎include/sound/pcm.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,8 @@ extern const struct snd_pcm_hw_constraint_list snd_pcm_known_rates;
900900
int snd_pcm_limit_hw_rates(struct snd_pcm_runtime *runtime);
901901
unsigned int snd_pcm_rate_to_rate_bit(unsigned int rate);
902902
unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit);
903+
unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
904+
unsigned int rates_b);
903905

904906
static inline void snd_pcm_set_runtime_buffer(struct snd_pcm_substream *substream,
905907
struct snd_dma_buffer *bufp)

‎include/sound/soc.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,10 @@ struct snd_soc_dai_link {
895895
/* This DAI link can route to other DAI links at runtime (Frontend)*/
896896
unsigned int dynamic:1;
897897

898+
/* DPCM capture and Playback support */
899+
unsigned int dpcm_capture:1;
900+
unsigned int dpcm_playback:1;
901+
898902
/* pmdown_time is ignored at stop */
899903
unsigned int ignore_pmdown_time:1;
900904

‎sound/core/pcm_misc.c‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,3 +514,42 @@ unsigned int snd_pcm_rate_bit_to_rate(unsigned int rate_bit)
514514
return 0;
515515
}
516516
EXPORT_SYMBOL(snd_pcm_rate_bit_to_rate);
517+
518+
static unsigned int snd_pcm_rate_mask_sanitize(unsigned int rates)
519+
{
520+
if (rates & SNDRV_PCM_RATE_CONTINUOUS)
521+
return SNDRV_PCM_RATE_CONTINUOUS;
522+
else if (rates & SNDRV_PCM_RATE_KNOT)
523+
return SNDRV_PCM_RATE_KNOT;
524+
return rates;
525+
}
526+
527+
/**
528+
* snd_pcm_rate_mask_intersect - computes the intersection between two rate masks
529+
* @rates_a: The first rate mask
530+
* @rates_b: The second rate mask
531+
*
532+
* This function computes the rates that are supported by both rate masks passed
533+
* to the function. It will take care of the special handling of
534+
* SNDRV_PCM_RATE_CONTINUOUS and SNDRV_PCM_RATE_KNOT.
535+
*
536+
* Return: A rate mask containing the rates that are supported by both rates_a
537+
* and rates_b.
538+
*/
539+
unsigned int snd_pcm_rate_mask_intersect(unsigned int rates_a,
540+
unsigned int rates_b)
541+
{
542+
rates_a = snd_pcm_rate_mask_sanitize(rates_a);
543+
rates_b = snd_pcm_rate_mask_sanitize(rates_b);
544+
545+
if (rates_a & SNDRV_PCM_RATE_CONTINUOUS)
546+
return rates_b;
547+
else if (rates_b & SNDRV_PCM_RATE_CONTINUOUS)
548+
return rates_a;
549+
else if (rates_a & SNDRV_PCM_RATE_KNOT)
550+
return rates_b;
551+
else if (rates_b & SNDRV_PCM_RATE_KNOT)
552+
return rates_a;
553+
return rates_a & rates_b;
554+
}
555+
EXPORT_SYMBOL_GPL(snd_pcm_rate_mask_intersect);

‎sound/soc/fsl/fsl_ssi.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ static inline void write_ssi_mask(u32 __iomem *addr, u32 clear, u32 set)
8080
* ALSA that we support all rates and let the codec driver decide what rates
8181
* are really supported.
8282
*/
83-
#define FSLSSI_I2S_RATES (SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000 | \
84-
SNDRV_PCM_RATE_CONTINUOUS)
83+
#define FSLSSI_I2S_RATES SNDRV_PCM_RATE_CONTINUOUS
8584

8685
/**
8786
* FSLSSI_I2S_FORMATS: audio formats supported by the SSI

‎sound/soc/fsl/mpc5200_psc_i2s.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
* ALSA that we support all rates and let the codec driver decide what rates
2727
* are really supported.
2828
*/
29-
#define PSC_I2S_RATES (SNDRV_PCM_RATE_5512 | SNDRV_PCM_RATE_8000_192000 | \
30-
SNDRV_PCM_RATE_CONTINUOUS)
29+
#define PSC_I2S_RATES SNDRV_PCM_RATE_CONTINUOUS
3130

3231
/**
3332
* PSC_I2S_FORMATS: audio formats supported by the PSC I2S mode

‎sound/soc/s6000/s6000-i2s.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,7 @@ static int s6000_i2s_dai_probe(struct snd_soc_dai *dai)
405405
return 0;
406406
}
407407

408-
#define S6000_I2S_RATES (SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_5512 | \
409-
SNDRV_PCM_RATE_8000_192000)
408+
#define S6000_I2S_RATES SNDRV_PCM_RATE_CONTINUOUS
410409
#define S6000_I2S_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
411410

412411
static const struct snd_soc_dai_ops s6000_i2s_dai_ops = {

‎sound/soc/soc-pcm.c‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,15 @@ static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime,
240240
cpu_stream->channels_min);
241241
hw->channels_max = min(codec_stream->channels_max,
242242
cpu_stream->channels_max);
243-
hw->formats = codec_stream->formats & cpu_stream->formats;
244-
hw->rates = codec_stream->rates & cpu_stream->rates;
245-
if (codec_stream->rates
246-
& (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
247-
hw->rates |= cpu_stream->rates;
248-
if (cpu_stream->rates
249-
& (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
250-
hw->rates |= codec_stream->rates;
243+
if (hw->formats)
244+
hw->formats &= codec_stream->formats & cpu_stream->formats;
245+
else
246+
hw->formats = codec_stream->formats & cpu_stream->formats;
247+
hw->rates = snd_pcm_rate_mask_intersect(codec_stream->rates,
248+
cpu_stream->rates);
249+
250+
hw->rate_min = 0;
251+
hw->rate_max = UINT_MAX;
251252

252253
snd_pcm_limit_hw_rates(runtime);
253254

@@ -2140,10 +2141,8 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
21402141
int ret = 0, playback = 0, capture = 0;
21412142

21422143
if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) {
2143-
if (cpu_dai->driver->playback.channels_min)
2144-
playback = 1;
2145-
if (cpu_dai->driver->capture.channels_min)
2146-
capture = 1;
2144+
playback = rtd->dai_link->dpcm_playback;
2145+
capture = rtd->dai_link->dpcm_capture;
21472146
} else {
21482147
if (codec_dai->driver->playback.channels_min &&
21492148
cpu_dai->driver->playback.channels_min)

0 commit comments

Comments
 (0)