HDMI: Implement pcm-per-pin
cover HDMI: Implement pcm-per-pin
This patchset implements a PCM-per-pin-widget model for all HDMI codecs that use the generic codec support. For most existing codecs, there is 1 pin and 1 converter per codec, so this change should have no functional impact. For some codecs (e.g. GeForce 520, Intel Ibex Peak) there are fewer converters than pins, and the default routing is for all pins to be mux'd from a single codec, so this patch allows:
a) Multiple PCMs to be used at once (1 per converter). Previously, only 1 PCM was created due to the default muxing.
b) A direct mapping from PCM device to pin, and hence to ELD data and connected monitor. This should enable simpler/better decisions re: which audio formats are supported for that PCM, since only 1 ELD has to be considered (previously, I think the ELDs other than from the first pin were simply ignored)
The very first change in the series is actually somewhat unrelated, but I noticed it while working on this, and I believe it's a correct change.
Stephen Warren (6):
ALSA: hda: Gate ELD usage only by whether ELD is valid
ALSA: hda: Allow multple SPDIF controls per codec
ALSA: hda: Virtualize SPDIF out controls
ALSA: hda: Separate generic and non-generic implementations
ALSA: hda: hdmi_eld_update_pcm_info: update a stream in place
ALSA: hda: HDMI: Support codecs with fewer cvts than pins
sound/pci/hda/hda_codec.c | 139 ++++++--- sound/pci/hda/hda_codec.h | 16 +- sound/pci/hda/hda_eld.c | 46 ++-- sound/pci/hda/hda_intel.c | 5 +- sound/pci/hda/hda_local.h | 8 +- sound/pci/hda/patch_analog.c | 4 +- sound/pci/hda/patch_ca0110.c | 3 +- sound/pci/hda/patch_cirrus.c | 3 +- sound/pci/hda/patch_cmedia.c | 4 +- sound/pci/hda/patch_conexant.c | 1 + sound/pci/hda/patch_hdmi.c | 704 ++++++++++++++++++++++++---------------- sound/pci/hda/patch_realtek.c | 1 + sound/pci/hda/patch_sigmatel.c | 4 +- sound/pci/hda/patch_via.c | 13 +- 14 files changed, 594 insertions(+), 357 deletions(-)
PATCH 1/6 ALSA: hda: Gate ELD usage only by whether ELD is valid
It's perfectly valid for an ELD to contain no SADs. This simply means that only basic audio is supoprted.
In this case, we still want to limit a PCM's capabilities based on the ELD.
History:
* Originally, ELD application was limited solely by sad_count>0, which was used to check that an ELD had been read.
* Later, eld_valid was added to the conditions to satisfy.
This change removes the original sad_count>0 check, which when squashed with the above two changes ends up replacing if (sad_count) with if (eld_valid).
--- sound/pci/hda/patch_hdmi.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
sound/pci/hda/patch_hdmi.c +1 -1
@@ -816,7 +816,7 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, *codec_pars = *hinfo; eld = &spec->sink_eld[idx]; -if (!static_hdmi_pcm && eld->eld_valid && eld->sad_count >0 ) { +if (!static_hdmi_pcm && eld->eld_valid) {hdmi_eld_update_pcm_info (eld, hinfo, codec_pars);if (hinfo->channels_min > hinfo->channels_max || !hinfo->rates || !hinfo->formats)
Signature · 1 line
1.7.0.4
PATCH 2/6 ALSA: hda: Allow multple SPDIF controls per codec
In reply to Stephen WarrenCurrently, 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.
--- sound/pci/hda/hda_codec.c | 80 ++++++++++++++++++++++++++++++-------------- sound/pci/hda/hda_codec.h | 12 +++++- sound/pci/hda/hda_intel.c | 5 ++- sound/pci/hda/patch_hdmi.c | 19 ++++++---- sound/pci/hda/patch_via.c | 12 ++++--- 5 files changed, 87 insertions(+), 41 deletions(-)
sound/pci/hda/hda_codec.c +55 -25
@@ -1083,6 +1083,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)snd_array_free (&codec->mixers);snd_array_free (&codec->nids);snd_array_free (&codec->conn_lists); +snd_array_free (&codec->spdif_out); codec->bus->caddr_tbl[codec->addr] =NULL ;if (codec->patch_ops.free) codec->patch_ops.free (codec);
@@ -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->cvt_setups,sizeof (struct hda_cvt_setup ),8 );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) { codec->modelname =kstrdup (codec->bus->modelname,GFP_KERNEL );if (!codec->modelname) {
@@ -2555,11 +2557,13 @@ static int snd_hda_spdif_default_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {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[1 ] = (codec->spdif_status >>8 ) &0xff ; - ucontrol->value.iec958.status[2 ] = (codec->spdif_status >>16 ) &0xff ; - ucontrol->value.iec958.status[3 ] = (codec->spdif_status >>24 ) &0xff ; + ucontrol->value.iec958.status[0 ] = spdif->status &0xff ; + ucontrol->value.iec958.status[1 ] = (spdif->status >>8 ) &0xff ; + ucontrol->value.iec958.status[2 ] = (spdif->status >>16 ) &0xff ; + ucontrol->value.iec958.status[3 ] = (spdif->status >>24 ) &0xff ;return 0 ; }
@@ -2644,19 +2648,21 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {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;int change;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[2 ] <<16 ) | ((unsigned int )ucontrol->value.iec958.status[3 ] <<24 ); - val =convert_from_spdif_status (codec->spdif_status); - val |= codec->spdif_ctls &1 ; - change = codec->spdif_ctls != val; - codec->spdif_ctls = val; + val =convert_from_spdif_status (spdif->status); + val |= spdif->ctls &1 ; + change = spdif->ctls != val; + spdif->ctls = val;if (change)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, struct snd_ctl_elem_value *ucontrol) {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 ; }
@@ -2680,17 +2688,19 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {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;int change;mutex_lock (&codec->spdif_mutex); - val = codec->spdif_ctls & ~AC_DIG1_ENABLE ; + val = spdif->ctls & ~AC_DIG1_ENABLE ;if (ucontrol->value.integer.value[0 ]) val |=AC_DIG1_ENABLE ; - change = codec->spdif_ctls != val; + change = spdif->ctls != val;if (change) { - codec->spdif_ctls = val; + spdif->ctls = val;set_dig_out_convert (codec, nid, val &0xff ,-1 );/* unmute amp switch (if any) */ 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)struct snd_kcontrol *kctl;struct snd_kcontrol_new *dig_mix;int idx; +struct hda_spdif_out *spdif; idx =find_empty_mixer_ctl_idx (codec,"IEC958 Playback Switch" );if (idx <0 ) {printk (KERN_ERR "hda_codec: too many IEC958 outputs\n" );return -EBUSY ; } + spdif =snd_array_new (&codec->spdif_out);for (dig_mix = dig_mixes; dig_mix->name; dig_mix++) { kctl =snd_ctl_new1 (dig_mix, codec);if (!kctl)return -ENOMEM ; kctl->id.index = idx; - kctl->private_value = nid; + kctl->private_value = codec->spdif_out.used -1 ; err =snd_hda_ctl_add (codec, nid, kctl);if (err <0 )return err; } - codec->spdif_ctls = -snd_hda_codec_read (codec, nid,0 , -AC_VERB_GET_DIGI_CONVERT_1 ,0 ); - codec->spdif_status =convert_to_spdif_status (codec->spdif_ctls); + spdif->nid = nid; + spdif->ctls =snd_hda_codec_read (codec, nid,0 , +AC_VERB_GET_DIGI_CONVERT_1 ,0 ); + spdif->status =convert_to_spdif_status (spdif->ctls);return 0 ; }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 */
@@ -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,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 */ -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, - codec->spdif_ctls & ~AC_DIG1_ENABLE &0xff , + spdif->ctls & ~AC_DIG1_ENABLE &0xff ,-1 );snd_hda_codec_setup_stream (codec, nid, stream_tag,0 , format);if (codec->slave_dig_outs) {
@@ -4190,9 +4218,9 @@ static void setup_dig_out_stream(struct hda_codec *codec, hda_nid_t nid, format); }/* 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, - codec->spdif_ctls &0xff ,-1 ); + spdif->ctls &0xff ,-1 ); }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, {const hda_nid_t *nids = mout->dac_nids;int chs = substream->runtime->channels; +struct hda_spdif_out *spdif = +snd_hda_spdif_out_of_nid (codec, mout->dig_out_nid);int i;mutex_lock (&codec->spdif_mutex);
@@ -4356,7 +4386,7 @@ int snd_hda_multi_out_analog_prepare(struct hda_codec *codec,if (chs ==2 &&snd_hda_is_supported_format (codec, mout->dig_out_nid, format) && - !(codec->spdif_status &IEC958_AES0_NONAUDIO )) { + !(spdif->status &IEC958_AES0_NONAUDIO )) { mout->dig_out_used =HDA_DIG_ANALOG_DUP ;setup_dig_out_stream (codec, mout->dig_out_nid, stream_tag, format);
sound/pci/hda/hda_codec.h +10 -2
@@ -829,8 +829,7 @@ struct hda_codec {struct mutex spdif_mutex;struct mutex control_mutex; -unsigned int spdif_status;/* IEC958 status bits */ -unsigned short spdif_ctls;/* SPDIF control bits */ +struct snd_array spdif_out;unsigned int spdif_in_enable;/* SPDIF input enable? */ const hda_nid_t *slave_dig_outs;/* optional digital out slave widgets */ 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, hda_nid_t nid, unsigned int cfg); /* for hwdep */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 */
sound/pci/hda/hda_intel.c +4 -1
@@ -1706,13 +1706,16 @@ static int azx_pcm_prepare(struct snd_pcm_substream *substream)struct snd_pcm_runtime *runtime = substream->runtime;unsigned int bufsize, period_bytes, format_val, stream_tag;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); format_val =snd_hda_calc_stream_format (runtime->rate, runtime->channels, runtime->format, hinfo->maxbps, - apcm->codec->spdif_ctls); + ctls);if (!format_val) { snd_printk(KERN_ERR SFX "invalid format_val, rate=%d, ch=%d, format=%d\n",
sound/pci/hda/patch_hdmi.c +11 -8
@@ -1352,6 +1352,9 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,int chs;unsigned int dataDCC1, dataDCC2, channel_id;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);
@@ -1361,12 +1364,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo, dataDCC2 =0x2 ;/* 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, nvhdmi_master_con_nid_7x,0 ,AC_VERB_SET_DIGI_CONVERT_1 , - codec->spdif_ctls & ~AC_DIG1_ENABLE &0xff ); + spdif->ctls & ~AC_DIG1_ENABLE &0xff );/* set the stream id */ 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,/* turn on again (if needed) */ /* 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, nvhdmi_master_con_nid_7x,0 ,AC_VERB_SET_DIGI_CONVERT_1 , - codec->spdif_ctls &0xff ); + spdif->ctls &0xff ); snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
@@ -1400,12 +1403,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,*otherwise the IEC958 bits won't be updated */ if (codec->spdif_status_reset && - (codec->spdif_ctls &AC_DIG1_ENABLE )) + (spdif->ctls &AC_DIG1_ENABLE ))snd_hda_codec_write (codec, nvhdmi_con_nids_7x[i],0 ,AC_VERB_SET_DIGI_CONVERT_1 , - codec->spdif_ctls & ~AC_DIG1_ENABLE &0xff ); + spdif->ctls & ~AC_DIG1_ENABLE &0xff );/* set the stream id */ snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i],
@@ -1421,12 +1424,12 @@ static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,/* turn on again (if needed) */ /* enable and set the channel status audio/data flag */ if (codec->spdif_status_reset && - (codec->spdif_ctls &AC_DIG1_ENABLE )) { + (spdif->ctls &AC_DIG1_ENABLE )) {snd_hda_codec_write (codec, nvhdmi_con_nids_7x[i],0 ,AC_VERB_SET_DIGI_CONVERT_1 , - codec->spdif_ctls &0xff ); + spdif->ctls &0xff ); snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
sound/pci/hda/patch_via.c +7 -5
@@ -1236,28 +1236,30 @@ static void playback_multi_pcm_prep_0(struct hda_codec *codec,const hda_nid_t *nids = mout->dac_nids;int chs = substream->runtime->channels;int i; +struct hda_spdif_out *spdif = +snd_hda_spdif_out_of_nid (codec, spec->multiout.dig_out_nid);mutex_lock (&codec->spdif_mutex);if (mout->dig_out_nid && mout->dig_out_used !=HDA_DIG_EXCLUSIVE ) {if (chs ==2 &&snd_hda_is_supported_format (codec, mout->dig_out_nid, format) && - !(codec->spdif_status &IEC958_AES0_NONAUDIO )) { + !(spdif->status &IEC958_AES0_NONAUDIO )) { mout->dig_out_used =HDA_DIG_ANALOG_DUP ;/* turn off SPDIF once; otherwise the IEC958 bits won't * 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 ,AC_VERB_SET_DIGI_CONVERT_1 , - codec->spdif_ctls & + spdif->ctls & ~AC_DIG1_ENABLE &0xff );snd_hda_codec_setup_stream (codec, mout->dig_out_nid, stream_tag,0 , format);/* 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 ,AC_VERB_SET_DIGI_CONVERT_1 , - codec->spdif_ctls &0xff ); + spdif->ctls &0xff ); }else { mout->dig_out_used =0 ; snd_hda_codec_setup_stream(codec, mout->dig_out_nid,
Signature · 1 line
1.7.0.4
PATCH 3/6 ALSA: hda: Virtualize SPDIF out controls
In reply to Stephen WarrenThe SPDIF output controls apply to converter widgets. A future change will create a PCM device per pin widget, and hence a set of SPDIF output controls per pin widget, for certain HDMI codecs. To support this, we need the ability to virtualize the SPDIF output controls. Specifically:
* Controls can be "unassigned" from real hardware when a converter is not used for the PCM the control was created for.
* Control puts only write to hardware when they are assigned.
* Controls can be "assigned" to real hardware when a converter is picked to support output for a particular PCM.
* When a converter is assigned, the hardware is updated to the cached configuration.
--- sound/pci/hda/hda_codec.c | 62 +++++++++++++++++++++++++++++---------- sound/pci/hda/hda_codec.h | 2 + sound/pci/hda/hda_local.h | 4 ++- sound/pci/hda/patch_analog.c | 4 ++- sound/pci/hda/patch_ca0110.c | 3 +- sound/pci/hda/patch_cirrus.c | 3 +- sound/pci/hda/patch_cmedia.c | 4 ++- sound/pci/hda/patch_conexant.c | 1 + sound/pci/hda/patch_hdmi.c | 3 +- sound/pci/hda/patch_realtek.c | 1 + sound/pci/hda/patch_sigmatel.c | 4 ++- sound/pci/hda/patch_via.c | 1 + 12 files changed, 69 insertions(+), 23 deletions(-)
sound/pci/hda/hda_codec.c +46 -16
@@ -2663,10 +2663,8 @@ static int snd_hda_spdif_default_put(struct snd_kcontrol *kcontrol, val |= spdif->ctls &1 ; change = spdif->ctls != val; spdif->ctls = val; - -if (change) +if (change && nid != (u16)-1 )set_dig_out_convert (codec, nid, val &0xff , (val >>8 ) &0xff ); -mutex_unlock (&codec->spdif_mutex);return change; }
@@ -2684,6 +2682,17 @@ static int snd_hda_spdif_out_switch_get(struct snd_kcontrol *kcontrol,return 0 ; } +static inline void set_spdif_ctls (struct hda_codec *codec,hda_nid_t nid, +int dig1,int dig2) +{ +set_dig_out_convert (codec, nid, dig1, dig2); +/* unmute amp switch (if any) */ +if ((get_wcaps (codec, nid) &AC_WCAP_OUT_AMP ) && + (dig1 &AC_DIG1_ENABLE )) +snd_hda_codec_amp_stereo (codec, nid,HDA_OUTPUT ,0 , +HDA_AMP_MUTE ,0 ); +} +static int snd_hda_spdif_out_switch_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {
@@ -2699,15 +2708,9 @@ static int snd_hda_spdif_out_switch_put(struct snd_kcontrol *kcontrol,if (ucontrol->value.integer.value[0 ]) val |=AC_DIG1_ENABLE ; change = spdif->ctls != val; -if (change) { - spdif->ctls = val; -set_dig_out_convert (codec, nid, val &0xff ,-1 ); -/* unmute amp switch (if any) */ -if ((get_wcaps (codec, nid) &AC_WCAP_OUT_AMP ) && - (val &AC_DIG1_ENABLE )) -snd_hda_codec_amp_stereo (codec, nid,HDA_OUTPUT ,0 , -HDA_AMP_MUTE ,0 ); - } + spdif->ctls = val; +if (change && nid != (u16)-1 ) +set_spdif_ctls (codec, nid, val &0xff ,-1 );mutex_unlock (&codec->spdif_mutex);return change; }
@@ -2754,7 +2757,9 @@ static struct snd_kcontrol_new dig_mixes[] = {* * Returns 0 if successful, or a negative error code. */ -int snd_hda_create_spdif_out_ctls (struct hda_codec *codec,hda_nid_t nid) +int snd_hda_create_spdif_out_ctls (struct hda_codec *codec, +hda_nid_t associated_nid, +hda_nid_t cvt_nid) {int err;struct snd_kcontrol *kctl;
@@ -2774,12 +2779,12 @@ int snd_hda_create_spdif_out_ctls(struct hda_codec *codec, hda_nid_t nid)return -ENOMEM ; kctl->id.index = idx; kctl->private_value = codec->spdif_out.used -1 ; - err =snd_hda_ctl_add (codec, nid, kctl); + err =snd_hda_ctl_add (codec, associated_nid, kctl);if (err <0 )return err; } - spdif->nid = nid; - spdif->ctls =snd_hda_codec_read (codec, nid,0 , + spdif->nid = cvt_nid; + spdif->ctls =snd_hda_codec_read (codec, cvt_nid,0 ,AC_VERB_GET_DIGI_CONVERT_1 ,0 ); spdif->status =convert_to_spdif_status (spdif->ctls);return 0 ;
@@ -2800,6 +2805,31 @@ struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec, }EXPORT_SYMBOL_HDA (snd_hda_spdif_out_of_nid); +void snd_hda_spdif_ctls_unassign (struct hda_codec *codec,int idx) +{ +struct hda_spdif_out *spdif =snd_array_elem (&codec->spdif_out, idx); + +mutex_lock (&codec->spdif_mutex); + spdif->nid = (u16)-1 ; +mutex_unlock (&codec->spdif_mutex); +} +EXPORT_SYMBOL_HDA (snd_hda_spdif_ctls_unassign); + +void snd_hda_spdif_ctls_assign (struct hda_codec *codec,int idx,hda_nid_t nid) +{ +struct hda_spdif_out *spdif =snd_array_elem (&codec->spdif_out, idx); +unsigned short val; + +mutex_lock (&codec->spdif_mutex); +if (spdif->nid != nid) { + spdif->nid = nid; + val = spdif->ctls; +set_spdif_ctls (codec, nid, val &0xff , (val >>8 ) &0xff ); + } +mutex_unlock (&codec->spdif_mutex); +} +EXPORT_SYMBOL_HDA (snd_hda_spdif_ctls_assign); +/* * SPDIF sharing with analog output */
sound/pci/hda/hda_codec.h +2 -0
@@ -954,6 +954,8 @@ struct hda_spdif_out { };struct hda_spdif_out *snd_hda_spdif_out_of_nid (struct hda_codec *codec,hda_nid_t nid); +void snd_hda_spdif_ctls_unassign (struct hda_codec *codec,int idx); +void snd_hda_spdif_ctls_assign (struct hda_codec *codec,int idx,hda_nid_t nid);/* * Mixer
sound/pci/hda/hda_local.h +3 -1
@@ -212,7 +212,9 @@ int snd_hda_mixer_bind_tlv(struct snd_kcontrol *kcontrol, int op_flag,/* * SPDIF I/O */ -int snd_hda_create_spdif_out_ctls (struct hda_codec *codec,hda_nid_t nid); +int snd_hda_create_spdif_out_ctls (struct hda_codec *codec, +hda_nid_t associated_nid, +hda_nid_t cvt_nid);int snd_hda_create_spdif_in_ctls (struct hda_codec *codec,hda_nid_t nid);/*
sound/pci/hda/patch_analog.c +3 -1
@@ -213,7 +213,9 @@ static int ad198x_build_controls(struct hda_codec *codec)return err; }if (spec->multiout.dig_out_nid) { - err =snd_hda_create_spdif_out_ctls (codec, spec->multiout.dig_out_nid); + err =snd_hda_create_spdif_out_ctls (codec, + spec->multiout.dig_out_nid, + spec->multiout.dig_out_nid);if (err <0 )return err; err = snd_hda_create_spdif_share_sw(codec,
sound/pci/hda/patch_ca0110.c +2 -1
@@ -240,7 +240,8 @@ static int ca0110_build_controls(struct hda_codec *codec) }if (spec->dig_out) { - err =snd_hda_create_spdif_out_ctls (codec, spec->dig_out); + err =snd_hda_create_spdif_out_ctls (codec, spec->dig_out, + spec->dig_out);if (err <0 )return err; err =snd_hda_create_spdif_share_sw (codec, &spec->multiout);
sound/pci/hda/patch_cirrus.c +2 -1
@@ -821,7 +821,8 @@ static int build_digital_output(struct hda_codec *codec)if (!spec->multiout.dig_out_nid)return 0 ; - err =snd_hda_create_spdif_out_ctls (codec, spec->multiout.dig_out_nid); + err =snd_hda_create_spdif_out_ctls (codec, spec->multiout.dig_out_nid, + spec->multiout.dig_out_nid);if (err <0 )return err; err =snd_hda_create_spdif_share_sw (codec, &spec->multiout);
sound/pci/hda/patch_cmedia.c +3 -1
@@ -327,7 +327,9 @@ static int cmi9880_build_controls(struct hda_codec *codec)return err; }if (spec->multiout.dig_out_nid) { - err =snd_hda_create_spdif_out_ctls (codec, spec->multiout.dig_out_nid); + err =snd_hda_create_spdif_out_ctls (codec, + spec->multiout.dig_out_nid, + spec->multiout.dig_out_nid);if (err <0 )return err; err = snd_hda_create_spdif_share_sw(codec,
sound/pci/hda/patch_conexant.c +1 -0
@@ -510,6 +510,7 @@ static int conexant_build_controls(struct hda_codec *codec) }if (spec->multiout.dig_out_nid) { err =snd_hda_create_spdif_out_ctls (codec, + spec->multiout.dig_out_nid, spec->multiout.dig_out_nid);if (err <0 )return err;
sound/pci/hda/patch_hdmi.c +2 -1
@@ -1095,7 +1095,8 @@ static int generic_hdmi_build_controls(struct hda_codec *codec)int i;for (i =0 ; i < codec->num_pcms; i++) { - err =snd_hda_create_spdif_out_ctls (codec, spec->cvt[i]); + err =snd_hda_create_spdif_out_ctls (codec, spec->cvt[i], + spec->cvt[i]);if (err <0 )return err; }
sound/pci/hda/patch_realtek.c +1 -0
@@ -3217,6 +3217,7 @@ static int alc_build_controls(struct hda_codec *codec) }if (spec->multiout.dig_out_nid) { err =snd_hda_create_spdif_out_ctls (codec, + spec->multiout.dig_out_nid, spec->multiout.dig_out_nid);if (err <0 )return err;
sound/pci/hda/patch_sigmatel.c +3 -1
@@ -1112,7 +1112,9 @@ static int stac92xx_build_controls(struct hda_codec *codec) }if (spec->multiout.dig_out_nid) { - err =snd_hda_create_spdif_out_ctls (codec, spec->multiout.dig_out_nid); + err =snd_hda_create_spdif_out_ctls (codec, + spec->multiout.dig_out_nid, + spec->multiout.dig_out_nid);if (err <0 )return err; err = snd_hda_create_spdif_share_sw(codec,
sound/pci/hda/patch_via.c +1 -0
@@ -1497,6 +1497,7 @@ static int via_build_controls(struct hda_codec *codec)if (spec->multiout.dig_out_nid) { err =snd_hda_create_spdif_out_ctls (codec, + spec->multiout.dig_out_nid, spec->multiout.dig_out_nid);if (err <0 )return err;
Signature · 1 line
1.7.0.4
PATCH 4/6 ALSA: hda: Separate generic and non-generic implementations
In reply to Stephen WarrenA future change will significantly rework the generic implementation in order to support codecs with a different number of pins and converters. Isolate the more custom codec variants from this change by duplicating the small portions of generic code they share. This simplifies the later rework of that previously shared code, since we don't have to consider the more custom codecs, and also prevents support for those codecs from regressing.
--- sound/pci/hda/patch_hdmi.c | 75 ++++++++++++++++++++++++++++++++++++++----- 1 files changed, 66 insertions(+), 9 deletions(-)
sound/pci/hda/patch_hdmi.c +66 -9
@@ -1164,6 +1164,63 @@ static int patch_generic_hdmi(struct hda_codec *codec) }/* +* Shared non-generic implementations +*/ + +static int simple_playback_build_pcms (struct hda_codec *codec) +{ +struct hdmi_spec *spec = codec->spec; +struct hda_pcm *info = spec->pcm_rec; +int i; + + codec->num_pcms = spec->num_cvts; + codec->pcm_info = info; + +for (i =0 ; i < codec->num_pcms; i++, info++) { +unsigned int chans; +struct hda_pcm_stream *pstr; + + chans =get_wcaps (codec, spec->cvt[i]); + chans =get_wcaps_channels (chans); + + info->name = generic_hdmi_pcm_names[i]; + info->pcm_type =HDA_PCM_TYPE_HDMI ; + pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK ]; +snd_BUG_ON (!spec->pcm_playback); + *pstr = *spec->pcm_playback; + pstr->nid = spec->cvt[i]; +if (pstr->channels_max <=2 && chans && chans <=16 ) + pstr->channels_max = chans; + } + +return 0 ; +} + +static int simple_playback_build_controls (struct hda_codec *codec) +{ +struct hdmi_spec *spec = codec->spec; +int err; +int i; + +for (i =0 ; i < codec->num_pcms; i++) { + err =snd_hda_create_spdif_out_ctls (codec, + spec->cvt[i], + spec->cvt[i]); +if (err <0 ) +return err; + } + +return 0 ; +} + +static void simple_playback_free (struct hda_codec *codec) +{ +struct hdmi_spec *spec = codec->spec; + +kfree (spec); +} + +/* * Nvidia specific implementations */
@@ -1475,17 +1532,17 @@ static const struct hda_pcm_stream nvhdmi_pcm_playback_2ch = { };static const struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = { - .build_controls = generic_hdmi_build_controls, - .build_pcms = generic_hdmi_build_pcms, + .build_controls = simple_playback_build_controls, + .build_pcms = simple_playback_build_pcms, .init = nvhdmi_7x_init, - .free = generic_hdmi_free, + .free = simple_playback_free, };static const struct hda_codec_ops nvhdmi_patch_ops_2ch = { - .build_controls = generic_hdmi_build_controls, - .build_pcms = generic_hdmi_build_pcms, + .build_controls = simple_playback_build_controls, + .build_pcms = simple_playback_build_pcms, .init = nvhdmi_7x_init, - .free = generic_hdmi_free, + .free = simple_playback_free, };static int patch_nvhdmi_2ch (struct hda_codec *codec)
@@ -1596,10 +1653,10 @@ static int atihdmi_init(struct hda_codec *codec) }static const struct hda_codec_ops atihdmi_patch_ops = { - .build_controls = generic_hdmi_build_controls, - .build_pcms = generic_hdmi_build_pcms, + .build_controls = simple_playback_build_controls, + .build_pcms = simple_playback_build_pcms, .init = atihdmi_init, - .free = generic_hdmi_free, + .free = simple_playback_free, };
Signature · 1 line
1.7.0.4
PATCH 5/6 ALSA: hda: hdmi_eld_update_pcm_info: update a stream in place
In reply to Stephen WarrenA future change won't store an entire hda_pcm_stream just to represent the capabilities of a codec; a custom data-structure will be used. To ease that transition, modify hdmi_eld_update_pcm_info to expect the hda_pcm_stream to be pre-initialized with the codec's capabilities, and to update those capabilities in-place based on the ELD.
--- sound/pci/hda/hda_eld.c | 46 ++++++++++++++++++++++--------------------- sound/pci/hda/hda_local.h | 4 +- sound/pci/hda/patch_hdmi.c | 18 +++++++++------- 3 files changed, 36 insertions(+), 32 deletions(-)
sound/pci/hda/hda_eld.c +24 -22
@@ -580,43 +580,45 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)#endif /* CONFIG_PROC_FS */ /* update PCM info based on ELD */ -void hdmi_eld_update_pcm_info (struct hdmi_eld *eld,struct hda_pcm_stream *pcm, -struct hda_pcm_stream *codec_pars) +void snd_hdmi_eld_update_pcm_info (struct hdmi_eld *eld, +struct hda_pcm_stream *hinfo) { +u32 rates; +u64 formats; +unsigned int maxbps; +unsigned int channels_max;int i;/* assume basic audio support (the basic audio flag is not in ELD; * however, all audio capable sinks are required to support basic * audio) */ - pcm->rates =SNDRV_PCM_RATE_32000 |SNDRV_PCM_RATE_44100 |SNDRV_PCM_RATE_48000 ; - pcm->formats =SNDRV_PCM_FMTBIT_S16_LE ; - pcm->maxbps =16 ; - pcm->channels_max =2 ; + rates =SNDRV_PCM_RATE_32000 |SNDRV_PCM_RATE_44100 | +SNDRV_PCM_RATE_48000 ; + formats =SNDRV_PCM_FMTBIT_S16_LE ; + maxbps =16 ; + channels_max =2 ;for (i =0 ; i < eld->sad_count; i++) {struct cea_sad *a = &eld->sad[i]; - pcm->rates |= a->rates; -if (a->channels > pcm->channels_max) - pcm->channels_max = a->channels; + rates |= a->rates; +if (a->channels > channels_max) + channels_max = a->channels;if (a->format ==AUDIO_CODING_TYPE_LPCM ) {if (a->sample_bits &AC_SUPPCM_BITS_20 ) { - pcm->formats |=SNDRV_PCM_FMTBIT_S32_LE ; -if (pcm->maxbps <20 ) - pcm->maxbps =20 ; + formats |=SNDRV_PCM_FMTBIT_S32_LE ; +if (maxbps <20 ) + maxbps =20 ; }if (a->sample_bits &AC_SUPPCM_BITS_24 ) { - pcm->formats |=SNDRV_PCM_FMTBIT_S32_LE ; -if (pcm->maxbps <24 ) - pcm->maxbps =24 ; + formats |=SNDRV_PCM_FMTBIT_S32_LE ; +if (maxbps <24 ) + maxbps =24 ; } } } -if (!codec_pars) -return ; -/* restrict the parameters by the values the codec provides */ - pcm->rates &= codec_pars->rates; - pcm->formats &= codec_pars->formats; - pcm->channels_max =min (pcm->channels_max, codec_pars->channels_max); - pcm->maxbps =min (pcm->maxbps, codec_pars->maxbps); + hinfo->rates &= rates; + hinfo->formats &= formats; + hinfo->maxbps =min (hinfo->maxbps, maxbps); + hinfo->channels_max =min (hinfo->channels_max, channels_max); }
sound/pci/hda/hda_local.h +2 -2
@@ -641,8 +641,8 @@ struct hdmi_eld {int snd_hdmi_get_eld_size (struct hda_codec *codec,hda_nid_t nid);int snd_hdmi_get_eld (struct hdmi_eld *,struct hda_codec *,hda_nid_t );void snd_hdmi_show_eld (struct hdmi_eld *eld); -void hdmi_eld_update_pcm_info (struct hdmi_eld *eld,struct hda_pcm_stream *pcm, -struct hda_pcm_stream *codec_pars); +void snd_hdmi_eld_update_pcm_info (struct hdmi_eld *eld, +struct hda_pcm_stream *hinfo);#ifdef CONFIG_PROC_FS int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,
sound/pci/hda/patch_hdmi.c +10 -8
@@ -815,20 +815,22 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,if (!codec_pars->rates) *codec_pars = *hinfo; +/* Initially set the converter's capabilities */ + hinfo->channels_min = codec_pars->channels_min; + hinfo->channels_max = codec_pars->channels_max; + hinfo->rates = codec_pars->rates; + hinfo->formats = codec_pars->formats; + hinfo->maxbps = codec_pars->maxbps; + eld = &spec->sink_eld[idx];if (!static_hdmi_pcm && eld->eld_valid) { -hdmi_eld_update_pcm_info (eld, hinfo, codec_pars); +snd_hdmi_eld_update_pcm_info (eld, hinfo);if (hinfo->channels_min > hinfo->channels_max || !hinfo->rates || !hinfo->formats)return -ENODEV ; - }else { -/* fallback to the codec default */ - hinfo->channels_max = codec_pars->channels_max; - hinfo->rates = codec_pars->rates; - hinfo->formats = codec_pars->formats; - hinfo->maxbps = codec_pars->maxbps; } -/* store the updated parameters */ + +/* Store the updated parameters */ runtime->hw.channels_min = hinfo->channels_min; runtime->hw.channels_max = hinfo->channels_max; runtime->hw.formats = hinfo->formats;
Signature · 1 line
1.7.0.4
PATCH 6/6 ALSA: hda: HDMI: Support codecs with fewer cvts than pins
In reply to Stephen WarrenThe general concept of this change is to create a PCM device for each pin widget instead of each converter widget. Whenever a PCM is opened, a converter is dynamically selected to drive that pin based on those available for muxing into the pin.
The one thing this model doesn't support is a single PCM/converter sending audio to multiple pin widgets at once.
Note that this means that a struct hda_pcm_stream's nid variable is set to 0 except between a stream's open and cleanup calls. The dynamic de-assignment of converters to PCMs occurs within cleanup, not close, in order for it to co-incide with when controller stream IDs are cleaned up from converters.
While the PCM for a pin is not open, the pin is disabled (its widget control's PIN_OUT bit is cleared) so that if the currently routed converter is used to drive a different PCM/pin, that audio does not leak out over a disabled pin.
We use the recently added SPDIF virtualization feature in order to create SPDIF controls for each pin widget instead of each converter widget, so that state is specific to a PCM.
In order to support this, a number of more mechanical changes are made:
* s/nid/pin_nid/ or s/nid/cvt_nid/ in many places in order to make it clear exactly what the code is dealing with.
* We now have per_pin and per_cvt arrays in hdmi_spec to store relevant data. In particular, we store a converter's capabilities in the per_cvt entry, rather than relying on a combination of codec_pcm_pars and the struct hda_pcm_stream.
* ELD-related workarounds were removed from hdmi_channel_allocation into hdmi_instrinsic in order to simplifiy infoframe calculations and remove HW dependencies.
* Various functions only apply to a single pin, since there is now only 1 pin per PCM. For example, hdmi_setup_infoframe, hdmi_setup_stream.
* hdmi_add_pin and hdmi_add_cvt are more oriented at pure codec parsing and data retrieval, rather than determining which pins/converters are to be used for creating PCMs.
This is quite a large change; it may be appropriate to simply read the result of the patch rather than the diffs. Some small parts of the change might be separable into different patches, but I think the bulk of the change will probably always be one large patch. Hopefully the change isn't too opaque!
This has been tested on:
* NVIDIA GeForce 400 series discrete graphics card. This model has the classical 1:1:1 codec:converter:pcm widget model. Tested stereo PCM audio to a PC monitor that supports audio.
* NVIDIA GeForce 520 discrete graphics card. This model is the new 1 codec n converters m pins m>n model. Tested stereo PCM audio to a PC monitor that supports audio.
* NVIDIA GeForce 400 series laptop graphics chip. This model has the classical 1:1:1 codec:converter:pcm widget model. Tested stereo PCM, multi-channel PCM, and AC3 pass-through to an AV receiver.
* Intel Ibex Peak laptop. This model is the new 1 codec n converters m pins m>n model. Tested stereo PCM, multi-channel PCM, and AC3 pass- through to an AV receiver.
Note that I'm not familiar at all with AC3 pass-through. Hence, I may not have covered all possible mechanisms that are applicable here. I do know that my receiver definitely received AC3, not decoded PCM. I tested with mplayer's "-afm hwac3" and/or "-af lavcac3enc" options, and alsa a WAV file that I believe has AC3 content rather than PCM.
I also tested:
* Play a stream
* Mute while playing
* Stop stream
* Play some other streams to re-assign the converter to a different pin, PCM, set of SPDIF controls, ... hence hopefully triggering cleanup for the original PCM.
* Unmute original stream while not playing
* Play a stream on the original pin/PCM.
This was to test SPDIF control virtualization.
--- sound/pci/hda/hda_codec.c | 3 +- sound/pci/hda/hda_codec.h | 2 + sound/pci/hda/patch_hdmi.c | 611 +++++++++++++++++++++++++------------------- 3 files changed, 350 insertions(+), 266 deletions(-)
sound/pci/hda/hda_codec.c +2 -1
@@ -3412,7 +3412,7 @@ static unsigned int query_stream_param(struct hda_codec *codec, hda_nid_t nid)* * Returns 0 if successful, otherwise a negative error code. */ -static int snd_hda_query_supported_pcm (struct hda_codec *codec,hda_nid_t nid, +int snd_hda_query_supported_pcm (struct hda_codec *codec,hda_nid_t nid,u32 *ratesp,u64 *formatsp,unsigned int *bpsp) {unsigned int i, val, wcaps;
@@ -3504,6 +3504,7 @@ static int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,return 0 ; } +EXPORT_SYMBOL_HDA (snd_hda_query_supported_pcm);/** * snd_hda_is_supported_format - Check the validity of the format
sound/pci/hda/hda_codec.h +2 -0
@@ -903,6 +903,8 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid, hda_nid_t *start_id);int snd_hda_get_connections (struct hda_codec *codec,hda_nid_t nid,hda_nid_t *conn_list,int max_conns); +int snd_hda_query_supported_pcm (struct hda_codec *codec,hda_nid_t nid, +u32 *ratesp,u64 *formatsp,unsigned int *bpsp);struct hda_verb {hda_nid_t nid;
sound/pci/hda/patch_hdmi.c +346 -265
934 lines not on this page · raw message
Signature · 1 line
1.7.0.4
At Wed, 1 Jun 2011 11:14:15 -0600,
Quoted 11 lines · Stephen Warren
This patchset implements a PCM-per-pin-widget model for all HDMI codecs that use the generic codec support. For most existing codecs, there is 1 pin and 1 converter per codec, so this change should have no functional impact. For some codecs (e.g. GeForce 520, Intel Ibex Peak) there are fewer converters than pins, and the default routing is for all pins to be mux'd from a single codec, so this patch allows:
a) Multiple PCMs to be used at once (1 per converter). Previously, only 1 PCM was created due to the default muxing.
Quoted 8 lines
b) A direct mapping from PCM device to pin, and hence to ELD data and connected monitor. This should enable simpler/better decisions re: which audio formats are supported for that PCM, since only 1 ELD has to be considered (previously, I think the ELDs other than from the first pin were simply ignored)
The very first change in the series is actually somewhat unrelated, but I noticed it while working on this, and I believe it's a correct change.
Thanks for the patches. Through a quick glance, all look OK to me. I'm going to try to review more and apply the patches in the next week.
Takashi
Quoted 25 lines
Stephen Warren (6):
ALSA: hda: Gate ELD usage only by whether ELD is valid
ALSA: hda: Allow multple SPDIF controls per codec
ALSA: hda: Virtualize SPDIF out controls
ALSA: hda: Separate generic and non-generic implementations
ALSA: hda:hdmi_eld_update_pcm_info: update a stream in place
ALSA: hda: HDMI: Support codecs with fewer cvts than pinssound/pci/hda/hda_codec.c | 139 ++++++--- sound/pci/hda/hda_codec.h | 16 +- sound/pci/hda/hda_eld.c | 46 ++-- sound/pci/hda/hda_intel.c | 5 +- sound/pci/hda/hda_local.h | 8 +- sound/pci/hda/patch_analog.c | 4 +- sound/pci/hda/patch_ca0110.c | 3 +- sound/pci/hda/patch_cirrus.c | 3 +- sound/pci/hda/patch_cmedia.c | 4 +- sound/pci/hda/patch_conexant.c | 1 + sound/pci/hda/patch_hdmi.c | 704 ++++++++++++++++++++++++---------------- sound/pci/hda/patch_realtek.c | 1 + sound/pci/hda/patch_sigmatel.c | 4 +- sound/pci/hda/patch_via.c | 13 +- 14 files changed, 594 insertions(+), 357 deletions(-)
At Fri, 03 Jun 2011 18:11:40 +0200,
Quoted 20 lines · Takashi Iwai
At Wed, 1 Jun 2011 11:14:15 -0600,
Quoted 17 lines · Stephen Warren
This patchset implements a PCM-per-pin-widget model for all HDMI codecs that use the generic codec support. For most existing codecs, there is 1 pin and 1 converter per codec, so this change should have no functional impact. For some codecs (e.g. GeForce 520, Intel Ibex Peak) there are fewer converters than pins, and the default routing is for all pins to be mux'd from a single codec, so this patch allows:
a) Multiple PCMs to be used at once (1 per converter). Previously, only 1 PCM was created due to the default muxing.
b) A direct mapping from PCM device to pin, and hence to ELD data and connected monitor. This should enable simpler/better decisions re: which audio formats are supported for that PCM, since only 1 ELD has to be considered (previously, I think the ELDs other than from the first pin were simply ignored)
Quoted 5 lines
Quoted 2 lines
The very first change in the series is actually somewhat unrelated, but I noticed it while working on this, and I believe it's a correct change.
Thanks for the patches. Through a quick glance, all look OK to me. I'm going to try to review more and apply the patches in the next week.
OK, now applied all patches to topic/hda branch and merged to master and for-next. Let's see what happens.
thanks,
Takashi
Re: [PATCH 1/1] Added patch file and Makefile entry for CA0132 HDA codec
In reply to Takashi IwaiThank you very much for the feedback - we've modified the patch following your recommendations:
- moved the patch to the alsa-kernel git tree
- included the Kconfig change in the patch
- tidied up the mutex calls and brought the number of access retries down.
Any comments welcome, please let us know if anything should be changed further.
Thanks,
Ian
sound/pci/hda/Kconfig +13 -0
@@ -171,6 +171,19 @@ config SND_HDA_CODEC_CA0110 snd-hda-codec-ca0110. This module is automatically loaded at probing. +config SND_HDA_CODEC_CA0132 + bool "Build Creative CA0132 codec support" + depends on SND_HDA_INTEL + default y + help + Say Y here to include Creative CA0132 codec support in + snd-hda-intel driver. + + When the HD-audio driver is built as a module, the codec + support code is also built as another module, + snd-hda-codec-ca0132. + This module is automatically loaded at probing. + config SND_HDA_CODEC_CMEDIA bool "Build C-Media HD-audio codec support" default y
sound/pci/hda/Makefile +4 -0
@@ -13,6 +13,7 @@ snd-hda-codec-idt-objs := patch_sigmatel.o snd-hda-codec-si3054-objs := patch_si3054.o snd-hda-codec-cirrus-objs := patch_cirrus.o snd-hda-codec-ca0110-objs := patch_ca0110.o +snd-hda-codec-ca0132-objs := patch_ca0132.o snd-hda-codec-conexant-objs := patch_conexant.o snd-hda-codec-via-objs := patch_via.o snd-hda-codec-hdmi-objs := patch_hdmi.o hda_eld.o
@@ -42,6 +43,9 @@ endif ifdef CONFIG_SND_HDA_CODEC_CA0110 obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0110.o endif +ifdef CONFIG_SND_HDA_CODEC_CA0132 +obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-ca0132.o +endif ifdef CONFIG_SND_HDA_CODEC_CONEXANT obj-$(CONFIG_SND_HDA_INTEL) += snd-hda-codec-conexant.o endif
sound/pci/hda/patch_ca0132.c new file +1142 -0
1,142 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Re: [PATCH 1/1] Added patch file and Makefile entry for CA0132 HDA codec
At Tue, 7 Jun 2011 17:06:25 -0700,
Quoted 6 lines · Ian Minett
Thank you very much for the feedback - we've modified the patch following your recommendations:
- moved the patch to the alsa-kernel git tree
- included theKconfigchange in the patch
- tidied up the mutex calls and brought the number of access retries down.
Thanks for the updates!
The code looks almost good for merge, but just a few things. See below.
Quoted 6 lines
Any comments welcome, please let us know if anything should be changed further.
Thanks,
IanSigned-off-by Ian Minett <[email protected]>
Please give the changelog text to include whenever you re-submit the patch.
Quoted 6 lines
sound/pci/hda/patch_ca0132.c new file +6
-0+static int chipio_write_address (struct hda_codec *codec, +unsigned int chip_addx) +{ +unsigned int res =0 ; +int retry =50 ; +
sound/pci/hda/patch_ca0132.c line 357
Quoted 10 lines
sound/pci/hda/patch_ca0132.c new file +10
-0+/* send low 16 bits of the address */ +do { + res =snd_hda_codec_read (codec,WIDGET_CHIP_CTRL ,0 , +HDA_SHORT_CMD_VENDOR_CHIP_IO_ADDRESS_LOW , + chip_addx &0xffff ); + retry--; + }while (res !=HDA_STATUS_VENDOR_CHIP_IO_OK && retry); + +if (!retry) +return -EIO ;
I'd write a helper function including this loop, e.g.
static int chipio_send(struct hda_codec *codec, unsigned int reg,
unsigned int data)
{
unsigned int res;
int retry = 50;
do {
res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, reg, data);
if (res == HDA_STATUS_VENDOR_CHIP_IO_OK)
return 0;
} while (--retry);
return -EIO;
}This code chunk appears repeatedly in the following codes.
sound/pci/hda/patch_ca0132.c line 758
Quoted 12 lines
sound/pci/hda/patch_ca0132.c new file +12
-0+static int ca0132_hp_switch_put (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct hda_codec *codec =snd_kcontrol_chip (kcontrol); +struct ca0132_spec *spec = codec->spec; +long *valp = ucontrol->value.integer.value; +unsigned int data; +int err; + +/* any change? */ +if (spec->curr_hp_switch == *valp) +return 0 ;
You need to wake up the controller/codec appropriately in the control callback if the hardware access is needed. Call snd_hda_power_up() / snd_hda_power_down() appropriately. In you case, call snd_hda_power_up() at this point, and call snd_hda_power_down() at exit of the function.
sound/pci/hda/patch_ca0132.c line 977
Quoted 5 lines
sound/pci/hda/patch_ca0132.c new file +5
-0+/* +* refresh widget caps that stored in cache +*/ +static void ca0132_refresh_widget_caps (struct hda_codec *codec) +{
Oh, this is a tricky part I overlooked at the previous time. This looks like a dead code, though. Is it still needed?
sound/pci/hda/patch_ca0132.c line 986
Quoted 9 lines
sound/pci/hda/patch_ca0132.c new file +9
-0+int i; +hda_nid_t nid, start; + + start = nid = codec->start_nid; +snd_printd ("ca0132_refresh_widget_caps: start_nid=%d\n" , start); +for (i =0 ; i < codec->num_nodes; i++, nid++) { + codec->wcaps[i] =snd_hda_param_read (codec, nid, +AC_PAR_AUDIO_WIDGET_CAP ); +snd_printd ("wcaps[0x%02x]=0x%x\n" , i+start, codec->wcaps[i]);
Don't use snd_printd(). CONFIG_SND_DEBUG is usually turned on by most distros, so it'd be annoying to see this at each time. Use snd_printdd() if any.
sound/pci/hda/patch_ca0132.c line 993
Quoted 6 lines
sound/pci/hda/patch_ca0132.c new file +6
-0+ } +} +static void ca0132_set_ct_ext (struct hda_codec *codec,int enable) +{ +/* Set Creative extension */ +snd_printd ("SET CREATIVE EXTENSION\n" );
Use snd_printdd().
sound/pci/hda/patch_ca0132.c line 997
Quoted 4 lines
sound/pci/hda/patch_ca0132.c new file +4
-0+snd_hda_codec_write (codec,WIDGET_CHIP_CTRL ,0 , +HDA_LONG_CMD_VENDOR_CHIP_IO_CT_EXTENSIONS_ENABLE , + enable); +msleep (20 );
Isn't this command needed when you recover from S3/S4 or powersave? If yes, this should be called in the init callback instead of patch_ca0132().
Quoted 44 lines
sound/pci/hda/patch_ca0132.c new file +44
-0+static void ca0132_init_chip (struct hda_codec *codec) +{ +struct ca0132_spec *spec = codec->spec; + +mutex_init (&spec->chipio_mutex); +} + +static void ca0132_exit_chip (struct hda_codec *codec) +{ +/* put any chip cleanup stuffs here. */ +} + +static int ca0132_init (struct hda_codec *codec) +{ +struct ca0132_spec *spec = codec->spec; +struct auto_pin_cfg *cfg = &spec->autocfg; +int i; + +for (i =0 ; i < spec->multiout.num_dacs; i++) { +init_output (codec, spec->out_pins[i], + spec->multiout.dac_nids[i]); + } +init_output (codec, cfg->hp_pins[0 ], spec->hp_dac); +init_output (codec, cfg->dig_out_pins[0 ], spec->dig_out); + +for (i =0 ; i < spec->num_inputs; i++) +init_input (codec, spec->input_pins[i], spec->adcs[i]); + +init_input (codec, cfg->dig_in_pin, spec->dig_in); + +return 0 ; +} + + +static void ca0132_free (struct hda_codec *codec) +{ +ca0132_exit_chip (codec); +kfree (codec->spec); +} + +static struct hda_codec_ops ca0132_patch_ops = { + .build_controls = ca0132_build_controls, + .build_pcms = ca0132_build_pcms, + .init = ca0132_init,
sound/pci/hda/patch_ca0132.c line 1096
Quoted 10 lines
sound/pci/hda/patch_ca0132.c new file +10
-0+ .free = ca0132_free, +}; + + + +static int patch_ca0132 (struct hda_codec *codec) +{ +struct ca0132_spec *spec; + +snd_printd ("patch_ca0132\n" );
Use snd_printdd().
sound/pci/hda/patch_ca0132.c line 1098
Quoted 1 line
sound/pci/hda/patch_ca0132.c new file +1
-0+ spec =kzalloc (sizeof (*spec),GFP_KERNEL );
Missing error check.
sound/pci/hda/patch_ca0132.c line 1099
Quoted 1 line
sound/pci/hda/patch_ca0132.c new file +1
-0+memset ((void *)spec,0 ,sizeof (*spec));
No need for cast.
thanks,
Takashi