Commit 7c935976 authored by Stephen Warren's avatar Stephen Warren Committed by Takashi Iwai

ALSA: hda: Allow multple SPDIF controls per codec

Currently, the data that backs the kcontrols created by
snd_hda_create_spdif_out_ctls is stored directly in struct hda_codec. When
multiple sets of these controls are stored, they will all manipulate the
same data, causing confusion. Instead, store an array of this data, one
copy per converter, to isolate the controls.

This patch would cause a behavioural change in the case where
snd_hda_create_spdif_out_ctls was called multiple times for a single codec.
As best I can tell, this is never the case for any codec.

This will be relevant at least for some HDMI audio codecs, such as the
NVIDIA GeForce 520 and Intel Ibex Peak. A future change will modify the
driver's handling of those codecs to create multiple PCMs per codec. Note
that this issue isn't affected by whether one creates a PCM-per-converter
or PCM-per-pin; there are multiple of both within a single codec in both
of those codecs.

Note that those codecs don't currently create multiple PCMs for the codec
due to the default HW mux state of all pins being to point at the same
converter, hence there is only a single converter routed to any pin, and
hence only a single PCM.
Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent c3d52105
...@@ -1083,6 +1083,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) ...@@ -1083,6 +1083,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
snd_array_free(&codec->mixers); snd_array_free(&codec->mixers);
snd_array_free(&codec->nids); snd_array_free(&codec->nids);
snd_array_free(&codec->conn_lists); snd_array_free(&codec->conn_lists);
snd_array_free(&codec->spdif_out);
codec->bus->caddr_tbl[codec->addr] = NULL; codec->bus->caddr_tbl[codec->addr] = NULL;
if (codec->patch_ops.free) if (codec->patch_ops.free)
codec->patch_ops.free(codec); codec->patch_ops.free(codec);
...@@ -1144,6 +1145,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, ...@@ -1144,6 +1145,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus,
snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16); snd_array_init(&codec->driver_pins, sizeof(struct hda_pincfg), 16);
snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8);
snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64); snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64);
snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16);
if (codec->bus->modelname) { if (codec->bus->modelname) {
codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL); codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
if (!codec->modelname) { if (!codec->modelname) {
...@@ -2555,11 +2557,13 @@ static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, ...@@ -2555,11 +2557,13 @@ static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
int idx = kcontrol->private_value;
struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx);
ucontrol->value.iec958.status[0] = codec->spdif_status & 0xff; ucontrol->value.iec958.status[0] = spdif->status & 0xff;
ucontrol->value.iec958.status[1] = (codec->spdif_status >> 8) & 0xff; ucontrol->value.iec958.status[1] = (spdif->status >> 8) & 0xff;
ucontrol->value.iec958.status[2] = (codec->spdif_status >> 16) & 0xff; ucontrol->value.iec958.status[2] = (spdif->status >> 16) & 0xff;
ucontrol->value.iec958.status[3] = (codec->spdif_status >> 24) & 0xff; ucontrol->value.iec958.status[3] = (spdif->status >> 24) & 0xff;
return 0; return 0;
} }
...@@ -2644,19 +2648,21 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, ...@@ -2644,19 +2648,21 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
hda_nid_t nid = kcontrol->private_value; int idx = kcontrol->private_value;
struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx);
hda_nid_t nid = spdif->nid;
unsigned short val; unsigned short val;
int change; int change;
mutex_lock(&codec->spdif_mutex); mutex_lock(&codec->spdif_mutex);
codec->spdif_status = ucontrol->value.iec958.status[0] | spdif->status = ucontrol->value.iec958.status[0] |
((unsigned int)ucontrol->value.iec958.status[1] << 8) | ((unsigned int)ucontrol->value.iec958.status[1] << 8) |
((unsigned int)ucontrol->value.iec958.status[2] << 16) | ((unsigned int)ucontrol->value.iec958.status[2] << 16) |
((unsigned int)ucontrol->value.iec958.status[3] << 24); ((unsigned int)ucontrol->value.iec958.status[3] << 24);
val = convert_from_spdif_status(codec->spdif_status); val = convert_from_spdif_status(spdif->status);
val |= codec->spdif_ctls & 1; val |= spdif->ctls & 1;
change = codec->spdif_ctls != val; change = spdif->ctls != val;
codec->spdif_ctls = val; spdif->ctls = val;
if (change) if (change)
set_dig_out_convert(codec, nid, val & 0xff, (val >> 8) & 0xff); set_dig_out_convert(codec, nid, val & 0xff, (val >> 8) & 0xff);
...@@ -2671,8 +2677,10 @@ static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol, ...@@ -2671,8 +2677,10 @@ static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
int idx = kcontrol->private_value;
struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx);
ucontrol->value.integer.value[0] = codec->spdif_ctls & AC_DIG1_ENABLE; ucontrol->value.integer.value[0] = spdif->ctls & AC_DIG1_ENABLE;
return 0; return 0;
} }
...@@ -2680,17 +2688,19 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, ...@@ -2680,17 +2688,19 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct hda_codec *codec = snd_kcontrol_chip(kcontrol); struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
hda_nid_t nid = kcontrol->private_value; int idx = kcontrol->private_value;
struct hda_spdif_out *spdif = snd_array_elem(&codec->spdif_out, idx);
hda_nid_t nid = spdif->nid;
unsigned short val; unsigned short val;
int change; int change;
mutex_lock(&codec->spdif_mutex); mutex_lock(&codec->spdif_mutex);
val = codec->spdif_ctls & ~AC_DIG1_ENABLE; val = spdif->ctls & ~AC_DIG1_ENABLE;
if (ucontrol->value.integer.value[0]) if (ucontrol->value.integer.value[0])
val |= AC_DIG1_ENABLE; val |= AC_DIG1_ENABLE;
change = codec->spdif_ctls != val; change = spdif->ctls != val;
if (change) { if (change) {
codec->spdif_ctls = val; spdif->ctls = val;
set_dig_out_convert(codec, nid, val & 0xff, -1); set_dig_out_convert(codec, nid, val & 0xff, -1);
/* unmute amp switch (if any) */ /* unmute amp switch (if any) */
if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) && if ((get_wcaps(codec, nid) & AC_WCAP_OUT_AMP) &&
...@@ -2750,30 +2760,46 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid) ...@@ -2750,30 +2760,46 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)
struct snd_kcontrol *kctl; struct snd_kcontrol *kctl;
struct snd_kcontrol_new *dig_mix; struct snd_kcontrol_new *dig_mix;
int idx; int idx;
struct hda_spdif_out *spdif;
idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch"); idx = find_empty_mixer_ctl_idx(codec, "IEC958 Playback Switch");
if (idx < 0) { if (idx < 0) {
printk(KERN_ERR "hda_codec: too many IEC958 outputs\n"); printk(KERN_ERR "hda_codec: too many IEC958 outputs\n");
return -EBUSY; return -EBUSY;
} }
spdif = snd_array_new(&codec->spdif_out);
for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) {
kctl = snd_ctl_new1(dig_mix, codec); kctl = snd_ctl_new1(dig_mix, codec);
if (!kctl) if (!kctl)
return -ENOMEM; return -ENOMEM;
kctl->id.index = idx; kctl->id.index = idx;
kctl->private_value = nid; kctl->private_value = codec->spdif_out.used - 1;
err = snd_hda_ctl_add(codec, nid, kctl); err = snd_hda_ctl_add(codec, nid, kctl);
if (err < 0) if (err < 0)
return err; return err;
} }
codec->spdif_ctls = spdif->nid = nid;
snd_hda_codec_read(codec, nid, 0, spdif->ctls = snd_hda_codec_read(codec, nid, 0,
AC_VERB_GET_DIGI_CONVERT_1, 0); AC_VERB_GET_DIGI_CONVERT_1, 0);
codec->spdif_status = convert_to_spdif_status(codec->spdif_ctls); spdif->status = convert_to_spdif_status(spdif->ctls);
return 0; return 0;
} }
EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls); EXPORT_SYMBOL_HDA(snd_hda_create_spdif_out_ctls);
struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec,
hda_nid_t nid)
{
int i;
for (i = 0; i < codec->spdif_out.used; i++) {
struct hda_spdif_out *spdif =
snd_array_elem(&codec->spdif_out, i);
if (spdif->nid == nid)
return spdif;
}
return NULL;
}
EXPORT_SYMBOL_HDA(snd_hda_spdif_out_of_nid);
/* /*
* SPDIF sharing with analog output * SPDIF sharing with analog output
*/ */
...@@ -4177,10 +4203,12 @@ EXPORT_SYMBOL_HDA(snd_hda_input_mux_put); ...@@ -4177,10 +4203,12 @@ EXPORT_SYMBOL_HDA(snd_hda_input_mux_put);
static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
unsigned int stream_tag, unsigned int format) unsigned int stream_tag, unsigned int format)
{ {
struct hda_spdif_out *spdif = snd_hda_spdif_out_of_nid(codec, nid);
/* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE))
set_dig_out_convert(codec, nid, set_dig_out_convert(codec, nid,
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff, spdif->ctls & ~AC_DIG1_ENABLE & 0xff,
-1); -1);
snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
if (codec->slave_dig_outs) { if (codec->slave_dig_outs) {
...@@ -4190,9 +4218,9 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, ...@@ -4190,9 +4218,9 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid,
format); format);
} }
/* turn on again (if needed) */ /* turn on again (if needed) */
if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE))
set_dig_out_convert(codec, nid, set_dig_out_convert(codec, nid,
codec->spdif_ctls & 0xff, -1); spdif->ctls & 0xff, -1);
} }
static void cleanup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid) static void cleanup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid)
...@@ -4348,6 +4376,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, ...@@ -4348,6 +4376,8 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
{ {
const hda_nid_t *nids = mout->dac_nids; const hda_nid_t *nids = mout->dac_nids;
int chs = substream->runtime->channels; int chs = substream->runtime->channels;
struct hda_spdif_out *spdif =
snd_hda_spdif_out_of_nid(codec, mout->dig_out_nid);
int i; int i;
mutex_lock(&codec->spdif_mutex); mutex_lock(&codec->spdif_mutex);
...@@ -4356,7 +4386,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec, ...@@ -4356,7 +4386,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,
if (chs == 2 && if (chs == 2 &&
snd_hda_is_supported_format(codec, mout->dig_out_nid, snd_hda_is_supported_format(codec, mout->dig_out_nid,
format) && format) &&
!(codec->spdif_status & IEC958_AES0_NONAUDIO)) { !(spdif->status & IEC958_AES0_NONAUDIO)) {
mout->dig_out_used = HDA_DIG_ANALOG_DUP; mout->dig_out_used = HDA_DIG_ANALOG_DUP;
setup_dig_out_stream(codec, mout->dig_out_nid, setup_dig_out_stream(codec, mout->dig_out_nid,
stream_tag, format); stream_tag, format);
......
...@@ -829,8 +829,7 @@ struct hda_codec { ...@@ -829,8 +829,7 @@ struct hda_codec {
struct mutex spdif_mutex; struct mutex spdif_mutex;
struct mutex control_mutex; struct mutex control_mutex;
unsigned int spdif_status; /* IEC958 status bits */ struct snd_array spdif_out;
unsigned short spdif_ctls; /* SPDIF control bits */
unsigned int spdif_in_enable; /* SPDIF input enable? */ unsigned int spdif_in_enable; /* SPDIF input enable? */
const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */ const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
struct snd_array init_pins; /* initial (BIOS) pin configurations */ struct snd_array init_pins; /* initial (BIOS) pin configurations */
...@@ -947,6 +946,15 @@ int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list, ...@@ -947,6 +946,15 @@ int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
hda_nid_t nid, unsigned int cfg); /* for hwdep */ hda_nid_t nid, unsigned int cfg); /* for hwdep */
void snd_hda_shutup_pins(struct hda_codec *codec); void snd_hda_shutup_pins(struct hda_codec *codec);
/* SPDIF controls */
struct hda_spdif_out {
hda_nid_t nid; /* Converter nid values relate to */
unsigned int status; /* IEC958 status bits */
unsigned short ctls; /* SPDIF control bits */
};
struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec,
hda_nid_t nid);
/* /*
* Mixer * Mixer
*/ */
......
...@@ -1706,13 +1706,16 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream) ...@@ -1706,13 +1706,16 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)
struct snd_pcm_runtime *runtime = substream->runtime; struct snd_pcm_runtime *runtime = substream->runtime;
unsigned int bufsize, period_bytes, format_val, stream_tag; unsigned int bufsize, period_bytes, format_val, stream_tag;
int err; int err;
struct hda_spdif_out *spdif =
snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid);
unsigned short ctls = spdif ? spdif->ctls : 0;
azx_stream_reset(chip, azx_dev); azx_stream_reset(chip, azx_dev);
format_val = snd_hda_calc_stream_format(runtime->rate, format_val = snd_hda_calc_stream_format(runtime->rate,
runtime->channels, runtime->channels,
runtime->format, runtime->format,
hinfo->maxbps, hinfo->maxbps,
apcm->codec->spdif_ctls); ctls);
if (!format_val) { if (!format_val) {
snd_printk(KERN_ERR SFX snd_printk(KERN_ERR SFX
"invalid format_val, rate=%d, ch=%d, format=%d\n", "invalid format_val, rate=%d, ch=%d, format=%d\n",
......
...@@ -1352,6 +1352,9 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -1352,6 +1352,9 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
int chs; int chs;
unsigned int dataDCC1, dataDCC2, channel_id; unsigned int dataDCC1, dataDCC2, channel_id;
int i; int i;
struct hdmi_spec *spec = codec->spec;
struct hda_spdif_out *spdif =
snd_hda_spdif_out_of_nid(codec, spec->cvt[0]);
mutex_lock(&codec->spdif_mutex); mutex_lock(&codec->spdif_mutex);
...@@ -1361,12 +1364,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -1361,12 +1364,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
dataDCC2 = 0x2; dataDCC2 = 0x2;
/* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE))
snd_hda_codec_write(codec, snd_hda_codec_write(codec,
nvhdmi_master_con_nid_7x, nvhdmi_master_con_nid_7x,
0, 0,
AC_VERB_SET_DIGI_CONVERT_1, AC_VERB_SET_DIGI_CONVERT_1,
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); spdif->ctls & ~AC_DIG1_ENABLE & 0xff);
/* set the stream id */ /* set the stream id */
snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
...@@ -1378,12 +1381,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -1378,12 +1381,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
/* turn on again (if needed) */ /* turn on again (if needed) */
/* enable and set the channel status audio/data flag */ /* enable and set the channel status audio/data flag */
if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) {
snd_hda_codec_write(codec, snd_hda_codec_write(codec,
nvhdmi_master_con_nid_7x, nvhdmi_master_con_nid_7x,
0, 0,
AC_VERB_SET_DIGI_CONVERT_1, AC_VERB_SET_DIGI_CONVERT_1,
codec->spdif_ctls & 0xff); spdif->ctls & 0xff);
snd_hda_codec_write(codec, snd_hda_codec_write(codec,
nvhdmi_master_con_nid_7x, nvhdmi_master_con_nid_7x,
0, 0,
...@@ -1400,12 +1403,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -1400,12 +1403,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
*otherwise the IEC958 bits won't be updated *otherwise the IEC958 bits won't be updated
*/ */
if (codec->spdif_status_reset && if (codec->spdif_status_reset &&
(codec->spdif_ctls & AC_DIG1_ENABLE)) (spdif->ctls & AC_DIG1_ENABLE))
snd_hda_codec_write(codec, snd_hda_codec_write(codec,
nvhdmi_con_nids_7x[i], nvhdmi_con_nids_7x[i],
0, 0,
AC_VERB_SET_DIGI_CONVERT_1, AC_VERB_SET_DIGI_CONVERT_1,
codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); spdif->ctls & ~AC_DIG1_ENABLE & 0xff);
/* set the stream id */ /* set the stream id */
snd_hda_codec_write(codec, snd_hda_codec_write(codec,
nvhdmi_con_nids_7x[i], nvhdmi_con_nids_7x[i],
...@@ -1421,12 +1424,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, ...@@ -1421,12 +1424,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
/* turn on again (if needed) */ /* turn on again (if needed) */
/* enable and set the channel status audio/data flag */ /* enable and set the channel status audio/data flag */
if (codec->spdif_status_reset && if (codec->spdif_status_reset &&
(codec->spdif_ctls & AC_DIG1_ENABLE)) { (spdif->ctls & AC_DIG1_ENABLE)) {
snd_hda_codec_write(codec, snd_hda_codec_write(codec,
nvhdmi_con_nids_7x[i], nvhdmi_con_nids_7x[i],
0, 0,
AC_VERB_SET_DIGI_CONVERT_1, AC_VERB_SET_DIGI_CONVERT_1,
codec->spdif_ctls & 0xff); spdif->ctls & 0xff);
snd_hda_codec_write(codec, snd_hda_codec_write(codec,
nvhdmi_con_nids_7x[i], nvhdmi_con_nids_7x[i],
0, 0,
......
...@@ -1236,28 +1236,30 @@ static void playback_multi_pcm_prep_0(struct hda_codec *codec, ...@@ -1236,28 +1236,30 @@ static void playback_multi_pcm_prep_0(struct hda_codec *codec,
const hda_nid_t *nids = mout->dac_nids; const hda_nid_t *nids = mout->dac_nids;
int chs = substream->runtime->channels; int chs = substream->runtime->channels;
int i; int i;
struct hda_spdif_out *spdif =
snd_hda_spdif_out_of_nid(codec, spec->multiout.dig_out_nid);
mutex_lock(&codec->spdif_mutex); mutex_lock(&codec->spdif_mutex);
if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) { if (mout->dig_out_nid && mout->dig_out_used != HDA_DIG_EXCLUSIVE) {
if (chs == 2 && if (chs == 2 &&
snd_hda_is_supported_format(codec, mout->dig_out_nid, snd_hda_is_supported_format(codec, mout->dig_out_nid,
format) && format) &&
!(codec->spdif_status & IEC958_AES0_NONAUDIO)) { !(spdif->status & IEC958_AES0_NONAUDIO)) {
mout->dig_out_used = HDA_DIG_ANALOG_DUP; mout->dig_out_used = HDA_DIG_ANALOG_DUP;
/* turn off SPDIF once; otherwise the IEC958 bits won't /* turn off SPDIF once; otherwise the IEC958 bits won't
* be updated */ * be updated */
if (codec->spdif_ctls & AC_DIG1_ENABLE) if (spdif->ctls & AC_DIG1_ENABLE)
snd_hda_codec_write(codec, mout->dig_out_nid, 0, snd_hda_codec_write(codec, mout->dig_out_nid, 0,
AC_VERB_SET_DIGI_CONVERT_1, AC_VERB_SET_DIGI_CONVERT_1,
codec->spdif_ctls & spdif->ctls &
~AC_DIG1_ENABLE & 0xff); ~AC_DIG1_ENABLE & 0xff);
snd_hda_codec_setup_stream(codec, mout->dig_out_nid, snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
stream_tag, 0, format); stream_tag, 0, format);
/* turn on again (if needed) */ /* turn on again (if needed) */
if (codec->spdif_ctls & AC_DIG1_ENABLE) if (spdif->ctls & AC_DIG1_ENABLE)
snd_hda_codec_write(codec, mout->dig_out_nid, 0, snd_hda_codec_write(codec, mout->dig_out_nid, 0,
AC_VERB_SET_DIGI_CONVERT_1, AC_VERB_SET_DIGI_CONVERT_1,
codec->spdif_ctls & 0xff); spdif->ctls & 0xff);
} else { } else {
mout->dig_out_used = 0; mout->dig_out_used = 0;
snd_hda_codec_setup_stream(codec, mout->dig_out_nid, snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment