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>

+10 -4
+10 -4
sound/pci/hda/hda_codec.c
··· 3470 } 3471 mutex_lock(&codec->spdif_mutex); 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; 3477 } 3478 mutex_unlock(&codec->spdif_mutex); 3479 }
··· 3470 } 3471 mutex_lock(&codec->spdif_mutex); 3472 if (mout->share_spdif) { 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 + } 3483 } 3484 mutex_unlock(&codec->spdif_mutex); 3485 }