Commit 022b466fc353d3dc7a152451144be656248666ce

Authored by Takashi Iwai
1 parent aa202455ee

ALSA: hda - Avoid invalid formats and rates with shared SPDIF

Check whether formats and rates don't result in zero due to the
restriction of SPDIF sharing.  If any of them can be zero, disable
the SPDIF sharing mode instead.  Otherwise it will lead to a PCM
configuration error.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

Showing 1 changed file with 10 additions and 4 deletions Side-by-side Diff

sound/pci/hda/hda_codec.c
... ... @@ -3470,10 +3470,16 @@
3470 3470 }
3471 3471 mutex_lock(&codec->spdif_mutex);
3472 3472 if (mout->share_spdif) {
3473   - runtime->hw.rates &= mout->spdif_rates;
3474   - runtime->hw.formats &= mout->spdif_formats;
3475   - if (mout->spdif_maxbps < hinfo->maxbps)
3476   - hinfo->maxbps = mout->spdif_maxbps;
  3473 + if ((runtime->hw.rates & mout->spdif_rates) &&
  3474 + (runtime->hw.formats & mout->spdif_formats)) {
  3475 + runtime->hw.rates &= mout->spdif_rates;
  3476 + runtime->hw.formats &= mout->spdif_formats;
  3477 + if (mout->spdif_maxbps < hinfo->maxbps)
  3478 + hinfo->maxbps = mout->spdif_maxbps;
  3479 + } else {
  3480 + mout->share_spdif = 0;
  3481 + /* FIXME: need notify? */
  3482 + }
3477 3483 }
3478 3484 mutex_unlock(&codec->spdif_mutex);
3479 3485 }