Merge tag 'asoc-v3.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[cascardo/linux.git] / sound / core / pcm_lib.c
index 446c00b..ffd6560 100644 (file)
@@ -1384,8 +1384,14 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params,
        int width = l & 0xffff;
        unsigned int msbits = l >> 16;
        struct snd_interval *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS);
-       if (snd_interval_single(i) && snd_interval_value(i) == width)
-               params->msbits = msbits;
+
+       if (!snd_interval_single(i))
+               return 0;
+
+       if ((snd_interval_value(i) == width) ||
+           (width == 0 && snd_interval_value(i) > msbits))
+               params->msbits = min_not_zero(params->msbits, msbits);
+
        return 0;
 }
 
@@ -1396,6 +1402,11 @@ static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params,
  * @width: sample bits width
  * @msbits: msbits width
  *
+ * This constraint will set the number of most significant bits (msbits) if a
+ * sample format with the specified width has been select. If width is set to 0
+ * the msbits will be set for any sample format with a width larger than the
+ * specified msbits.
+ *
  * Return: Zero if successful, or a negative error code on failure.
  */
 int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime,