diff options
author | Lydia Wang <lydiawang@viatech.com.cn> | 2009-10-10 07:08:31 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2009-10-11 11:58:22 -0400 |
commit | 6369bcfccb57da28ad3e09b25fecd841a415ae95 (patch) | |
tree | d669ea29ac608b08741e18f7ad58e5701a83473e /sound/pci/hda/patch_via.c | |
parent | 4483a2f5907fa824bd6384c36fdcee9777cab1b9 (diff) |
ALSA: HDA VIA: Replace MIC_BOOST_VOLUME.
With snd_hda_override_amp_caps.
Signed-off-by: Lydia Wang <lydiawang@viatech.com.cn>
Signed-off-by: Logan Li <loganli@viatech.com.cn>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_via.c')
-rw-r--r-- | sound/pci/hda/patch_via.c | 72 |
1 files changed, 15 insertions, 57 deletions
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index f9702a17fc16..4b7cd5971701 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -197,46 +197,6 @@ enum { | |||
197 | AUTO_SEQ_SIDE | 197 | AUTO_SEQ_SIDE |
198 | }; | 198 | }; |
199 | 199 | ||
200 | /* Some VT1708S based boards gets the micboost setting wrong, so we have | ||
201 | * to apply some brute-force and re-write the TLV's by software. */ | ||
202 | static int mic_boost_tlv(struct snd_kcontrol *kcontrol, int op_flag, | ||
203 | unsigned int size, unsigned int __user *_tlv) | ||
204 | { | ||
205 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
206 | hda_nid_t nid = get_amp_nid(kcontrol); | ||
207 | |||
208 | if (get_codec_type(codec) == VT1708S | ||
209 | && (nid == 0x1a || nid == 0x1e)) { | ||
210 | if (size < 4 * sizeof(unsigned int)) | ||
211 | return -ENOMEM; | ||
212 | if (put_user(1, _tlv)) /* SNDRV_CTL_TLVT_DB_SCALE */ | ||
213 | return -EFAULT; | ||
214 | if (put_user(2 * sizeof(unsigned int), _tlv + 1)) | ||
215 | return -EFAULT; | ||
216 | if (put_user(0, _tlv + 2)) /* offset = 0 */ | ||
217 | return -EFAULT; | ||
218 | if (put_user(1000, _tlv + 3)) /* step size = 10 dB */ | ||
219 | return -EFAULT; | ||
220 | } | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int mic_boost_volume_info(struct snd_kcontrol *kcontrol, | ||
225 | struct snd_ctl_elem_info *uinfo) | ||
226 | { | ||
227 | struct hda_codec *codec = snd_kcontrol_chip(kcontrol); | ||
228 | hda_nid_t nid = get_amp_nid(kcontrol); | ||
229 | |||
230 | if (get_codec_type(codec) == VT1708S | ||
231 | && (nid == 0x1a || nid == 0x1e)) { | ||
232 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
233 | uinfo->count = 2; | ||
234 | uinfo->value.integer.min = 0; | ||
235 | uinfo->value.integer.max = 3; | ||
236 | } | ||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static void analog_low_current_mode(struct hda_codec *codec, int stream_idle); | 200 | static void analog_low_current_mode(struct hda_codec *codec, int stream_idle); |
241 | static void set_jack_power_state(struct hda_codec *codec); | 201 | static void set_jack_power_state(struct hda_codec *codec); |
242 | static int is_aa_path_mute(struct hda_codec *codec); | 202 | static int is_aa_path_mute(struct hda_codec *codec); |
@@ -3063,29 +3023,15 @@ static int patch_vt1708B_4ch(struct hda_codec *codec) | |||
3063 | 3023 | ||
3064 | /* Patch for VT1708S */ | 3024 | /* Patch for VT1708S */ |
3065 | 3025 | ||
3066 | /* VT1708S software backdoor based override for buggy hardware micboost | ||
3067 | * setting */ | ||
3068 | #define MIC_BOOST_VOLUME(xname, nid) { \ | ||
3069 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ | ||
3070 | .name = xname, \ | ||
3071 | .index = 0, \ | ||
3072 | .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ | ||
3073 | SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ | ||
3074 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | ||
3075 | .info = mic_boost_volume_info, \ | ||
3076 | .get = snd_hda_mixer_amp_volume_get, \ | ||
3077 | .put = snd_hda_mixer_amp_volume_put, \ | ||
3078 | .tlv = { .c = mic_boost_tlv }, \ | ||
3079 | .private_value = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT) } | ||
3080 | |||
3081 | /* capture mixer elements */ | 3026 | /* capture mixer elements */ |
3082 | static struct snd_kcontrol_new vt1708S_capture_mixer[] = { | 3027 | static struct snd_kcontrol_new vt1708S_capture_mixer[] = { |
3083 | HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT), | 3028 | HDA_CODEC_VOLUME("Capture Volume", 0x13, 0x0, HDA_INPUT), |
3084 | HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT), | 3029 | HDA_CODEC_MUTE("Capture Switch", 0x13, 0x0, HDA_INPUT), |
3085 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT), | 3030 | HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x14, 0x0, HDA_INPUT), |
3086 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT), | 3031 | HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x14, 0x0, HDA_INPUT), |
3087 | MIC_BOOST_VOLUME("Mic Boost Capture Volume", 0x1A), | 3032 | HDA_CODEC_VOLUME("Mic Boost Capture Volume", 0x1A, 0x0, HDA_INPUT), |
3088 | MIC_BOOST_VOLUME("Front Mic Boost Capture Volume", 0x1E), | 3033 | HDA_CODEC_VOLUME("Front Mic Boost Capture Volume", 0x1E, 0x0, |
3034 | HDA_INPUT), | ||
3089 | { | 3035 | { |
3090 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 3036 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
3091 | /* The multiple "Capture Source" controls confuse alsamixer | 3037 | /* The multiple "Capture Source" controls confuse alsamixer |
@@ -3457,6 +3403,16 @@ static struct hda_amp_list vt1708S_loopbacks[] = { | |||
3457 | }; | 3403 | }; |
3458 | #endif | 3404 | #endif |
3459 | 3405 | ||
3406 | static void override_mic_boost(struct hda_codec *codec, hda_nid_t pin, | ||
3407 | int offset, int num_steps, int step_size) | ||
3408 | { | ||
3409 | snd_hda_override_amp_caps(codec, pin, HDA_INPUT, | ||
3410 | (offset << AC_AMPCAP_OFFSET_SHIFT) | | ||
3411 | (num_steps << AC_AMPCAP_NUM_STEPS_SHIFT) | | ||
3412 | (step_size << AC_AMPCAP_STEP_SIZE_SHIFT) | | ||
3413 | (0 << AC_AMPCAP_MUTE_SHIFT)); | ||
3414 | } | ||
3415 | |||
3460 | static int patch_vt1708S(struct hda_codec *codec) | 3416 | static int patch_vt1708S(struct hda_codec *codec) |
3461 | { | 3417 | { |
3462 | struct via_spec *spec; | 3418 | struct via_spec *spec; |
@@ -3493,6 +3449,8 @@ static int patch_vt1708S(struct hda_codec *codec) | |||
3493 | spec->adc_nids = vt1708S_adc_nids; | 3449 | spec->adc_nids = vt1708S_adc_nids; |
3494 | spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); | 3450 | spec->num_adc_nids = ARRAY_SIZE(vt1708S_adc_nids); |
3495 | get_mux_nids(codec); | 3451 | get_mux_nids(codec); |
3452 | override_mic_boost(codec, 0x1a, 0, 3, 40); | ||
3453 | override_mic_boost(codec, 0x1e, 0, 3, 40); | ||
3496 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; | 3454 | spec->mixers[spec->num_mixers] = vt1708S_capture_mixer; |
3497 | spec->num_mixers++; | 3455 | spec->num_mixers++; |
3498 | } | 3456 | } |