Commit 96f845de authored by Takashi Iwai's avatar Takashi Iwai

ALSA: hda - Create "Digital Mic Capture Volume" correctly for IDT codecs

So far, the digital mic capture volume wasn't created.  This is because
IDT codecs have output amps for digital mics, not input amps, while
input amps should be used for other analog pins.  Thus the automatic
capture volume creation should check both directions for digital mics.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 286f5875
...@@ -3580,21 +3580,30 @@ static int get_connection_index(struct hda_codec *codec, hda_nid_t mux, ...@@ -3580,21 +3580,30 @@ static int get_connection_index(struct hda_codec *codec, hda_nid_t mux,
} }
/* create a volume assigned to the given pin (only if supported) */ /* create a volume assigned to the given pin (only if supported) */
/* return 1 if the volume control is created */
static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid, static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
const char *label) const char *label, int direction)
{ {
unsigned int caps, nums; unsigned int caps, nums;
char name[32]; char name[32];
int err;
if (!(get_wcaps(codec, nid) & AC_WCAP_IN_AMP)) if (direction == HDA_OUTPUT)
caps = AC_WCAP_OUT_AMP;
else
caps = AC_WCAP_IN_AMP;
if (!(get_wcaps(codec, nid) & caps))
return 0; return 0;
caps = query_amp_caps(codec, nid, HDA_OUTPUT); caps = query_amp_caps(codec, nid, direction);
nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT; nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
if (!nums) if (!nums)
return 0; return 0;
snprintf(name, sizeof(name), "%s Capture Volume", label); snprintf(name, sizeof(name), "%s Capture Volume", label);
return stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name, err = stac92xx_add_control(codec->spec, STAC_CTL_WIDGET_VOL, name,
HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT)); HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
if (err < 0)
return err;
return 1;
} }
/* create playback/capture controls for input pins on dmic capable codecs */ /* create playback/capture controls for input pins on dmic capable codecs */
...@@ -3643,9 +3652,15 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec, ...@@ -3643,9 +3652,15 @@ static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
else else
label = stac92xx_dmic_labels[dimux->num_items]; label = stac92xx_dmic_labels[dimux->num_items];
err = create_elem_capture_vol(codec, nid, label); err = create_elem_capture_vol(codec, nid, label, HDA_INPUT);
if (err < 0) if (err < 0)
return err; return err;
if (!err) {
err = create_elem_capture_vol(codec, nid, label,
HDA_OUTPUT);
if (err < 0)
return err;
}
dimux->items[dimux->num_items].label = label; dimux->items[dimux->num_items].label = label;
dimux->items[dimux->num_items].index = index; dimux->items[dimux->num_items].index = index;
...@@ -3766,7 +3781,8 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const ...@@ -3766,7 +3781,8 @@ static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const
continue; continue;
err = create_elem_capture_vol(codec, nid, err = create_elem_capture_vol(codec, nid,
auto_pin_cfg_labels[i]); auto_pin_cfg_labels[i],
HDA_INPUT);
if (err < 0) if (err < 0)
return err; return err;
......
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