Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: hda/ca0132 - Add ZxR 600 ohm gain control

This patch adds a control for 600 ohm gain on the Sound Blaster ZxR.

Signed-off-by: Connor McAdams <conmanx360@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Connor McAdams and committed by
Takashi Iwai
d51434d4 76dea4db

+42 -2
+42 -2
sound/pci/hda/patch_ca0132.c
··· 154 154 SMART_VOLUME_ENUM, 155 155 MIC_BOOST_ENUM, 156 156 AE5_HEADPHONE_GAIN_ENUM, 157 - AE5_SOUND_FILTER_ENUM 157 + AE5_SOUND_FILTER_ENUM, 158 + ZXR_HEADPHONE_GAIN 158 159 #define EFFECTS_COUNT (EFFECT_END_NID - EFFECT_START_NID) 159 160 }; 160 161 ··· 1032 1031 /* AE-5 Control values */ 1033 1032 unsigned char ae5_headphone_gain_val; 1034 1033 unsigned char ae5_filter_val; 1035 - 1034 + /* ZxR Control Values */ 1035 + unsigned char zxr_gain_set; 1036 1036 1037 1037 struct hda_codec *codec; 1038 1038 struct delayed_work unsol_hp_work; ··· 4144 4142 } 4145 4143 4146 4144 static int ae5_headphone_gain_set(struct hda_codec *codec, long val); 4145 + static int zxr_headphone_gain_set(struct hda_codec *codec, long val); 4147 4146 static int ca0132_effects_set(struct hda_codec *codec, hda_nid_t nid, long val); 4148 4147 4149 4148 static void ae5_mmio_select_out(struct hda_codec *codec) ··· 4181 4178 ca0113_mmio_gpio_set(codec, 2, true); 4182 4179 ca0113_mmio_gpio_set(codec, 3, true); 4183 4180 ca0113_mmio_gpio_set(codec, 5, false); 4181 + zxr_headphone_gain_set(codec, 0); 4184 4182 chipio_set_control_param(codec, 0x0d, 0x24); 4185 4183 break; 4186 4184 case QUIRK_R3DI: ··· 4215 4211 ca0113_mmio_gpio_set(codec, 2, false); 4216 4212 ca0113_mmio_gpio_set(codec, 3, false); 4217 4213 ca0113_mmio_gpio_set(codec, 5, true); 4214 + zxr_headphone_gain_set(codec, spec->zxr_gain_set); 4218 4215 chipio_set_control_param(codec, 0x0d, 0x21); 4219 4216 break; 4220 4217 case QUIRK_R3DI: ··· 4250 4245 ca0113_mmio_gpio_set(codec, 2, true); 4251 4246 ca0113_mmio_gpio_set(codec, 3, true); 4252 4247 ca0113_mmio_gpio_set(codec, 5, false); 4248 + zxr_headphone_gain_set(codec, 0); 4253 4249 chipio_set_control_param(codec, 0x0d, 0x24); 4254 4250 break; 4255 4251 case QUIRK_R3DI: ··· 5025 5019 return 0; 5026 5020 } 5027 5021 5022 + /* 5023 + * gpio pin 1 is a relay that switches on/off, apparently setting the headphone 5024 + * amplifier to handle a 600 ohm load. 5025 + */ 5026 + static int zxr_headphone_gain_set(struct hda_codec *codec, long val) 5027 + { 5028 + ca0113_mmio_gpio_set(codec, 1, val); 5029 + 5030 + return 0; 5031 + } 5032 + 5028 5033 static int ca0132_vnode_switch_set(struct snd_kcontrol *kcontrol, 5029 5034 struct snd_ctl_elem_value *ucontrol) 5030 5035 { ··· 5794 5777 goto exit; 5795 5778 } 5796 5779 5780 + if (nid == ZXR_HEADPHONE_GAIN) { 5781 + spec->zxr_gain_set = *valp; 5782 + if (spec->cur_out_type == HEADPHONE_OUT) 5783 + changed = zxr_headphone_gain_set(codec, *valp); 5784 + else 5785 + changed = 0; 5786 + 5787 + goto exit; 5788 + } 5789 + 5797 5790 exit: 5798 5791 snd_hda_power_down(codec); 5799 5792 return changed; ··· 6212 6185 snd_ctl_new1(&knew, codec)); 6213 6186 } 6214 6187 6188 + static int zxr_add_headphone_gain_switch(struct hda_codec *codec) 6189 + { 6190 + struct snd_kcontrol_new knew = 6191 + CA0132_CODEC_MUTE_MONO("ZxR: 600 Ohm Gain", 6192 + ZXR_HEADPHONE_GAIN, 1, HDA_OUTPUT); 6193 + 6194 + return snd_hda_ctl_add(codec, ZXR_HEADPHONE_GAIN, 6195 + snd_ctl_new1(&knew, codec)); 6196 + } 6197 + 6215 6198 /* 6216 6199 * Need to create slave controls for the alternate codecs that have surround 6217 6200 * capabilities. ··· 6452 6415 ae5_add_headphone_gain_enum(codec); 6453 6416 ae5_add_sound_filter_enum(codec); 6454 6417 } 6418 + 6419 + if (spec->quirk == QUIRK_ZXR) 6420 + zxr_add_headphone_gain_switch(codec); 6455 6421 #ifdef ENABLE_TUNING_CONTROLS 6456 6422 add_tuning_ctls(codec); 6457 6423 #endif