aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_generic.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-12-20 05:48:54 -0500
committerTakashi Iwai <tiwai@suse.de>2013-01-12 02:34:02 -0500
commit47d46abba2d2046c6bfa37eeb583269d43e659ad (patch)
tree64443d7b1be721820804768b150ccd02583098ae /sound/pci/hda/hda_generic.c
parent84e3908dc837b9d3314a92d8fda12a0ce3946714 (diff)
ALSA: hda - Add / fix comments about capture vol/sw controls in hda_generic.c
A bit of details won't hurt. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_generic.c')
-rw-r--r--sound/pci/hda/hda_generic.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 3e818b6aa5b0..f5eb57cdac2d 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -1877,10 +1877,6 @@ static int mux_enum_put(struct snd_kcontrol *kcontrol,
1877 ucontrol->value.enumerated.item[0]); 1877 ucontrol->value.enumerated.item[0]);
1878} 1878}
1879 1879
1880/*
1881 * capture volume and capture switch ctls
1882 */
1883
1884static const struct snd_kcontrol_new cap_src_temp = { 1880static const struct snd_kcontrol_new cap_src_temp = {
1885 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1881 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1886 .name = "Input Source", 1882 .name = "Input Source",
@@ -1889,9 +1885,14 @@ static const struct snd_kcontrol_new cap_src_temp = {
1889 .put = mux_enum_put, 1885 .put = mux_enum_put,
1890}; 1886};
1891 1887
1888/*
1889 * capture volume and capture switch ctls
1890 */
1891
1892typedef int (*put_call_t)(struct snd_kcontrol *kcontrol, 1892typedef int (*put_call_t)(struct snd_kcontrol *kcontrol,
1893 struct snd_ctl_elem_value *ucontrol); 1893 struct snd_ctl_elem_value *ucontrol);
1894 1894
1895/* call the given amp update function for all amps in the imux list at once */
1895static int cap_put_caller(struct snd_kcontrol *kcontrol, 1896static int cap_put_caller(struct snd_kcontrol *kcontrol,
1896 struct snd_ctl_elem_value *ucontrol, 1897 struct snd_ctl_elem_value *ucontrol,
1897 put_call_t func, int type) 1898 put_call_t func, int type)
@@ -1905,6 +1906,10 @@ static int cap_put_caller(struct snd_kcontrol *kcontrol,
1905 imux = &spec->input_mux; 1906 imux = &spec->input_mux;
1906 adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); 1907 adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1907 mutex_lock(&codec->control_mutex); 1908 mutex_lock(&codec->control_mutex);
1909 /* we use the cache-only update at first since multiple input paths
1910 * may shared the same amp; by updating only caches, the redundant
1911 * writes to hardware can be reduced.
1912 */
1908 codec->cached_write = 1; 1913 codec->cached_write = 1;
1909 for (i = 0; i < imux->num_items; i++) { 1914 for (i = 0; i < imux->num_items; i++) {
1910 path = snd_hda_get_nid_path(codec, spec->imux_pins[i], 1915 path = snd_hda_get_nid_path(codec, spec->imux_pins[i],
@@ -1919,7 +1924,7 @@ static int cap_put_caller(struct snd_kcontrol *kcontrol,
1919 error: 1924 error:
1920 codec->cached_write = 0; 1925 codec->cached_write = 0;
1921 mutex_unlock(&codec->control_mutex); 1926 mutex_unlock(&codec->control_mutex);
1922 snd_hda_codec_flush_amp_cache(codec); 1927 snd_hda_codec_flush_amp_cache(codec); /* flush the updates */
1923 if (err >= 0 && spec->cap_sync_hook) 1928 if (err >= 0 && spec->cap_sync_hook)
1924 spec->cap_sync_hook(codec); 1929 spec->cap_sync_hook(codec);
1925 return err; 1930 return err;