Changeset 695 for GPL/trunk/alsa-kernel/pci/hda
- Timestamp:
- Aug 21, 2021, 3:35:34 AM (4 years ago)
- Location:
- GPL/trunk
- Files:
-
- 21 edited
-
. (modified) (1 prop)
-
alsa-kernel/pci/hda/hda_auto_parser.c (modified) (1 diff)
-
alsa-kernel/pci/hda/hda_auto_parser.h (modified) (1 diff)
-
alsa-kernel/pci/hda/hda_codec.c (modified) (10 diffs)
-
alsa-kernel/pci/hda/hda_controller.c (modified) (1 diff)
-
alsa-kernel/pci/hda/hda_eld.c (modified) (1 diff)
-
alsa-kernel/pci/hda/hda_generic.c (modified) (13 diffs)
-
alsa-kernel/pci/hda/hda_generic.h (modified) (3 diffs)
-
alsa-kernel/pci/hda/hda_intel.c (modified) (10 diffs)
-
alsa-kernel/pci/hda/hda_jack.c (modified) (5 diffs)
-
alsa-kernel/pci/hda/hda_jack.h (modified) (2 diffs)
-
alsa-kernel/pci/hda/hda_local.h (modified) (4 diffs)
-
alsa-kernel/pci/hda/hda_proc.c (modified) (2 diffs)
-
alsa-kernel/pci/hda/hda_tegra.c (modified) (9 diffs)
-
alsa-kernel/pci/hda/patch_ca0132.c (modified) (44 diffs)
-
alsa-kernel/pci/hda/patch_cirrus.c (modified) (23 diffs)
-
alsa-kernel/pci/hda/patch_conexant.c (modified) (1 diff)
-
alsa-kernel/pci/hda/patch_hdmi.c (modified) (21 diffs)
-
alsa-kernel/pci/hda/patch_realtek.c (modified) (14 diffs)
-
alsa-kernel/pci/hda/patch_sigmatel.c (modified) (2 diffs)
-
alsa-kernel/pci/hda/thinkpad_helper.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-next merged: 691-694
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/hda/hda_auto_parser.c
r679 r695 769 769 if (!name) 770 770 return 0; 771 str lcpy(label, name, maxlen);771 strscpy(label, name, maxlen); 772 772 return 1; 773 773 } -
GPL/trunk/alsa-kernel/pci/hda/hda_auto_parser.h
r679 r695 28 28 29 29 #define AUTO_CFG_MAX_OUTS HDA_MAX_OUTS 30 #define AUTO_CFG_MAX_INS 830 #define AUTO_CFG_MAX_INS 18 31 31 32 32 struct auto_pin_cfg_item { -
GPL/trunk/alsa-kernel/pci/hda/hda_codec.c
r689 r695 1950 1950 * @suffix: suffix string to each follower name (optional) 1951 1951 * @init_follower_vol: initialize followers to unmute/0dB 1952 * @access: kcontrol access rights 1952 1953 * @ctl_ret: store the vmaster kcontrol in return 1953 1954 * … … 1964 1965 unsigned int *tlv, const char * const *followers, 1965 1966 const char *suffix, bool init_follower_vol, 1966 struct snd_kcontrol **ctl_ret)1967 unsigned int access, struct snd_kcontrol **ctl_ret) 1967 1968 { 1968 1969 struct snd_kcontrol *kctl; … … 1980 1981 if (!kctl) 1981 1982 return -ENOMEM; 1983 kctl->vd[0].access |= access; 1982 1984 err = snd_hda_ctl_add(codec, 0, kctl); 1983 1985 if (err < 0) … … 2011 2013 EXPORT_SYMBOL_GPL(__snd_hda_add_vmaster); 2012 2014 2013 /*2014 * mute-LED control using vmaster2015 */2016 static int vmaster_mute_mode_info(struct snd_kcontrol *kcontrol,2017 struct snd_ctl_elem_info *uinfo)2018 {2019 static const char * const texts[] = {2020 "On", "Off", "Follow Master"2021 };2022 2023 return snd_ctl_enum_info(uinfo, 1, 3, texts);2024 }2025 2026 static int vmaster_mute_mode_get(struct snd_kcontrol *kcontrol,2027 struct snd_ctl_elem_value *ucontrol)2028 {2029 struct hda_vmaster_mute_hook *hook = snd_kcontrol_chip(kcontrol);2030 ucontrol->value.enumerated.item[0] = hook->mute_mode;2031 return 0;2032 }2033 2034 static int vmaster_mute_mode_put(struct snd_kcontrol *kcontrol,2035 struct snd_ctl_elem_value *ucontrol)2036 {2037 struct hda_vmaster_mute_hook *hook = snd_kcontrol_chip(kcontrol);2038 unsigned int old_mode = hook->mute_mode;2039 2040 hook->mute_mode = ucontrol->value.enumerated.item[0];2041 if (hook->mute_mode > HDA_VMUTE_FOLLOW_MASTER)2042 hook->mute_mode = HDA_VMUTE_FOLLOW_MASTER;2043 if (old_mode == hook->mute_mode)2044 return 0;2045 snd_hda_sync_vmaster_hook(hook);2046 return 1;2047 }2048 2049 static const struct snd_kcontrol_new vmaster_mute_mode = {2050 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,2051 .name = "Mute-LED Mode",2052 .info = vmaster_mute_mode_info,2053 .get = vmaster_mute_mode_get,2054 .put = vmaster_mute_mode_put,2055 };2056 2057 2015 /* meta hook to call each driver's vmaster hook */ 2058 2016 static void vmaster_hook(void *private_data, int enabled) … … 2060 2018 struct hda_vmaster_mute_hook *hook = private_data; 2061 2019 2062 if (hook->mute_mode != HDA_VMUTE_FOLLOW_MASTER)2063 enabled = hook->mute_mode;2064 2020 hook->hook(hook->codec, enabled); 2065 2021 } 2066 2022 2067 2023 /** 2068 * snd_hda_add_vmaster_hook - Add a vmaster h ook for mute-LED2024 * snd_hda_add_vmaster_hook - Add a vmaster hw specific hook 2069 2025 * @codec: the HDA codec 2070 2026 * @hook: the vmaster hook object 2071 * @expose_enum_ctl: flag to create an enum ctl 2072 * 2073 * Add a mute-LED hook with the given vmaster switch kctl. 2074 * When @expose_enum_ctl is set, "Mute-LED Mode" control is automatically 2075 * created and associated with the given hook. 2027 * 2028 * Add a hw specific hook (like EAPD) with the given vmaster switch kctl. 2076 2029 */ 2077 2030 int snd_hda_add_vmaster_hook(struct hda_codec *codec, 2078 struct hda_vmaster_mute_hook *hook, 2079 bool expose_enum_ctl) 2080 { 2081 struct snd_kcontrol *kctl; 2082 2031 struct hda_vmaster_mute_hook *hook) 2032 { 2083 2033 if (!hook->hook || !hook->sw_kctl) 2084 2034 return 0; 2085 2035 hook->codec = codec; 2086 hook->mute_mode = HDA_VMUTE_FOLLOW_MASTER;2087 2036 snd_ctl_add_vmaster_hook(hook->sw_kctl, vmaster_hook, hook); 2088 if (!expose_enum_ctl) 2089 return 0; 2090 kctl = snd_ctl_new1(&vmaster_mute_mode, hook); 2091 if (!kctl) 2092 return -ENOMEM; 2093 return snd_hda_ctl_add(codec, 0, kctl); 2037 return 0; 2094 2038 } 2095 2039 EXPORT_SYMBOL_GPL(snd_hda_add_vmaster_hook); … … 3002 2946 dev->power.power_state = PMSG_RESUME; 3003 2947 #endif 2948 3004 2949 if (pm_runtime_suspended(dev) && (codec->jackpoll_interval || 3005 2950 hda_codec_need_resume(codec) || codec->forced_resume)) … … 3505 3450 3506 3451 /** 3507 * snd_hda_input_mux_info _info- Info callback helper for the input-mux enum3452 * snd_hda_input_mux_info - Info callback helper for the input-mux enum 3508 3453 * @imux: imux helper object 3509 3454 * @uinfo: pointer to get/store the data … … 3528 3473 3529 3474 /** 3530 * snd_hda_input_mux_ info_put - Put callback helper for the input-mux enum3475 * snd_hda_input_mux_put - Put callback helper for the input-mux enum 3531 3476 * @codec: the HDA codec 3532 3477 * @imux: imux helper object … … 3963 3908 3964 3909 /** 3965 * _snd_hda_ pin_ctl - Helper to set pin ctl value3910 * _snd_hda_set_pin_ctl - Helper to set pin ctl value 3966 3911 * @codec: the HDA codec 3967 3912 * @pin: referred pin NID … … 4021 3966 "%s %d", label, label_idx); 4022 3967 else 4023 str lcpy(imux->items[imux->num_items].label, label,3968 strscpy(imux->items[imux->num_items].label, label, 4024 3969 sizeof(imux->items[imux->num_items].label)); 4025 3970 imux->items[imux->num_items].index = index; -
GPL/trunk/alsa-kernel/pci/hda/hda_controller.c
r689 r695 753 753 if (err < 0) 754 754 return err; 755 str lcpy(pcm->name, cpcm->name, sizeof(pcm->name));755 strscpy(pcm->name, cpcm->name, sizeof(pcm->name)); 756 756 apcm = kzalloc(sizeof(*apcm), GFP_KERNEL); 757 757 if (apcm == NULL) { -
GPL/trunk/alsa-kernel/pci/hda/hda_eld.c
r679 r695 261 261 goto out_fail; 262 262 } else 263 str lcpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl + 1);263 strscpy(e->monitor_name, buf + ELD_FIXED_BYTES, mnl + 1); 264 264 265 265 for (i = 0; i < e->sad_count; i++) { -
GPL/trunk/alsa-kernel/pci/hda/hda_generic.c
r689 r695 985 985 if (get_amp_nid_(val)) 986 986 knew->subdevice = HDA_SUBDEV_AMP_FLAG; 987 if (knew->access == 0) 988 knew->access = SNDRV_CTL_ELEM_ACCESS_READWRITE; 987 989 knew->private_value = val; 988 990 return knew; … … 3530 3532 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 3531 3533 .name = "Capture Switch", 3534 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 3532 3535 .info = cap_sw_info, 3533 3536 .get = cap_sw_get, … … 3636 3639 if (!knew) 3637 3640 return -ENOMEM; 3638 if (is_switch) 3641 if (is_switch) { 3639 3642 knew->put = cap_single_sw_put; 3643 if (spec->mic_mute_led) 3644 knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED; 3645 } 3640 3646 if (!inv_dmic) 3641 3647 return 0; … … 3652 3658 if (!knew) 3653 3659 return -ENOMEM; 3654 if (is_switch) 3660 if (is_switch) { 3655 3661 knew->put = cap_single_sw_put; 3662 if (spec->mic_mute_led) 3663 knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED; 3664 } 3656 3665 return 0; 3657 3666 } … … 3694 3703 knew->private_value = sw_ctl; 3695 3704 knew->subdevice = HDA_SUBDEV_AMP_FLAG; 3705 if (spec->mic_mute_led) 3706 knew->access |= SNDRV_CTL_ELEM_ACCESS_MIC_LED; 3696 3707 } 3697 3708 return 0; … … 3935 3946 } 3936 3947 3937 static void vmaster_update_mute_led(void *private_data, int enabled)3938 {3939 ledtrig_audio_set(LED_AUDIO_MUTE, enabled ? LED_OFF : LED_ON);3940 }3941 3942 3948 /** 3943 * snd_ dha_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED3949 * snd_hda_gen_add_mute_led_cdev - Create a LED classdev and enable as vmaster mute LED 3944 3950 * @codec: the HDA codec 3945 3951 * @callback: the callback for LED classdev brightness_set_blocking … … 3963 3969 codec_err(codec, "vmaster hook already present before cdev!\n"); 3964 3970 3965 spec->vmaster_mute.hook = vmaster_update_mute_led; 3966 spec->vmaster_mute_enum = 1; 3971 spec->vmaster_mute_led = 1; 3967 3972 return 0; 3968 3973 } 3969 3974 EXPORT_SYMBOL_GPL(snd_hda_gen_add_mute_led_cdev); 3970 3975 3971 /*3972 * mic mute LED hook helpers3973 */3974 enum {3975 MICMUTE_LED_ON,3976 MICMUTE_LED_OFF,3977 MICMUTE_LED_FOLLOW_CAPTURE,3978 MICMUTE_LED_FOLLOW_MUTE,3979 };3980 3981 static void call_micmute_led_update(struct hda_codec *codec)3982 {3983 struct hda_gen_spec *spec = codec->spec;3984 unsigned int val;3985 3986 switch (spec->micmute_led.led_mode) {3987 case MICMUTE_LED_ON:3988 val = 1;3989 break;3990 case MICMUTE_LED_OFF:3991 val = 0;3992 break;3993 case MICMUTE_LED_FOLLOW_CAPTURE:3994 val = !!spec->micmute_led.capture;3995 break;3996 case MICMUTE_LED_FOLLOW_MUTE:3997 default:3998 val = !spec->micmute_led.capture;3999 break;4000 }4001 4002 if (val == spec->micmute_led.led_value)4003 return;4004 spec->micmute_led.led_value = val;4005 ledtrig_audio_set(LED_AUDIO_MICMUTE,4006 spec->micmute_led.led_value ? LED_ON : LED_OFF);4007 }4008 4009 static void update_micmute_led(struct hda_codec *codec,4010 struct snd_kcontrol *kcontrol,4011 struct snd_ctl_elem_value *ucontrol)4012 {4013 struct hda_gen_spec *spec = codec->spec;4014 unsigned int mask;4015 4016 if (spec->micmute_led.old_hook)4017 spec->micmute_led.old_hook(codec, kcontrol, ucontrol);4018 4019 if (!ucontrol)4020 return;4021 mask = 1U << snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);4022 if (!strcmp("Capture Switch", ucontrol->id.name)) {4023 /* TODO: How do I verify if it's a mono or stereo here? */4024 if (ucontrol->value.integer.value[0] ||4025 ucontrol->value.integer.value[1])4026 spec->micmute_led.capture |= mask;4027 else4028 spec->micmute_led.capture &= ~mask;4029 call_micmute_led_update(codec);4030 }4031 }4032 4033 static int micmute_led_mode_info(struct snd_kcontrol *kcontrol,4034 struct snd_ctl_elem_info *uinfo)4035 {4036 static const char * const texts[] = {4037 "On", "Off", "Follow Capture", "Follow Mute",4038 };4039 4040 return snd_ctl_enum_info(uinfo, 1, ARRAY_SIZE(texts), texts);4041 }4042 4043 static int micmute_led_mode_get(struct snd_kcontrol *kcontrol,4044 struct snd_ctl_elem_value *ucontrol)4045 {4046 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);4047 struct hda_gen_spec *spec = codec->spec;4048 4049 ucontrol->value.enumerated.item[0] = spec->micmute_led.led_mode;4050 return 0;4051 }4052 4053 static int micmute_led_mode_put(struct snd_kcontrol *kcontrol,4054 struct snd_ctl_elem_value *ucontrol)4055 {4056 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);4057 struct hda_gen_spec *spec = codec->spec;4058 unsigned int mode;4059 4060 mode = ucontrol->value.enumerated.item[0];4061 if (mode > MICMUTE_LED_FOLLOW_MUTE)4062 mode = MICMUTE_LED_FOLLOW_MUTE;4063 if (mode == spec->micmute_led.led_mode)4064 return 0;4065 spec->micmute_led.led_mode = mode;4066 call_micmute_led_update(codec);4067 return 1;4068 }4069 4070 static const struct snd_kcontrol_new micmute_led_mode_ctl = {4071 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,4072 .name = "Mic Mute-LED Mode",4073 .info = micmute_led_mode_info,4074 .get = micmute_led_mode_get,4075 .put = micmute_led_mode_put,4076 };4077 4078 /* Set up the capture sync hook for controlling the mic-mute LED */4079 static int add_micmute_led_hook(struct hda_codec *codec)4080 {4081 struct hda_gen_spec *spec = codec->spec;4082 4083 spec->micmute_led.led_mode = MICMUTE_LED_FOLLOW_MUTE;4084 spec->micmute_led.capture = 0;4085 spec->micmute_led.led_value = -1;4086 spec->micmute_led.old_hook = spec->cap_sync_hook;4087 spec->cap_sync_hook = update_micmute_led;4088 if (!snd_hda_gen_add_kctl(spec, NULL, &micmute_led_mode_ctl))4089 return -ENOMEM;4090 return 0;4091 }4092 4093 3976 /** 4094 * snd_ dha_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED3977 * snd_hda_gen_add_micmute_led_cdev - Create a LED classdev and enable as mic-mute LED 4095 3978 * @codec: the HDA codec 4096 3979 * @callback: the callback for LED classdev brightness_set_blocking … … 4109 3992 enum led_brightness)) 4110 3993 { 3994 struct hda_gen_spec *spec = codec->spec; 4111 3995 int err; 4112 3996 … … 4119 4003 } 4120 4004 4121 return add_micmute_led_hook(codec); 4005 spec->mic_mute_led = 1; 4006 return 0; 4122 4007 } 4123 4008 EXPORT_SYMBOL_GPL(snd_hda_gen_add_micmute_led_cdev); … … 5078 4963 parse_user_hints(codec); 5079 4964 4965 if (spec->vmaster_mute_led || spec->mic_mute_led) 4966 snd_ctl_led_request(); 4967 5080 4968 if (spec->mixer_nid && !spec->mixer_merge_nid) 5081 4969 spec->mixer_merge_nid = spec->mixer_nid; … … 5309 5197 err = snd_hda_add_vmaster(codec, "Master Playback Volume", 5310 5198 spec->vmaster_tlv, follower_pfxs, 5311 "Playback Volume" );5199 "Playback Volume", 0); 5312 5200 if (err < 0) 5313 5201 return err; … … 5317 5205 err = __snd_hda_add_vmaster(codec, "Master Playback Switch", 5318 5206 NULL, follower_pfxs, 5319 "Playback Switch", 5320 true, &spec->vmaster_mute.sw_kctl); 5207 "Playback Switch", true, 5208 spec->vmaster_mute_led ? 5209 SNDRV_CTL_ELEM_ACCESS_SPK_LED : 0, 5210 &spec->vmaster_mute.sw_kctl); 5321 5211 if (err < 0) 5322 5212 return err; 5323 5213 if (spec->vmaster_mute.hook) { 5324 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, 5325 spec->vmaster_mute_enum); 5214 snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute); 5326 5215 snd_hda_sync_vmaster_hook(&spec->vmaster_mute); 5327 5216 } … … 5739 5628 if (*str) 5740 5629 return; 5741 str lcpy(str, chip_name, len);5630 strscpy(str, chip_name, len); 5742 5631 5743 5632 /* drop non-alnum chars after a space */ -
GPL/trunk/alsa-kernel/pci/hda/hda_generic.h
r679 r695 84 84 extern const struct badness_table hda_main_out_badness; 85 85 extern const struct badness_table hda_extra_out_badness; 86 87 struct hda_micmute_hook {88 unsigned int led_mode;89 unsigned int capture;90 unsigned int led_value;91 void (*old_hook)(struct hda_codec *codec,92 struct snd_kcontrol *kcontrol,93 struct snd_ctl_elem_value *ucontrol);94 };95 86 96 87 struct hda_gen_spec { … … 230 221 unsigned int own_eapd_ctl:1; /* set EAPD by own function */ 231 222 unsigned int keep_eapd_on:1; /* don't turn off EAPD automatically */ 232 unsigned int vmaster_mute_enum:1; /* add vmaster mute mode enum */ 223 unsigned int vmaster_mute_led:1; /* add SPK-LED flag to vmaster mute switch */ 224 unsigned int mic_mute_led:1; /* add MIC-LED flag to capture mute switch */ 233 225 unsigned int indep_hp:1; /* independent HP supported */ 234 226 unsigned int prefer_hp_amp:1; /* enable HP amp for speaker if any */ … … 285 277 struct snd_kcontrol *kcontrol, 286 278 struct snd_ctl_elem_value *ucontrol); 287 288 /* mic mute LED hook; called via cap_sync_hook */289 struct hda_micmute_hook micmute_led;290 279 291 280 /* PCM hooks */ -
GPL/trunk/alsa-kernel/pci/hda/hda_intel.c
r689 r695 227 227 228 228 MODULE_LICENSE("GPL"); 229 MODULE_SUPPORTED_DEVICE("{{Intel, ICH6},"230 "{Intel, ICH6M},"231 "{Intel, ICH7},"232 "{Intel, ESB2},"233 "{Intel, ICH8},"234 "{Intel, ICH9},"235 "{Intel, ICH10},"236 "{Intel, PCH},"237 "{Intel, CPT},"238 "{Intel, PPT},"239 "{Intel, LPT},"240 "{Intel, LPT_LP},"241 "{Intel, WPT_LP},"242 "{Intel, SPT},"243 "{Intel, SPT_LP},"244 "{Intel, HPT},"245 "{Intel, PBG},"246 "{Intel, SCH},"247 "{ATI, SB450},"248 "{ATI, SB600},"249 "{ATI, RS600},"250 "{ATI, RS690},"251 "{ATI, RS780},"252 "{ATI, R600},"253 "{ATI, RV630},"254 "{ATI, RV610},"255 "{ATI, RV670},"256 "{ATI, RV635},"257 "{ATI, RV620},"258 "{ATI, RV770},"259 "{VIA, VT8251},"260 "{VIA, VT8237A},"261 "{SiS, SIS966},"262 "{ULI, M5461}}");263 229 MODULE_DESCRIPTION("Intel HDA driver"); 264 230 … … 1492 1458 if (dhandle) { 1493 1459 status = acpi_get_handle(dhandle, "ATPX", &atpx_handle); 1494 if ( !ACPI_FAILURE(status)) {1460 if (ACPI_SUCCESS(status)) { 1495 1461 pci_dev_put(pdev); 1496 1462 return true; … … 1502 1468 if (dhandle) { 1503 1469 status = acpi_get_handle(dhandle, "ATPX", &atpx_handle); 1504 if ( !ACPI_FAILURE(status)) {1470 if (ACPI_SUCCESS(status)) { 1505 1471 pci_dev_put(pdev); 1506 1472 return true; … … 2019 1985 if (!(gcap & AZX_GCAP_64OK)) 2020 1986 dma_bits = 32; 2021 if (!dma_set_mask(&pci->dev, DMA_BIT_MASK(dma_bits))) { 2022 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(dma_bits)); 2023 } else { 2024 dma_set_mask(&pci->dev, DMA_BIT_MASK(32)); 2025 dma_set_coherent_mask(&pci->dev, DMA_BIT_MASK(32)); 2026 } 1987 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits))) 1988 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); 2027 1989 2028 1990 /* read number of streams from GCAP register instead of using … … 2089 2051 2090 2052 strcpy(card->driver, "HDA-Intel"); 2091 str lcpy(card->shortname, driver_short_names[chip->driver_type],2053 strscpy(card->shortname, driver_short_names[chip->driver_type], 2092 2054 sizeof(card->shortname)); 2093 2055 snprintf(card->longname, sizeof(card->longname), … … 2280 2242 /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ 2281 2243 SND_PCI_QUIRK(0x1043, 0x8733, "Asus Prime X370-Pro", 0), 2282 /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */2283 SND_PCI_QUIRK(0x1558, 0x6504, "Clevo W65_67SB", 0),2284 2244 /* https://bugzilla.redhat.com/show_bug.cgi?id=1525104 */ 2285 2245 SND_PCI_QUIRK(0x1028, 0x0497, "Dell Precision T3600", 0), … … 2364 2324 /* HSW/BDW controllers need this power */ 2365 2325 if (CONTROLLER_IN_GPU(pci)) 2366 hda->need_i915_power = 1;2326 hda->need_i915_power = true; 2367 2327 } 2368 2328 … … 2575 2535 { PCI_DEVICE(0x8086, 0x51c8), 2576 2536 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, 2537 /* Alderlake-M */ 2538 { PCI_DEVICE(0x8086, 0x51cc), 2539 .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, 2577 2540 /* Elkhart Lake */ 2578 2541 { PCI_DEVICE(0x8086, 0x4b55), … … 2666 2629 /* ATI HDMI */ 2667 2630 { PCI_DEVICE(0x1002, 0x0002), 2668 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, 2631 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS | 2632 AZX_DCAPS_PM_RUNTIME }, 2669 2633 { PCI_DEVICE(0x1002, 0x1308), 2670 2634 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, … … 2728 2692 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, 2729 2693 { PCI_DEVICE(0x1002, 0xaac0), 2730 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, 2694 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS | 2695 AZX_DCAPS_PM_RUNTIME }, 2731 2696 { PCI_DEVICE(0x1002, 0xaac8), 2732 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, 2697 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS | 2698 AZX_DCAPS_PM_RUNTIME }, 2733 2699 { PCI_DEVICE(0x1002, 0xaad8), 2734 2700 .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS | -
GPL/trunk/alsa-kernel/pci/hda/hda_jack.c
r679 r695 214 214 215 215 /** 216 * snd_hda_ set_dirty_all - Mark all the cached as dirty216 * snd_hda_jack_set_dirty_all - Mark all the cached as dirty 217 217 * @codec: the HDA codec 218 218 * … … 294 294 295 295 /** 296 * snd_hda_jack_detect_enable_ mst - enable the jack-detection296 * snd_hda_jack_detect_enable_callback_mst - enable the jack-detection 297 297 * @codec: the HDA codec 298 298 * @nid: pin NID to enable … … 388 388 } 389 389 EXPORT_SYMBOL_GPL(snd_hda_jack_set_gating_jack); 390 391 /** 392 * snd_hda_jack_bind_keymap - bind keys generated from one NID to another jack. 393 * @codec: the HDA codec 394 * @key_nid: key event is generated by this pin NID 395 * @keymap: map of key type and key code 396 * @jack_nid: key reports to the jack of this pin NID 397 * 398 * This function is used in the case of key is generated from one NID while is 399 * reported to the jack of another NID. 400 */ 401 int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid, 402 const struct hda_jack_keymap *keymap, 403 hda_nid_t jack_nid) 404 { 405 const struct hda_jack_keymap *map; 406 struct hda_jack_tbl *key_gen = snd_hda_jack_tbl_get(codec, key_nid); 407 struct hda_jack_tbl *report_to = snd_hda_jack_tbl_get(codec, jack_nid); 408 409 WARN_ON(codec->dp_mst); 410 411 if (!key_gen || !report_to || !report_to->jack) 412 return -EINVAL; 413 414 key_gen->key_report_jack = jack_nid; 415 416 if (keymap) 417 for (map = keymap; map->type; map++) 418 snd_jack_set_key(report_to->jack, map->type, map->key); 419 420 return 0; 421 } 422 EXPORT_SYMBOL_GPL(snd_hda_jack_bind_keymap); 423 424 /** 425 * snd_hda_jack_set_button_state - report button event to the hda_jack_tbl button_state. 426 * @codec: the HDA codec 427 * @jack_nid: the button event reports to the jack_tbl of this NID 428 * @button_state: the button event captured by codec 429 * 430 * Codec driver calls this function to report the button event. 431 */ 432 void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid, 433 int button_state) 434 { 435 struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, jack_nid); 436 437 if (!jack) 438 return; 439 440 if (jack->key_report_jack) { 441 struct hda_jack_tbl *report_to = 442 snd_hda_jack_tbl_get(codec, jack->key_report_jack); 443 444 if (report_to) { 445 report_to->button_state = button_state; 446 return; 447 } 448 } 449 450 jack->button_state = button_state; 451 } 452 EXPORT_SYMBOL_GPL(snd_hda_jack_set_button_state); 390 453 391 454 /** … … 531 594 532 595 if (base_name) 533 str lcpy(name, base_name, sizeof(name));596 strscpy(name, base_name, sizeof(name)); 534 597 else 535 598 snd_hda_get_pin_label(codec, nid, cfg, name, sizeof(name), NULL); … … 652 715 if (!event) 653 716 return; 654 event->jack_dirty = 1; 717 718 if (event->key_report_jack) { 719 struct hda_jack_tbl *report_to = 720 snd_hda_jack_tbl_get_mst(codec, event->key_report_jack, 721 event->dev_id); 722 if (report_to) 723 report_to->jack_dirty = 1; 724 } else 725 event->jack_dirty = 1; 655 726 656 727 call_jack_callback(codec, res, event); -
GPL/trunk/alsa-kernel/pci/hda/hda_jack.h
r679 r695 41 41 hda_nid_t gating_jack; /* valid when gating jack plugged */ 42 42 hda_nid_t gated_jack; /* gated is dependent on this jack */ 43 hda_nid_t key_report_jack; /* key reports to this jack */ 43 44 int type; 44 45 int button_state; … … 99 100 int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid, 100 101 hda_nid_t gating_nid); 102 103 int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid, 104 const struct hda_jack_keymap *keymap, 105 hda_nid_t jack_nid); 106 107 void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid, 108 int button_state); 101 109 102 110 u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id); -
GPL/trunk/alsa-kernel/pci/hda/hda_local.h
r679 r695 132 132 unsigned int *tlv, const char * const *followers, 133 133 const char *suffix, bool init_follower_vol, 134 struct snd_kcontrol **ctl_ret);135 #define snd_hda_add_vmaster(codec, name, tlv, followers, suffix ) \136 __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, NULL)134 unsigned int access, struct snd_kcontrol **ctl_ret); 135 #define snd_hda_add_vmaster(codec, name, tlv, followers, suffix, access) \ 136 __snd_hda_add_vmaster(codec, name, tlv, followers, suffix, true, access, NULL) 137 137 int snd_hda_codec_reset(struct hda_codec *codec); 138 138 void snd_hda_codec_register(struct hda_codec *codec); … … 140 140 141 141 #define snd_hda_regmap_sync(codec) snd_hdac_regmap_sync(&(codec)->core) 142 143 enum {144 HDA_VMUTE_OFF,145 HDA_VMUTE_ON,146 HDA_VMUTE_FOLLOW_MASTER,147 };148 142 149 143 struct hda_vmaster_mute_hook { … … 154 148 void (*hook)(void *, int); 155 149 /* below are initialized automatically */ 156 unsigned int mute_mode; /* HDA_VMUTE_XXX */157 150 struct hda_codec *codec; 158 151 }; 159 152 160 153 int snd_hda_add_vmaster_hook(struct hda_codec *codec, 161 struct hda_vmaster_mute_hook *hook, 162 bool expose_enum_ctl); 154 struct hda_vmaster_mute_hook *hook); 163 155 void snd_hda_sync_vmaster_hook(struct hda_vmaster_mute_hook *hook); 164 156 … … 181 173 * input MUX helper 182 174 */ 183 #define HDA_MAX_NUM_INPUTS 16175 #define HDA_MAX_NUM_INPUTS 36 184 176 struct hda_input_mux_item { 185 177 char label[32]; -
GPL/trunk/alsa-kernel/pci/hda/hda_proc.c
r679 r695 683 683 } 684 684 685 static void print_dpmst_connections(struct snd_info_buffer *buffer, struct hda_codec *codec, 686 hda_nid_t nid, int dev_num) 687 { 688 int c, conn_len, curr, dev_id_saved; 689 hda_nid_t *conn; 690 691 conn_len = snd_hda_get_num_raw_conns(codec, nid); 692 if (conn_len <= 0) 693 return; 694 695 conn = kmalloc_array(conn_len, sizeof(hda_nid_t), GFP_KERNEL); 696 if (!conn) 697 return; 698 699 dev_id_saved = snd_hda_get_dev_select(codec, nid); 700 701 snd_hda_set_dev_select(codec, nid, dev_num); 702 curr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0); 703 if (snd_hda_get_raw_connections(codec, nid, conn, conn_len) < 0) 704 goto out; 705 706 for (c = 0; c < conn_len; c++) { 707 snd_iprintf(buffer, " 0x%02x", conn[c]); 708 if (c == curr) 709 snd_iprintf(buffer, "*"); 710 } 711 712 out: 713 kfree(conn); 714 snd_hda_set_dev_select(codec, nid, dev_id_saved); 715 } 716 685 717 static void print_device_list(struct snd_info_buffer *buffer, 686 718 struct hda_codec *codec, hda_nid_t nid) … … 706 738 707 739 snd_iprintf(buffer, 708 "Dev %02d: PD = %d, ELDV = %d, IA = %d \n", i,740 "Dev %02d: PD = %d, ELDV = %d, IA = %d, Connections [", i, 709 741 !!(dev_list[i] & AC_DE_PD), 710 742 !!(dev_list[i] & AC_DE_ELDV), 711 743 !!(dev_list[i] & AC_DE_IA)); 744 745 print_dpmst_connections(buffer, codec, nid, i); 746 747 snd_iprintf(buffer, " ]\n"); 712 748 } 713 749 } -
GPL/trunk/alsa-kernel/pci/hda/hda_tegra.c
r679 r695 18 18 #include <linux/mutex.h> 19 19 #include <linux/of_device.h> 20 #include <linux/reset.h> 20 21 #include <linux/slab.h> 21 22 #include <linux/time.h> … … 71 72 struct azx chip; 72 73 struct device *dev; 73 struct clk *hda_clk;74 struct clk *hda2codec_2x_clk;75 struct clk *hda2hdmi_clk;74 struct reset_control *reset; 75 struct clk_bulk_data clocks[3]; 76 unsigned int nclocks; 76 77 void __iomem *regs; 77 78 struct work_struct probe_work; … … 114 115 } 115 116 116 static int hda_tegra_enable_clocks(struct hda_tegra *data)117 {118 int rc;119 120 rc = clk_prepare_enable(data->hda_clk);121 if (rc)122 return rc;123 rc = clk_prepare_enable(data->hda2codec_2x_clk);124 if (rc)125 goto disable_hda;126 rc = clk_prepare_enable(data->hda2hdmi_clk);127 if (rc)128 goto disable_codec_2x;129 130 return 0;131 132 disable_codec_2x:133 clk_disable_unprepare(data->hda2codec_2x_clk);134 disable_hda:135 clk_disable_unprepare(data->hda_clk);136 return rc;137 }138 139 static void hda_tegra_disable_clocks(struct hda_tegra *data)140 {141 clk_disable_unprepare(data->hda2hdmi_clk);142 clk_disable_unprepare(data->hda2codec_2x_clk);143 clk_disable_unprepare(data->hda_clk);144 }145 146 117 /* 147 118 * power management … … 187 158 azx_enter_link_reset(chip); 188 159 } 189 hda_tegra_disable_clocks(hda);160 clk_bulk_disable_unprepare(hda->nclocks, hda->clocks); 190 161 191 162 return 0; … … 199 170 int rc; 200 171 201 rc = hda_tegra_enable_clocks(hda); 172 if (!chip->running) { 173 rc = reset_control_assert(hda->reset); 174 if (rc) 175 return rc; 176 } 177 178 rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks); 202 179 if (rc != 0) 203 180 return rc; 204 if (chip && chip->running) {181 if (chip->running) { 205 182 hda_tegra_init(hda); 206 183 azx_init_chip(chip, 1); … … 208 185 azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) & 209 186 ~STATESTS_INT_MASK); 187 } else { 188 usleep_range(10, 100); 189 190 rc = reset_control_deassert(hda->reset); 191 if (rc) 192 return rc; 210 193 } 211 194 … … 265 248 266 249 hda_tegra_init(hda); 267 268 return 0;269 }270 271 static int hda_tegra_init_clk(struct hda_tegra *hda)272 {273 struct device *dev = hda->dev;274 275 hda->hda_clk = devm_clk_get(dev, "hda");276 if (IS_ERR(hda->hda_clk)) {277 dev_err(dev, "failed to get hda clock\n");278 return PTR_ERR(hda->hda_clk);279 }280 hda->hda2codec_2x_clk = devm_clk_get(dev, "hda2codec_2x");281 if (IS_ERR(hda->hda2codec_2x_clk)) {282 dev_err(dev, "failed to get hda2codec_2x clock\n");283 return PTR_ERR(hda->hda2codec_2x_clk);284 }285 hda->hda2hdmi_clk = devm_clk_get(dev, "hda2hdmi");286 if (IS_ERR(hda->hda2hdmi_clk)) {287 dev_err(dev, "failed to get hda2hdmi clock\n");288 return PTR_ERR(hda->hda2hdmi_clk);289 }290 250 291 251 return 0; … … 302 262 const char *sname, *drv_name = "tegra-hda"; 303 263 struct device_node *np = pdev->dev.of_node; 264 265 if (irq_id < 0) 266 return irq_id; 304 267 305 268 err = hda_tegra_init_chip(chip, pdev); … … 496 459 } 497 460 498 err = hda_tegra_init_clk(hda); 461 hda->reset = devm_reset_control_array_get_exclusive(&pdev->dev); 462 if (IS_ERR(hda->reset)) { 463 err = PTR_ERR(hda->reset); 464 goto out_free; 465 } 466 467 hda->clocks[hda->nclocks++].id = "hda"; 468 hda->clocks[hda->nclocks++].id = "hda2hdmi"; 469 hda->clocks[hda->nclocks++].id = "hda2codec_2x"; 470 471 err = devm_clk_bulk_get(&pdev->dev, hda->nclocks, hda->clocks); 499 472 if (err < 0) 500 473 goto out_free; -
GPL/trunk/alsa-kernel/pci/hda/patch_ca0132.c
r689 r695 791 791 { .name = "Fast Roll Off", 792 792 .val = 0x80 793 } 794 }; 795 796 /* 797 * Data structures for storing audio router remapping data. These are used to 798 * remap a currently active streams ports. 799 */ 800 struct chipio_stream_remap_data { 801 unsigned int stream_id; 802 unsigned int count; 803 804 unsigned int offset[16]; 805 unsigned int value[16]; 806 }; 807 808 static const struct chipio_stream_remap_data stream_remap_data[] = { 809 { .stream_id = 0x14, 810 .count = 0x04, 811 .offset = { 0x00, 0x04, 0x08, 0x0c }, 812 .value = { 0x0001f8c0, 0x0001f9c1, 0x0001fac6, 0x0001fbc7 }, 813 }, 814 { .stream_id = 0x0c, 815 .count = 0x0c, 816 .offset = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c, 817 0x20, 0x24, 0x28, 0x2c }, 818 .value = { 0x0001e0c0, 0x0001e1c1, 0x0001e4c2, 0x0001e5c3, 819 0x0001e2c4, 0x0001e3c5, 0x0001e8c6, 0x0001e9c7, 820 0x0001ecc8, 0x0001edc9, 0x0001eaca, 0x0001ebcb }, 821 }, 822 { .stream_id = 0x0c, 823 .count = 0x08, 824 .offset = { 0x08, 0x0c, 0x10, 0x14, 0x20, 0x24, 0x28, 0x2c }, 825 .value = { 0x000140c2, 0x000141c3, 0x000150c4, 0x000151c5, 826 0x000142c8, 0x000143c9, 0x000152ca, 0x000153cb }, 793 827 } 794 828 }; … … 1836 1870 } 1837 1871 1872 /* 1873 * Get ChipIO audio stream's status. 1874 */ 1875 static void chipio_get_stream_control(struct hda_codec *codec, 1876 int streamid, unsigned int *enable) 1877 { 1878 chipio_set_control_param_no_mutex(codec, 1879 CONTROL_PARAM_STREAM_ID, streamid); 1880 *enable = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, 1881 VENDOR_CHIPIO_PARAM_GET, 1882 CONTROL_PARAM_STREAM_CONTROL); 1883 } 1838 1884 1839 1885 /* … … 1875 1921 1876 1922 /* 1923 * Writes to the 8051's exram, which has 16-bits of address space. 1924 * Data at addresses 0x2000-0x7fff is mirrored to 0x8000-0xdfff. 1925 * Data at 0x8000-0xdfff can also be used as program memory for the 8051 by 1926 * setting the pmem bank selection SFR. 1927 * 0xe000-0xffff is always mapped as program memory, with only 0xf000-0xffff 1928 * being writable. 1929 */ 1930 static void chipio_8051_set_address(struct hda_codec *codec, unsigned int addr) 1931 { 1932 unsigned int tmp; 1933 1934 /* Lower 8-bits. */ 1935 tmp = addr & 0xff; 1936 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1937 VENDOR_CHIPIO_8051_ADDRESS_LOW, tmp); 1938 1939 /* Upper 8-bits. */ 1940 tmp = (addr >> 8) & 0xff; 1941 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1942 VENDOR_CHIPIO_8051_ADDRESS_HIGH, tmp); 1943 } 1944 1945 static void chipio_8051_set_data(struct hda_codec *codec, unsigned int data) 1946 { 1947 /* 8-bits of data. */ 1948 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1949 VENDOR_CHIPIO_8051_DATA_WRITE, data & 0xff); 1950 } 1951 1952 static unsigned int chipio_8051_get_data(struct hda_codec *codec) 1953 { 1954 return snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, 1955 VENDOR_CHIPIO_8051_DATA_READ, 0); 1956 } 1957 1958 /* PLL_PMU writes share the lower address register of the 8051 exram writes. */ 1959 static void chipio_8051_set_data_pll(struct hda_codec *codec, unsigned int data) 1960 { 1961 /* 8-bits of data. */ 1962 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1963 VENDOR_CHIPIO_PLL_PMU_WRITE, data & 0xff); 1964 } 1965 1966 static void chipio_8051_write_exram(struct hda_codec *codec, 1967 unsigned int addr, unsigned int data) 1968 { 1969 struct ca0132_spec *spec = codec->spec; 1970 1971 mutex_lock(&spec->chipio_mutex); 1972 1973 chipio_8051_set_address(codec, addr); 1974 chipio_8051_set_data(codec, data); 1975 1976 mutex_unlock(&spec->chipio_mutex); 1977 } 1978 1979 static void chipio_8051_write_exram_no_mutex(struct hda_codec *codec, 1980 unsigned int addr, unsigned int data) 1981 { 1982 chipio_8051_set_address(codec, addr); 1983 chipio_8051_set_data(codec, data); 1984 } 1985 1986 /* Readback data from the 8051's exram. No mutex. */ 1987 static void chipio_8051_read_exram(struct hda_codec *codec, 1988 unsigned int addr, unsigned int *data) 1989 { 1990 chipio_8051_set_address(codec, addr); 1991 *data = chipio_8051_get_data(codec); 1992 } 1993 1994 static void chipio_8051_write_pll_pmu(struct hda_codec *codec, 1995 unsigned int addr, unsigned int data) 1996 { 1997 struct ca0132_spec *spec = codec->spec; 1998 1999 mutex_lock(&spec->chipio_mutex); 2000 2001 chipio_8051_set_address(codec, addr & 0xff); 2002 chipio_8051_set_data_pll(codec, data); 2003 2004 mutex_unlock(&spec->chipio_mutex); 2005 } 2006 2007 static void chipio_8051_write_pll_pmu_no_mutex(struct hda_codec *codec, 2008 unsigned int addr, unsigned int data) 2009 { 2010 chipio_8051_set_address(codec, addr & 0xff); 2011 chipio_8051_set_data_pll(codec, data); 2012 } 2013 2014 /* 1877 2015 * Enable clocks. 1878 2016 */ … … 1882 2020 1883 2021 mutex_lock(&spec->chipio_mutex); 1884 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1885 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0); 1886 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1887 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff); 1888 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1889 VENDOR_CHIPIO_8051_ADDRESS_LOW, 5); 1890 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1891 VENDOR_CHIPIO_PLL_PMU_WRITE, 0x0b); 1892 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1893 VENDOR_CHIPIO_8051_ADDRESS_LOW, 6); 1894 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 1895 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xff); 2022 2023 chipio_8051_write_pll_pmu_no_mutex(codec, 0x00, 0xff); 2024 chipio_8051_write_pll_pmu_no_mutex(codec, 0x05, 0x0b); 2025 chipio_8051_write_pll_pmu_no_mutex(codec, 0x06, 0xff); 2026 1896 2027 mutex_unlock(&spec->chipio_mutex); 1897 2028 } … … 2214 2345 2215 2346 /** 2216 * Prepare and send the SCP message to DSP2347 * dspio_scp - Prepare and send the SCP message to DSP 2217 2348 * @codec: the HDA codec 2218 2349 * @mod_id: ID of the DSP module to send the command … … 2323 2454 } 2324 2455 2325 static int dspio_set_uint_param_no_source(struct hda_codec *codec, int mod_id,2326 int req, const unsigned int data)2327 {2328 return dspio_set_param(codec, mod_id, 0x00, req, &data,2329 sizeof(unsigned int));2330 }2331 2332 2456 /* 2333 2457 * Allocate a DSP DMA channel via an SCP message … … 2748 2872 2749 2873 /** 2750 * Allocate router ports2874 * dsp_allocate_router_ports - Allocate router ports 2751 2875 * 2752 2876 * @codec: the HDA codec … … 3065 3189 3066 3190 /** 3067 * Write a block of data into DSP code or data RAM using pre-allocated 3068 * DMA engine. 3191 * dspxfr_one_seg - Write a block of data into DSP code or data RAM using pre-allocated DMA engine. 3069 3192 * 3070 3193 * @codec: the HDA codec … … 3263 3386 3264 3387 /** 3265 * Write the entire DSP image of a DSP code/data overlay to DSP memories3388 * dspxfr_image - Write the entire DSP image of a DSP code/data overlay to DSP memories 3266 3389 * 3267 3390 * @codec: the HDA codec … … 7017 7140 snd_hda_add_vmaster(codec, "Master Playback Volume", 7018 7141 spec->tlv, ca0132_alt_follower_pfxs, 7019 "Playback Volume" );7142 "Playback Volume", 0); 7020 7143 err = __snd_hda_add_vmaster(codec, "Master Playback Switch", 7021 7144 NULL, ca0132_alt_follower_pfxs, 7022 7145 "Playback Switch", 7023 true, &spec->vmaster_mute.sw_kctl);7146 true, 0, &spec->vmaster_mute.sw_kctl); 7024 7147 if (err < 0) 7025 7148 return err; … … 7488 7611 7489 7612 mutex_lock(&spec->chipio_mutex); 7490 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7491 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x20); 7492 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7493 VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19); 7494 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7495 VENDOR_CHIPIO_8051_DATA_WRITE, 0x00); 7496 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7497 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x2D); 7498 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7499 VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19); 7500 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7501 VENDOR_CHIPIO_8051_DATA_WRITE, 0x00); 7613 7614 chipio_8051_write_exram_no_mutex(codec, 0x1920, 0x00); 7615 chipio_8051_write_exram_no_mutex(codec, 0x192d, 0x00); 7616 7502 7617 mutex_unlock(&spec->chipio_mutex); 7503 7618 } … … 7521 7636 refresh_amp_caps(codec, spec->input_pins[i], HDA_INPUT); 7522 7637 } 7638 } 7639 7640 7641 /* If there is an active channel for some reason, find it and free it. */ 7642 static void ca0132_alt_free_active_dma_channels(struct hda_codec *codec) 7643 { 7644 unsigned int i, tmp; 7645 int status; 7646 7647 /* Read active DSPDMAC channel register. */ 7648 status = chipio_read(codec, DSPDMAC_CHNLSTART_MODULE_OFFSET, &tmp); 7649 if (status >= 0) { 7650 /* AND against 0xfff to get the active channel bits. */ 7651 tmp = tmp & 0xfff; 7652 7653 /* If there are no active channels, nothing to free. */ 7654 if (!tmp) 7655 return; 7656 } else { 7657 codec_dbg(codec, "%s: Failed to read active DSP DMA channel register.\n", 7658 __func__); 7659 return; 7660 } 7661 7662 /* 7663 * Check each DSP DMA channel for activity, and if the channel is 7664 * active, free it. 7665 */ 7666 for (i = 0; i < DSPDMAC_DMA_CFG_CHANNEL_COUNT; i++) { 7667 if (dsp_is_dma_active(codec, i)) { 7668 status = dspio_free_dma_chan(codec, i); 7669 if (status < 0) 7670 codec_dbg(codec, "%s: Failed to free active DSP DMA channel %d.\n", 7671 __func__, i); 7672 } 7673 } 7674 } 7675 7676 /* 7677 * In the case of CT_EXTENSIONS_ENABLE being set to 1, and the DSP being in 7678 * use, audio is no longer routed directly to the DAC/ADC from the HDA stream. 7679 * Instead, audio is now routed through the DSP's DMA controllers, which 7680 * the DSP is tasked with setting up itself. Through debugging, it seems the 7681 * cause of most of the no-audio on startup issues were due to improperly 7682 * configured DSP DMA channels. 7683 * 7684 * Normally, the DSP configures these the first time an HDA audio stream is 7685 * started post DSP firmware download. That is why creating a 'dummy' stream 7686 * worked in fixing the audio in some cases. This works most of the time, but 7687 * sometimes if a stream is started/stopped before the DSP can setup the DMA 7688 * configuration registers, it ends up in a broken state. Issues can also 7689 * arise if streams are started in an unusual order, i.e the audio output dma 7690 * channel being sandwiched between the mic1 and mic2 dma channels. 7691 * 7692 * The solution to this is to make sure that the DSP has no DMA channels 7693 * in use post DSP firmware download, and then to manually start each default 7694 * DSP stream that uses the DMA channels. These are 0x0c, the audio output 7695 * stream, 0x03, analog mic 1, and 0x04, analog mic 2. 7696 */ 7697 static void ca0132_alt_start_dsp_audio_streams(struct hda_codec *codec) 7698 { 7699 const unsigned int dsp_dma_stream_ids[] = { 0x0c, 0x03, 0x04 }; 7700 struct ca0132_spec *spec = codec->spec; 7701 unsigned int i, tmp; 7702 7703 /* 7704 * Check if any of the default streams are active, and if they are, 7705 * stop them. 7706 */ 7707 mutex_lock(&spec->chipio_mutex); 7708 7709 for (i = 0; i < ARRAY_SIZE(dsp_dma_stream_ids); i++) { 7710 chipio_get_stream_control(codec, dsp_dma_stream_ids[i], &tmp); 7711 7712 if (tmp) { 7713 chipio_set_stream_control(codec, 7714 dsp_dma_stream_ids[i], 0); 7715 } 7716 } 7717 7718 mutex_unlock(&spec->chipio_mutex); 7719 7720 /* 7721 * If all DSP streams are inactive, there should be no active DSP DMA 7722 * channels. Check and make sure this is the case, and if it isn't, 7723 * free any active channels. 7724 */ 7725 ca0132_alt_free_active_dma_channels(codec); 7726 7727 mutex_lock(&spec->chipio_mutex); 7728 7729 /* Make sure stream 0x0c is six channels. */ 7730 chipio_set_stream_channels(codec, 0x0c, 6); 7731 7732 for (i = 0; i < ARRAY_SIZE(dsp_dma_stream_ids); i++) { 7733 chipio_set_stream_control(codec, 7734 dsp_dma_stream_ids[i], 1); 7735 7736 /* Give the DSP some time to setup the DMA channel. */ 7737 msleep(75); 7738 } 7739 7740 mutex_unlock(&spec->chipio_mutex); 7741 } 7742 7743 /* 7744 * The region of ChipIO memory from 0x190000-0x1903fc is a sort of 'audio 7745 * router', where each entry represents a 48khz audio channel, with a format 7746 * of an 8-bit destination, an 8-bit source, and an unknown 2-bit number 7747 * value. The 2-bit number value is seemingly 0 if inactive, 1 if active, 7748 * and 3 if it's using Sample Rate Converter ports. 7749 * An example is: 7750 * 0x0001f8c0 7751 * In this case, f8 is the destination, and c0 is the source. The number value 7752 * is 1. 7753 * This region of memory is normally managed internally by the 8051, where 7754 * the region of exram memory from 0x1477-0x1575 has each byte represent an 7755 * entry within the 0x190000 range, and when a range of entries is in use, the 7756 * ending value is overwritten with 0xff. 7757 * 0x1578 in exram is a table of 0x25 entries, corresponding to the ChipIO 7758 * streamID's, where each entry is a starting 0x190000 port offset. 7759 * 0x159d in exram is the same as 0x1578, except it contains the ending port 7760 * offset for the corresponding streamID. 7761 * 7762 * On certain cards, such as the SBZ/ZxR/AE7, these are originally setup by 7763 * the 8051, then manually overwritten to remap the ports to work with the 7764 * new DACs. 7765 * 7766 * Currently known portID's: 7767 * 0x00-0x1f: HDA audio stream input/output ports. 7768 * 0x80-0xbf: Sample rate converter input/outputs. Only valid ports seem to 7769 * have the lower-nibble set to 0x1, 0x2, and 0x9. 7770 * 0xc0-0xdf: DSP DMA input/output ports. Dynamically assigned. 7771 * 0xe0-0xff: DAC/ADC audio input/output ports. 7772 * 7773 * Currently known streamID's: 7774 * 0x03: Mic1 ADC to DSP. 7775 * 0x04: Mic2 ADC to DSP. 7776 * 0x05: HDA node 0x02 audio stream to DSP. 7777 * 0x0f: DSP Mic exit to HDA node 0x07. 7778 * 0x0c: DSP processed audio to DACs. 7779 * 0x14: DAC0, front L/R. 7780 * 7781 * It is possible to route the HDA audio streams directly to the DAC and 7782 * bypass the DSP entirely, with the only downside being that since the DSP 7783 * does volume control, the only volume control you'll get is through PCM on 7784 * the PC side, in the same way volume is handled for optical out. This may be 7785 * useful for debugging. 7786 */ 7787 static void chipio_remap_stream(struct hda_codec *codec, 7788 const struct chipio_stream_remap_data *remap_data) 7789 { 7790 unsigned int i, stream_offset; 7791 7792 /* Get the starting port for the stream to be remapped. */ 7793 chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id, 7794 &stream_offset); 7795 7796 /* 7797 * Check if the stream's port value is 0xff, because the 8051 may not 7798 * have gotten around to setting up the stream yet. Wait until it's 7799 * setup to remap it's ports. 7800 */ 7801 if (stream_offset == 0xff) { 7802 for (i = 0; i < 5; i++) { 7803 msleep(25); 7804 7805 chipio_8051_read_exram(codec, 0x1578 + remap_data->stream_id, 7806 &stream_offset); 7807 7808 if (stream_offset != 0xff) 7809 break; 7810 } 7811 } 7812 7813 if (stream_offset == 0xff) { 7814 codec_info(codec, "%s: Stream 0x%02x ports aren't allocated, remap failed!\n", 7815 __func__, remap_data->stream_id); 7816 return; 7817 } 7818 7819 /* Offset isn't in bytes, its in 32-bit words, so multiply it by 4. */ 7820 stream_offset *= 0x04; 7821 stream_offset += 0x190000; 7822 7823 for (i = 0; i < remap_data->count; i++) { 7824 chipio_write_no_mutex(codec, 7825 stream_offset + remap_data->offset[i], 7826 remap_data->value[i]); 7827 } 7828 7829 /* Update stream map configuration. */ 7830 chipio_write_no_mutex(codec, 0x19042c, 0x00000001); 7523 7831 } 7524 7832 … … 7583 7891 dspio_set_uint_param(codec, 0x96, 7584 7892 SPEAKER_TUNING_FRONT_LEFT_DELAY + i, values[i]); 7585 }7586 7587 /*7588 * Creates a dummy stream to bind the output to. This seems to have to be done7589 * after changing the main outputs source and destination streams.7590 */7591 static void ca0132_alt_create_dummy_stream(struct hda_codec *codec)7592 {7593 struct ca0132_spec *spec = codec->spec;7594 unsigned int stream_format;7595 7596 stream_format = snd_hdac_calc_stream_format(48000, 2,7597 SNDRV_PCM_FORMAT_S32_LE, 32, 0);7598 7599 snd_hda_codec_setup_stream(codec, spec->dacs[0], spec->dsp_stream_id,7600 0, stream_format);7601 7602 snd_hda_codec_cleanup_stream(codec, spec->dacs[0]);7603 7893 } 7604 7894 … … 7644 7934 codec_dbg(codec, "Connect Streams entered, mutex locked and loaded.\n"); 7645 7935 7646 chipio_set_stream_channels(codec, 0x0C, 6);7647 chipio_set_stream_control(codec, 0x0C, 1);7648 7649 7936 /* This value is 0x43 for 96khz, and 0x83 for 192khz. */ 7650 7937 chipio_write_no_mutex(codec, 0x18a020, 0x00000043); … … 7670 7957 static void sbz_chipio_startup_data(struct hda_codec *codec) 7671 7958 { 7959 const struct chipio_stream_remap_data *dsp_out_remap_data; 7672 7960 struct ca0132_spec *spec = codec->spec; 7673 7961 … … 7675 7963 codec_dbg(codec, "Startup Data entered, mutex locked and loaded.\n"); 7676 7964 7677 /* These control audio output */ 7678 chipio_write_no_mutex(codec, 0x190060, 0x0001f8c0); 7679 chipio_write_no_mutex(codec, 0x190064, 0x0001f9c1); 7680 chipio_write_no_mutex(codec, 0x190068, 0x0001fac6); 7681 chipio_write_no_mutex(codec, 0x19006c, 0x0001fbc7); 7682 /* Signal to update I think */ 7683 chipio_write_no_mutex(codec, 0x19042c, 0x00000001); 7684 7685 chipio_set_stream_channels(codec, 0x0C, 6); 7686 chipio_set_stream_control(codec, 0x0C, 1); 7687 /* No clue what these control */ 7688 if (ca0132_quirk(spec) == QUIRK_SBZ) { 7689 chipio_write_no_mutex(codec, 0x190030, 0x0001e0c0); 7690 chipio_write_no_mutex(codec, 0x190034, 0x0001e1c1); 7691 chipio_write_no_mutex(codec, 0x190038, 0x0001e4c2); 7692 chipio_write_no_mutex(codec, 0x19003c, 0x0001e5c3); 7693 chipio_write_no_mutex(codec, 0x190040, 0x0001e2c4); 7694 chipio_write_no_mutex(codec, 0x190044, 0x0001e3c5); 7695 chipio_write_no_mutex(codec, 0x190048, 0x0001e8c6); 7696 chipio_write_no_mutex(codec, 0x19004c, 0x0001e9c7); 7697 chipio_write_no_mutex(codec, 0x190050, 0x0001ecc8); 7698 chipio_write_no_mutex(codec, 0x190054, 0x0001edc9); 7699 chipio_write_no_mutex(codec, 0x190058, 0x0001eaca); 7700 chipio_write_no_mutex(codec, 0x19005c, 0x0001ebcb); 7701 } else if (ca0132_quirk(spec) == QUIRK_ZXR) { 7702 chipio_write_no_mutex(codec, 0x190038, 0x000140c2); 7703 chipio_write_no_mutex(codec, 0x19003c, 0x000141c3); 7704 chipio_write_no_mutex(codec, 0x190040, 0x000150c4); 7705 chipio_write_no_mutex(codec, 0x190044, 0x000151c5); 7706 chipio_write_no_mutex(codec, 0x190050, 0x000142c8); 7707 chipio_write_no_mutex(codec, 0x190054, 0x000143c9); 7708 chipio_write_no_mutex(codec, 0x190058, 0x000152ca); 7709 chipio_write_no_mutex(codec, 0x19005c, 0x000153cb); 7710 } 7711 chipio_write_no_mutex(codec, 0x19042c, 0x00000001); 7965 /* Remap DAC0's output ports. */ 7966 chipio_remap_stream(codec, &stream_remap_data[0]); 7967 7968 /* Remap DSP audio output stream ports. */ 7969 switch (ca0132_quirk(spec)) { 7970 case QUIRK_SBZ: 7971 dsp_out_remap_data = &stream_remap_data[1]; 7972 break; 7973 7974 case QUIRK_ZXR: 7975 dsp_out_remap_data = &stream_remap_data[2]; 7976 break; 7977 7978 default: 7979 dsp_out_remap_data = NULL; 7980 break; 7981 } 7982 7983 if (dsp_out_remap_data) 7984 chipio_remap_stream(codec, dsp_out_remap_data); 7712 7985 7713 7986 codec_dbg(codec, "Startup Data exited, mutex released.\n"); 7714 7987 mutex_unlock(&spec->chipio_mutex); 7715 }7716 7717 /*7718 * Custom DSP SCP commands where the src value is 0x00 instead of 0x20. This is7719 * done after the DSP is loaded.7720 */7721 static void ca0132_alt_dsp_scp_startup(struct hda_codec *codec)7722 {7723 struct ca0132_spec *spec = codec->spec;7724 unsigned int tmp, i;7725 7726 /*7727 * Gotta run these twice, or else mic works inconsistently. Not clear7728 * why this is, but multiple tests have confirmed it.7729 */7730 for (i = 0; i < 2; i++) {7731 switch (ca0132_quirk(spec)) {7732 case QUIRK_SBZ:7733 case QUIRK_AE5:7734 case QUIRK_AE7:7735 tmp = 0x00000003;7736 dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);7737 tmp = 0x00000000;7738 dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp);7739 tmp = 0x00000001;7740 dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp);7741 tmp = 0x00000004;7742 dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);7743 tmp = 0x00000005;7744 dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);7745 tmp = 0x00000000;7746 dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);7747 break;7748 case QUIRK_R3D:7749 case QUIRK_R3DI:7750 tmp = 0x00000000;7751 dspio_set_uint_param_no_source(codec, 0x80, 0x0A, tmp);7752 tmp = 0x00000001;7753 dspio_set_uint_param_no_source(codec, 0x80, 0x0B, tmp);7754 tmp = 0x00000004;7755 dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);7756 tmp = 0x00000005;7757 dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);7758 tmp = 0x00000000;7759 dspio_set_uint_param_no_source(codec, 0x80, 0x0C, tmp);7760 break;7761 default:7762 break;7763 }7764 msleep(100);7765 }7766 7988 } 7767 7989 … … 7802 8024 7803 8025 chipio_8051_write_direct(codec, 0x93, 0x10); 7804 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7805 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x44); 7806 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7807 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc2); 8026 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); 7808 8027 7809 8028 writeb(0xff, spec->mem_base + 0x304); … … 7842 8061 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 0); 7843 8062 7844 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7845 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x92); 7846 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7847 VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0xfa); 7848 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7849 VENDOR_CHIPIO_8051_DATA_WRITE, 0x22); 8063 chipio_8051_write_exram(codec, 0xfa92, 0x22); 7850 8064 } 7851 8065 7852 8066 static void ae5_post_dsp_pll_setup(struct hda_codec *codec) 7853 8067 { 7854 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7855 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x41); 7856 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7857 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc8); 7858 7859 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7860 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x45); 7861 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7862 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xcc); 7863 7864 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7865 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x40); 7866 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7867 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xcb); 7868 7869 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7870 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43); 7871 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7872 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7); 7873 7874 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7875 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x51); 7876 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7877 VENDOR_CHIPIO_PLL_PMU_WRITE, 0x8d); 8068 chipio_8051_write_pll_pmu(codec, 0x41, 0xc8); 8069 chipio_8051_write_pll_pmu(codec, 0x45, 0xcc); 8070 chipio_8051_write_pll_pmu(codec, 0x40, 0xcb); 8071 chipio_8051_write_pll_pmu(codec, 0x43, 0xc7); 8072 chipio_8051_write_pll_pmu(codec, 0x51, 0x8d); 7878 8073 } 7879 8074 … … 7887 8082 7888 8083 chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000); 7889 7890 chipio_set_stream_channels(codec, 0x0C, 6);7891 chipio_set_stream_control(codec, 0x0C, 1);7892 8084 7893 8085 chipio_set_stream_source_dest(codec, 0x5, 0x43, 0x0); … … 7900 8092 chipio_set_control_param_no_mutex(codec, CONTROL_PARAM_ASI, 4); 7901 8093 7902 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7903 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43); 7904 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 7905 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7); 8094 chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7); 7906 8095 7907 8096 ca0113_mmio_command_set(codec, 0x48, 0x01, 0x80); … … 7942 8131 } 7943 8132 7944 static const unsigned int ae7_port_set_data[] = {7945 0x0001e0c0, 0x0001e1c1, 0x0001e4c2, 0x0001e5c3, 0x0001e2c4, 0x0001e3c5,7946 0x0001e8c6, 0x0001e9c7, 0x0001ecc8, 0x0001edc9, 0x0001eaca, 0x0001ebcb7947 };7948 7949 8133 static void ae7_post_dsp_setup_ports(struct hda_codec *codec) 7950 8134 { 7951 8135 struct ca0132_spec *spec = codec->spec; 7952 unsigned int i, count, addr;7953 8136 7954 8137 mutex_lock(&spec->chipio_mutex); 7955 8138 7956 chipio_set_stream_channels(codec, 0x0c, 6); 7957 chipio_set_stream_control(codec, 0x0c, 1); 7958 7959 count = ARRAY_SIZE(ae7_port_set_data); 7960 addr = 0x190030; 7961 for (i = 0; i < count; i++) { 7962 chipio_write_no_mutex(codec, addr, ae7_port_set_data[i]); 7963 7964 /* Addresses are incremented by 4-bytes. */ 7965 addr += 0x04; 7966 } 7967 7968 /* 7969 * Port setting always ends with a write of 0x1 to address 0x19042c. 7970 */ 7971 chipio_write_no_mutex(codec, 0x19042c, 0x00000001); 8139 /* Seems to share the same port remapping as the SBZ. */ 8140 chipio_remap_stream(codec, &stream_remap_data[1]); 7972 8141 7973 8142 ca0113_mmio_command_set(codec, 0x30, 0x30, 0x00); … … 7993 8162 7994 8163 chipio_set_conn_rate_no_mutex(codec, 0x70, SR_96_000); 7995 chipio_set_stream_channels(codec, 0x0c, 6);7996 chipio_set_stream_control(codec, 0x0c, 1);7997 8164 7998 8165 chipio_set_stream_source_dest(codec, 0x05, 0x43, 0x00); … … 8018 8185 unsigned int i; 8019 8186 8020 for (i = 0; i < ARRAY_SIZE(addr); i++) { 8021 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8022 VENDOR_CHIPIO_8051_ADDRESS_LOW, addr[i]); 8023 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8024 VENDOR_CHIPIO_PLL_PMU_WRITE, data[i]); 8025 } 8187 for (i = 0; i < ARRAY_SIZE(addr); i++) 8188 chipio_8051_write_pll_pmu_no_mutex(codec, addr[i], data[i]); 8026 8189 } 8027 8190 … … 8039 8202 mutex_lock(&spec->chipio_mutex); 8040 8203 8041 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8042 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43); 8043 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8044 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7); 8204 chipio_8051_write_pll_pmu_no_mutex(codec, 0x43, 0xc7); 8045 8205 8046 8206 chipio_write_no_mutex(codec, 0x189000, 0x0001f101); … … 8115 8275 chipio_8051_write_direct(codec, 0x93, 0x10); 8116 8276 8117 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8118 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x44); 8119 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8120 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc2); 8277 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); 8121 8278 8122 8279 ca0113_mmio_command_set_type2(codec, 0x48, 0x07, 0x83); … … 8130 8287 snd_hda_codec_write(codec, 0x17, 0, 0x794, 0x00); 8131 8288 8132 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8133 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x92); 8134 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8135 VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0xfa); 8136 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8137 VENDOR_CHIPIO_8051_DATA_WRITE, 0x22); 8289 chipio_8051_write_exram(codec, 0xfa92, 0x22); 8138 8290 8139 8291 ae7_post_dsp_pll_setup(codec); 8140 8292 ae7_post_dsp_asi_stream_setup(codec); 8141 8293 8142 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8143 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x43); 8144 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 8145 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc7); 8294 chipio_8051_write_pll_pmu(codec, 0x43, 0xc7); 8146 8295 8147 8296 ae7_post_dsp_asi_setup_ports(codec); … … 8206 8355 return; 8207 8356 8208 ca0132_alt_dsp_scp_startup(codec);8209 8357 ca0132_alt_init_analog_mics(codec); 8358 ca0132_alt_start_dsp_audio_streams(codec); 8210 8359 8211 8360 /*remove DSP headroom*/ … … 8256 8405 return; 8257 8406 8258 ca0132_alt_dsp_scp_startup(codec);8259 8407 ca0132_alt_init_analog_mics(codec); 8408 ca0132_alt_start_dsp_audio_streams(codec); 8260 8409 sbz_connect_streams(codec); 8261 8410 sbz_chipio_startup_data(codec); 8262 8263 chipio_set_stream_control(codec, 0x03, 1);8264 chipio_set_stream_control(codec, 0x04, 1);8265 8411 8266 8412 /* … … 8298 8444 8299 8445 ca0132_alt_init_speaker_tuning(codec); 8300 8301 ca0132_alt_create_dummy_stream(codec);8302 8446 } 8303 8447 … … 8315 8459 return; 8316 8460 8317 ca0132_alt_dsp_scp_startup(codec);8318 8461 ca0132_alt_init_analog_mics(codec); 8319 chipio_set_stream_control(codec, 0x03, 1); 8320 chipio_set_stream_control(codec, 0x04, 1); 8462 ca0132_alt_start_dsp_audio_streams(codec); 8321 8463 8322 8464 /* New, unknown SCP req's */ … … 8367 8509 8368 8510 ca0132_alt_init_speaker_tuning(codec); 8369 8370 ca0132_alt_create_dummy_stream(codec);8371 8511 } 8372 8512 … … 8384 8524 return; 8385 8525 8386 ca0132_alt_dsp_scp_startup(codec);8387 8526 ca0132_alt_init_analog_mics(codec); 8527 ca0132_alt_start_dsp_audio_streams(codec); 8388 8528 ae7_post_dsp_setup_ports(codec); 8389 8529 … … 8452 8592 8453 8593 ca0132_alt_init_speaker_tuning(codec); 8454 8455 ca0132_alt_create_dummy_stream(codec);8456 8594 } 8457 8595 … … 8644 8782 } 8645 8783 8646 static void ca0132_ init_unsol(struct hda_codec *codec)8784 static void ca0132_setup_unsol(struct hda_codec *codec) 8647 8785 { 8648 8786 struct ca0132_spec *spec = codec->spec; … … 8742 8880 mutex_init(&spec->chipio_mutex); 8743 8881 8882 /* 8883 * The Windows driver always does this upon startup, which seems to 8884 * clear out any previous configuration. This should help issues where 8885 * a boot into Windows prior to a boot into Linux breaks things. Also, 8886 * Windows always sends the reset twice. 8887 */ 8888 if (ca0132_use_alt_functions(spec)) { 8889 chipio_set_control_flag(codec, CONTROL_FLAG_IDLE_ENABLE, 0); 8890 chipio_write_no_mutex(codec, 0x18b0a4, 0x000000c2); 8891 8892 snd_hda_codec_write(codec, codec->core.afg, 0, 8893 AC_VERB_SET_CODEC_RESET, 0); 8894 snd_hda_codec_write(codec, codec->core.afg, 0, 8895 AC_VERB_SET_CODEC_RESET, 0); 8896 } 8897 8744 8898 spec->cur_out_type = SPEAKER_OUT; 8745 8899 if (!ca0132_use_alt_functions(spec)) … … 9114 9268 chipio_write(codec, 0x18b0a4, 0x000000c2); 9115 9269 9116 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9117 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x1E); 9118 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9119 VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x1C); 9120 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9121 VENDOR_CHIPIO_8051_DATA_WRITE, 0x5B); 9270 chipio_8051_write_exram(codec, 0x1c1e, 0x5b); 9122 9271 9123 9272 snd_hda_codec_write(codec, 0x11, 0, … … 9129 9278 chipio_write(codec, 0x18b0a4, 0x000000c2); 9130 9279 9131 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9132 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x1E); 9133 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9134 VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x1C); 9135 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9136 VENDOR_CHIPIO_8051_DATA_WRITE, 0x5B); 9137 9138 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9139 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x20); 9140 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9141 VENDOR_CHIPIO_8051_ADDRESS_HIGH, 0x19); 9142 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9143 VENDOR_CHIPIO_8051_DATA_WRITE, 0x00); 9144 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9145 VENDOR_CHIPIO_8051_DATA_WRITE, 0x40); 9280 chipio_8051_write_exram(codec, 0x1c1e, 0x5b); 9281 chipio_8051_write_exram(codec, 0x1920, 0x00); 9282 chipio_8051_write_exram(codec, 0x1921, 0x40); 9146 9283 9147 9284 snd_hda_codec_write(codec, 0x11, 0, 9148 9285 AC_VERB_SET_PIN_WIDGET_CONTROL, 0x04); 9286 } 9287 9288 /* 9289 * The ZxR seems to use alternative DAC's for the surround channels, which 9290 * require PLL PMU setup for the clock rate, I'm guessing. Without setting 9291 * this up, we get no audio out of the surround jacks. 9292 */ 9293 static void zxr_pre_dsp_setup(struct hda_codec *codec) 9294 { 9295 static const unsigned int addr[] = { 0x43, 0x40, 0x41, 0x42, 0x45 }; 9296 static const unsigned int data[] = { 0x08, 0x0c, 0x0b, 0x07, 0x0d }; 9297 unsigned int i; 9298 9299 chipio_write(codec, 0x189000, 0x0001f100); 9300 msleep(50); 9301 chipio_write(codec, 0x18900c, 0x0001f100); 9302 msleep(50); 9303 9304 /* 9305 * This writes a RET instruction at the entry point of the function at 9306 * 0xfa92 in exram. This function seems to have something to do with 9307 * ASI. Might be some way to prevent the card from reconfiguring the 9308 * ASI stuff itself. 9309 */ 9310 chipio_8051_write_exram(codec, 0xfa92, 0x22); 9311 9312 chipio_8051_write_pll_pmu(codec, 0x51, 0x98); 9313 9314 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 0x725, 0x82); 9315 chipio_set_control_param(codec, CONTROL_PARAM_ASI, 3); 9316 9317 chipio_write(codec, 0x18902c, 0x00000000); 9318 msleep(50); 9319 chipio_write(codec, 0x18902c, 0x00000003); 9320 msleep(50); 9321 9322 for (i = 0; i < ARRAY_SIZE(addr); i++) 9323 chipio_8051_write_pll_pmu(codec, addr[i], data[i]); 9149 9324 } 9150 9325 … … 9313 9488 unsigned char tmp[3]; 9314 9489 9315 if (ca0132_quirk(spec) == QUIRK_AE7) { 9316 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9317 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x41); 9318 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9319 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc8); 9320 } 9490 if (ca0132_quirk(spec) == QUIRK_AE7) 9491 chipio_8051_write_pll_pmu(codec, 0x41, 0xc8); 9321 9492 9322 9493 chipio_8051_write_direct(codec, 0x93, 0x10); 9323 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9324 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x44); 9325 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9326 VENDOR_CHIPIO_PLL_PMU_WRITE, 0xc2); 9494 chipio_8051_write_pll_pmu(codec, 0x44, 0xc2); 9327 9495 9328 9496 if (ca0132_quirk(spec) == QUIRK_AE7) { … … 9363 9531 if (ca0132_quirk(spec) == QUIRK_AE5) 9364 9532 ca0113_mmio_command_set(codec, 0x48, 0x07, 0x83); 9365 9366 chipio_write(codec, 0x18b0a4, 0x000000c2);9367 9368 snd_hda_codec_write(codec, 0x01, 0, 0x7ff, 0x00);9369 snd_hda_codec_write(codec, 0x01, 0, 0x7ff, 0x00);9370 9533 } 9371 9534 … … 9405 9568 case QUIRK_AE5: 9406 9569 ca0132_gpio_init(codec); 9407 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9408 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x49); 9409 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9410 VENDOR_CHIPIO_PLL_PMU_WRITE, 0x88); 9570 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); 9411 9571 chipio_write(codec, 0x18b030, 0x00000020); 9412 9572 snd_hda_sequence_write(codec, spec->chip_init_verbs); … … 9416 9576 case QUIRK_AE7: 9417 9577 ca0132_gpio_init(codec); 9418 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9419 VENDOR_CHIPIO_8051_ADDRESS_LOW, 0x49); 9420 snd_hda_codec_write(codec, WIDGET_CHIP_CTRL, 0, 9421 VENDOR_CHIPIO_PLL_PMU_WRITE, 0x88); 9578 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); 9422 9579 snd_hda_sequence_write(codec, spec->chip_init_verbs); 9423 9580 snd_hda_sequence_write(codec, spec->desktop_init_verbs); … … 9428 9585 break; 9429 9586 case QUIRK_ZXR: 9587 chipio_8051_write_pll_pmu(codec, 0x49, 0x88); 9430 9588 snd_hda_sequence_write(codec, spec->chip_init_verbs); 9431 9589 snd_hda_sequence_write(codec, spec->desktop_init_verbs); 9590 zxr_pre_dsp_setup(codec); 9432 9591 break; 9433 9592 default: … … 9477 9636 ae5_register_set(codec); 9478 9637 9479 ca0132_init_unsol(codec);9480 9638 ca0132_init_params(codec); 9481 9639 ca0132_init_flags(codec); … … 10042 10200 goto error; 10043 10201 10202 ca0132_setup_unsol(codec); 10203 10044 10204 return 0; 10045 10205 -
GPL/trunk/alsa-kernel/pci/hda/patch_cirrus.c
r679 r695 10 10 #include <linux/module.h> 11 11 #include <sound/core.h> 12 #include <linux/mutex.h> 13 #include <linux/pci.h> 12 14 #include <sound/tlv.h> 13 15 #include <sound/hda_codec.h> … … 24 26 */ 25 27 28 #define CS42L42_HP_CH (2U) 29 #define CS42L42_HS_MIC_CH (1U) 30 26 31 struct cs_spec { 27 32 struct hda_gen_spec gen; … … 42 47 int (*spdif_sw_put)(struct snd_kcontrol *kcontrol, 43 48 struct snd_ctl_elem_value *ucontrol); 49 50 unsigned int cs42l42_hp_jack_in:1; 51 unsigned int cs42l42_mic_jack_in:1; 52 unsigned int cs42l42_volume_init:1; 53 char cs42l42_hp_volume[CS42L42_HP_CH]; 54 char cs42l42_hs_mic_volume[CS42L42_HS_MIC_CH]; 55 56 struct mutex cs8409_i2c_mux; 57 58 /* verb exec op override */ 59 int (*exec_verb)(struct hdac_device *dev, unsigned int cmd, 60 unsigned int flags, unsigned int *res); 44 61 }; 45 62 … … 115 132 * 1 ADC <= LineIn(sense) / MicIn / DMicIn, 116 133 * 1 SPDIF OUT => SPDIF Trasmitter(sense) 117 */134 */ 118 135 #define CS4210_DAC_NID 0x02 119 136 #define CS4210_ADC_NID 0x03 … … 134 151 { 135 152 struct cs_spec *spec = codec->spec; 153 136 154 snd_hda_codec_write(codec, spec->vendor_nid, 0, 137 155 AC_VERB_SET_COEF_INDEX, idx); … … 144 162 { 145 163 struct cs_spec *spec = codec->spec; 164 146 165 snd_hda_codec_write(codec, spec->vendor_nid, 0, 147 166 AC_VERB_SET_COEF_INDEX, idx); … … 180 199 { 181 200 unsigned int val; 201 182 202 val = snd_hda_codec_get_pincfg(codec, nid); 183 203 return (get_defcfg_connect(val) != AC_JACK_PORT_NONE); … … 198 218 * No effect if SPDIF_OUT2 is 199 219 * selected in IDX_SPDIF_CTL. 200 */220 */ 201 221 202 222 cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef); … … 272 292 {0x11, AC_VERB_SET_PROC_COEF, 0x0008}, 273 293 {0x11, AC_VERB_SET_PROC_STATE, 0x00}, 274 275 #if 0 /* Don't to set to D3 as we are in power-up sequence */276 {0x07, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Rx: D3 */277 {0x08, AC_VERB_SET_POWER_STATE, 0x03}, /* S/PDIF Tx: D3 */278 /*{0x01, AC_VERB_SET_POWER_STATE, 0x03},*/ /* AFG: D3 This is already handled */279 #endif280 281 294 {0} /* terminator */ 282 295 }; … … 366 379 if (spec->gen.dyn_adc_switch) { 367 380 unsigned int done = 0; 381 368 382 for (i = 0; i < spec->gen.input_mux.num_items; i++) { 369 383 int idx = spec->gen.dyn_adc_idx[i]; 384 370 385 if (done & (1 << idx)) 371 386 continue; … … 501 516 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 502 517 struct cs_spec *spec = codec->spec; 518 503 519 spec->gpio_eapd_hp = 2; /* GPIO1 = headphones */ 504 520 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ … … 513 529 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 514 530 struct cs_spec *spec = codec->spec; 531 515 532 spec->gpio_eapd_hp = 4; /* GPIO2 = headphones */ 516 533 spec->gpio_eapd_speaker = 8; /* GPIO3 = speakers */ … … 659 676 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 660 677 struct cs_spec *spec = codec->spec; 678 661 679 spec->gpio_eapd_hp = 0; 662 680 spec->gpio_eapd_speaker = 1; … … 813 831 * 1 ADC <= LineIn(sense) / MicIn / DMicIn, 814 832 * 1 SPDIF OUT => SPDIF Trasmitter(sense) 815 */833 */ 816 834 817 835 /* CS4210 board names */ … … 856 874 { 857 875 struct cs_spec *spec = codec->spec; 876 858 877 if (action == HDA_FIXUP_ACT_PRE_PROBE) 859 878 spec->sense_b = 1; … … 881 900 {0x0B, AC_VERB_SET_COEF_INDEX, CS421X_IDX_DEV_CFG}, 882 901 /* 883 Disable Coefficient Index Auto-Increment(DAI)=1,884 PDREF=0885 */902 * Disable Coefficient Index Auto-Increment(DAI)=1, 903 * PDREF=0 904 */ 886 905 {0x0B, AC_VERB_SET_PROC_COEF, 0x0001 }, 887 906 … … 970 989 coef &= ~0x0003; 971 990 coef |= (vol & 0x0003); 972 if (original_coef == coef) 973 return 0; 974 else { 991 if (original_coef != coef) { 975 992 cs_vendor_coef_set(codec, CS421X_IDX_SPK_CTL, coef); 976 993 return 1; 977 994 } 995 996 return 0; 978 997 } 979 998 … … 1014 1033 1015 1034 /* 1016 GPIO or SENSE_B forced - disconnect the DMIC pin.1017 */1035 * GPIO or SENSE_B forced - disconnect the DMIC pin. 1036 */ 1018 1037 def_conf = snd_hda_codec_get_pincfg(codec, CS421X_DMIC_PIN_NID); 1019 1038 def_conf &= ~AC_DEFCFG_PORT_CONN; … … 1054 1073 for (i = 0; i < cfg->dig_outs; i++) { 1055 1074 hda_nid_t nid = cfg->dig_out_pins[i]; 1075 1056 1076 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { 1057 1077 spec->spdif_detect = 1; … … 1132 1152 #ifdef CONFIG_PM 1133 1153 /* 1134 Manage PDREF, when transitioning to D3hot1135 (DAC,ADC) -> D3, PDREF=1, AFG->D31136 */1154 * Manage PDREF, when transitioning to D3hot 1155 * (DAC,ADC) -> D3, PDREF=1, AFG->D3 1156 */ 1137 1157 static int cs421x_suspend(struct hda_codec *codec) 1138 1158 { … … 1185 1205 1186 1206 /* 1187 Update the GPIO/DMIC/SENSE_B pinmux before the configuration1188 is auto-parsed. If GPIO or SENSE_B is forced, DMIC input1189 is disabled.1190 */1207 * Update the GPIO/DMIC/SENSE_B pinmux before the configuration 1208 * is auto-parsed. If GPIO or SENSE_B is forced, DMIC input 1209 * is disabled. 1210 */ 1191 1211 cs4210_pinmux_init(codec); 1192 1212 … … 1226 1246 } 1227 1247 1248 /* Cirrus Logic CS8409 HDA bridge with 1249 * companion codec CS42L42 1250 */ 1251 #define CS8409_VENDOR_NID 0x47 1252 1253 #define CS8409_CS42L42_HP_PIN_NID 0x24 1254 #define CS8409_CS42L42_SPK_PIN_NID 0x2c 1255 #define CS8409_CS42L42_AMIC_PIN_NID 0x34 1256 #define CS8409_CS42L42_DMIC_PIN_NID 0x44 1257 #define CS8409_CS42L42_DMIC_ADC_PIN_NID 0x22 1258 1259 #define CS42L42_HSDET_AUTO_DONE 0x02 1260 #define CS42L42_HSTYPE_MASK 0x03 1261 1262 #define CS42L42_JACK_INSERTED 0x0C 1263 #define CS42L42_JACK_REMOVED 0x00 1264 1265 #define GPIO3_INT (1 << 3) 1266 #define GPIO4_INT (1 << 4) 1267 #define GPIO5_INT (1 << 5) 1268 1269 #define CS42L42_I2C_ADDR (0x48 << 1) 1270 1271 #define CIR_I2C_ADDR 0x0059 1272 #define CIR_I2C_DATA 0x005A 1273 #define CIR_I2C_CTRL 0x005B 1274 #define CIR_I2C_STATUS 0x005C 1275 #define CIR_I2C_QWRITE 0x005D 1276 #define CIR_I2C_QREAD 0x005E 1277 1278 #define CS8409_CS42L42_HP_VOL_REAL_MIN (-63) 1279 #define CS8409_CS42L42_HP_VOL_REAL_MAX (0) 1280 #define CS8409_CS42L42_AMIC_VOL_REAL_MIN (-97) 1281 #define CS8409_CS42L42_AMIC_VOL_REAL_MAX (12) 1282 #define CS8409_CS42L42_REG_HS_VOLUME_CHA (0x2301) 1283 #define CS8409_CS42L42_REG_HS_VOLUME_CHB (0x2303) 1284 #define CS8409_CS42L42_REG_AMIC_VOLUME (0x1D03) 1285 1286 struct cs8409_i2c_param { 1287 unsigned int addr; 1288 unsigned int reg; 1289 }; 1290 1291 struct cs8409_cir_param { 1292 unsigned int nid; 1293 unsigned int cir; 1294 unsigned int coeff; 1295 }; 1296 1297 enum { 1298 CS8409_BULLSEYE, 1299 CS8409_WARLOCK, 1300 CS8409_CYBORG, 1301 CS8409_FIXUPS, 1302 }; 1303 1304 static void cs8409_cs42l42_fixups(struct hda_codec *codec, 1305 const struct hda_fixup *fix, int action); 1306 static int cs8409_cs42l42_exec_verb(struct hdac_device *dev, 1307 unsigned int cmd, unsigned int flags, unsigned int *res); 1308 1309 /* Dell Inspiron models with cs8409/cs42l42 */ 1310 static const struct hda_model_fixup cs8409_models[] = { 1311 { .id = CS8409_BULLSEYE, .name = "bullseye" }, 1312 { .id = CS8409_WARLOCK, .name = "warlock" }, 1313 { .id = CS8409_CYBORG, .name = "cyborg" }, 1314 {0} 1315 }; 1316 1317 /* Dell Inspiron platforms 1318 * with cs8409 bridge and cs42l42 codec 1319 */ 1320 static const struct snd_pci_quirk cs8409_fixup_tbl[] = { 1321 SND_PCI_QUIRK(0x1028, 0x0A11, "Bullseye", CS8409_BULLSEYE), 1322 SND_PCI_QUIRK(0x1028, 0x0A12, "Bullseye", CS8409_BULLSEYE), 1323 SND_PCI_QUIRK(0x1028, 0x0A23, "Bullseye", CS8409_BULLSEYE), 1324 SND_PCI_QUIRK(0x1028, 0x0A24, "Bullseye", CS8409_BULLSEYE), 1325 SND_PCI_QUIRK(0x1028, 0x0A25, "Bullseye", CS8409_BULLSEYE), 1326 SND_PCI_QUIRK(0x1028, 0x0A29, "Bullseye", CS8409_BULLSEYE), 1327 SND_PCI_QUIRK(0x1028, 0x0A2A, "Bullseye", CS8409_BULLSEYE), 1328 SND_PCI_QUIRK(0x1028, 0x0A2B, "Bullseye", CS8409_BULLSEYE), 1329 SND_PCI_QUIRK(0x1028, 0x0AB0, "Warlock", CS8409_WARLOCK), 1330 SND_PCI_QUIRK(0x1028, 0x0AB2, "Warlock", CS8409_WARLOCK), 1331 SND_PCI_QUIRK(0x1028, 0x0AB1, "Warlock", CS8409_WARLOCK), 1332 SND_PCI_QUIRK(0x1028, 0x0AB3, "Warlock", CS8409_WARLOCK), 1333 SND_PCI_QUIRK(0x1028, 0x0AB4, "Warlock", CS8409_WARLOCK), 1334 SND_PCI_QUIRK(0x1028, 0x0AB5, "Warlock", CS8409_WARLOCK), 1335 SND_PCI_QUIRK(0x1028, 0x0AD9, "Warlock", CS8409_WARLOCK), 1336 SND_PCI_QUIRK(0x1028, 0x0ADA, "Warlock", CS8409_WARLOCK), 1337 SND_PCI_QUIRK(0x1028, 0x0ADB, "Warlock", CS8409_WARLOCK), 1338 SND_PCI_QUIRK(0x1028, 0x0ADC, "Warlock", CS8409_WARLOCK), 1339 SND_PCI_QUIRK(0x1028, 0x0AF4, "Warlock", CS8409_WARLOCK), 1340 SND_PCI_QUIRK(0x1028, 0x0AF5, "Warlock", CS8409_WARLOCK), 1341 SND_PCI_QUIRK(0x1028, 0x0A77, "Cyborg", CS8409_CYBORG), 1342 SND_PCI_QUIRK(0x1028, 0x0A78, "Cyborg", CS8409_CYBORG), 1343 SND_PCI_QUIRK(0x1028, 0x0A79, "Cyborg", CS8409_CYBORG), 1344 SND_PCI_QUIRK(0x1028, 0x0A7A, "Cyborg", CS8409_CYBORG), 1345 SND_PCI_QUIRK(0x1028, 0x0A7D, "Cyborg", CS8409_CYBORG), 1346 SND_PCI_QUIRK(0x1028, 0x0A7E, "Cyborg", CS8409_CYBORG), 1347 SND_PCI_QUIRK(0x1028, 0x0A7F, "Cyborg", CS8409_CYBORG), 1348 SND_PCI_QUIRK(0x1028, 0x0A80, "Cyborg", CS8409_CYBORG), 1349 SND_PCI_QUIRK(0x1028, 0x0ADF, "Cyborg", CS8409_CYBORG), 1350 SND_PCI_QUIRK(0x1028, 0x0AE0, "Cyborg", CS8409_CYBORG), 1351 SND_PCI_QUIRK(0x1028, 0x0AE1, "Cyborg", CS8409_CYBORG), 1352 SND_PCI_QUIRK(0x1028, 0x0AE2, "Cyborg", CS8409_CYBORG), 1353 SND_PCI_QUIRK(0x1028, 0x0AE9, "Cyborg", CS8409_CYBORG), 1354 SND_PCI_QUIRK(0x1028, 0x0AEA, "Cyborg", CS8409_CYBORG), 1355 SND_PCI_QUIRK(0x1028, 0x0AEB, "Cyborg", CS8409_CYBORG), 1356 SND_PCI_QUIRK(0x1028, 0x0AEC, "Cyborg", CS8409_CYBORG), 1357 SND_PCI_QUIRK(0x1028, 0x0AED, "Cyborg", CS8409_CYBORG), 1358 SND_PCI_QUIRK(0x1028, 0x0AEE, "Cyborg", CS8409_CYBORG), 1359 SND_PCI_QUIRK(0x1028, 0x0AEF, "Cyborg", CS8409_CYBORG), 1360 SND_PCI_QUIRK(0x1028, 0x0AF0, "Cyborg", CS8409_CYBORG), 1361 {0} /* terminator */ 1362 }; 1363 1364 static const struct hda_verb cs8409_cs42l42_init_verbs[] = { 1365 { 0x01, AC_VERB_SET_GPIO_WAKE_MASK, 0x0018 }, /* WAKE from GPIO 3,4 */ 1366 { 0x47, AC_VERB_SET_PROC_STATE, 0x0001 }, /* Enable VPW processing */ 1367 { 0x47, AC_VERB_SET_COEF_INDEX, 0x0002 }, /* Configure GPIO 6,7 */ 1368 { 0x47, AC_VERB_SET_PROC_COEF, 0x0080 }, /* I2C mode */ 1369 { 0x47, AC_VERB_SET_COEF_INDEX, 0x005b }, /* Set I2C bus speed */ 1370 { 0x47, AC_VERB_SET_PROC_COEF, 0x0200 }, /* 100kHz I2C_STO = 2 */ 1371 {0} /* terminator */ 1372 }; 1373 1374 static const struct hda_pintbl cs8409_cs42l42_pincfgs[] = { 1375 { 0x24, 0x042120f0 }, /* ASP-1-TX */ 1376 { 0x34, 0x04a12050 }, /* ASP-1-RX */ 1377 { 0x2c, 0x901000f0 }, /* ASP-2-TX */ 1378 { 0x44, 0x90a00090 }, /* DMIC-1 */ 1379 {0} /* terminator */ 1380 }; 1381 1382 static const struct hda_fixup cs8409_fixups[] = { 1383 [CS8409_BULLSEYE] = { 1384 .type = HDA_FIXUP_PINS, 1385 .v.pins = cs8409_cs42l42_pincfgs, 1386 .chained = true, 1387 .chain_id = CS8409_FIXUPS, 1388 }, 1389 [CS8409_WARLOCK] = { 1390 .type = HDA_FIXUP_PINS, 1391 .v.pins = cs8409_cs42l42_pincfgs, 1392 .chained = true, 1393 .chain_id = CS8409_FIXUPS, 1394 }, 1395 [CS8409_CYBORG] = { 1396 .type = HDA_FIXUP_PINS, 1397 .v.pins = cs8409_cs42l42_pincfgs, 1398 .chained = true, 1399 .chain_id = CS8409_FIXUPS, 1400 }, 1401 [CS8409_FIXUPS] = { 1402 .type = HDA_FIXUP_FUNC, 1403 .v.func = cs8409_cs42l42_fixups, 1404 }, 1405 }; 1406 1407 /* Vendor specific HW configuration for CS42L42 */ 1408 static const struct cs8409_i2c_param cs42l42_init_reg_seq[] = { 1409 { 0x1010, 0xB0 }, 1410 { 0x1D01, 0x00 }, 1411 { 0x1D02, 0x06 }, 1412 { 0x1D03, 0x00 }, 1413 { 0x1107, 0x01 }, 1414 { 0x1009, 0x02 }, 1415 { 0x1007, 0x03 }, 1416 { 0x1201, 0x00 }, 1417 { 0x1208, 0x13 }, 1418 { 0x1205, 0xFF }, 1419 { 0x1206, 0x00 }, 1420 { 0x1207, 0x20 }, 1421 { 0x1202, 0x0D }, 1422 { 0x2A02, 0x02 }, 1423 { 0x2A03, 0x00 }, 1424 { 0x2A04, 0x00 }, 1425 { 0x2A05, 0x02 }, 1426 { 0x2A06, 0x00 }, 1427 { 0x2A07, 0x20 }, 1428 { 0x2A08, 0x02 }, 1429 { 0x2A09, 0x00 }, 1430 { 0x2A0A, 0x80 }, 1431 { 0x2A0B, 0x02 }, 1432 { 0x2A0C, 0x00 }, 1433 { 0x2A0D, 0xA0 }, 1434 { 0x2A01, 0x0C }, 1435 { 0x2902, 0x01 }, 1436 { 0x2903, 0x02 }, 1437 { 0x2904, 0x00 }, 1438 { 0x2905, 0x00 }, 1439 { 0x2901, 0x01 }, 1440 { 0x1101, 0x0A }, 1441 { 0x1102, 0x84 }, 1442 { 0x2301, 0x00 }, 1443 { 0x2303, 0x00 }, 1444 { 0x2302, 0x3f }, 1445 { 0x2001, 0x03 }, 1446 { 0x1B75, 0xB6 }, 1447 { 0x1B73, 0xC2 }, 1448 { 0x1129, 0x01 }, 1449 { 0x1121, 0xF3 }, 1450 { 0x1103, 0x20 }, 1451 { 0x1105, 0x00 }, 1452 { 0x1112, 0xC0 }, 1453 { 0x1113, 0x80 }, 1454 { 0x1C03, 0xC0 }, 1455 { 0x1105, 0x00 }, 1456 { 0x1112, 0xC0 }, 1457 { 0x1101, 0x02 }, 1458 {0} /* Terminator */ 1459 }; 1460 1461 /* Vendor specific hw configuration for CS8409 */ 1462 static const struct cs8409_cir_param cs8409_cs42l42_hw_cfg[] = { 1463 { 0x47, 0x00, 0xb008 }, /* +PLL1/2_EN, +I2C_EN */ 1464 { 0x47, 0x01, 0x0002 }, /* ASP1/2_EN=0, ASP1_STP=1 */ 1465 { 0x47, 0x02, 0x0a80 }, /* ASP1/2_BUS_IDLE=10, +GPIO_I2C */ 1466 { 0x47, 0x19, 0x0800 }, /* ASP1.A: TX.LAP=0, TX.LSZ=24 bits, TX.LCS=0 */ 1467 { 0x47, 0x1a, 0x0820 }, /* ASP1.A: TX.RAP=0, TX.RSZ=24 bits, TX.RCS=32 */ 1468 { 0x47, 0x29, 0x0800 }, /* ASP2.A: TX.LAP=0, TX.LSZ=24 bits, TX.LCS=0 */ 1469 { 0x47, 0x2a, 0x2800 }, /* ASP2.A: TX.RAP=1, TX.RSZ=24 bits, TX.RCS=0 */ 1470 { 0x47, 0x39, 0x0800 }, /* ASP1.A: RX.LAP=0, RX.LSZ=24 bits, RX.LCS=0 */ 1471 { 0x47, 0x3a, 0x0800 }, /* ASP1.A: RX.RAP=0, RX.RSZ=24 bits, RX.RCS=0 */ 1472 { 0x47, 0x03, 0x8000 }, /* ASP1: LCHI = 00h */ 1473 { 0x47, 0x04, 0x28ff }, /* ASP1: MC/SC_SRCSEL=PLL1, LCPR=FFh */ 1474 { 0x47, 0x05, 0x0062 }, /* ASP1: MCEN=0, FSD=011, SCPOL_IN/OUT=0, SCDIV=1:4 */ 1475 { 0x47, 0x06, 0x801f }, /* ASP2: LCHI=1Fh */ 1476 { 0x47, 0x07, 0x283f }, /* ASP2: MC/SC_SRCSEL=PLL1, LCPR=3Fh */ 1477 { 0x47, 0x08, 0x805c }, /* ASP2: 5050=1, MCEN=0, FSD=010, SCPOL_IN/OUT=1, SCDIV=1:16 */ 1478 { 0x47, 0x09, 0x0023 }, /* DMIC1_MO=10b, DMIC1/2_SR=1 */ 1479 { 0x47, 0x0a, 0x0000 }, /* ASP1/2_BEEP=0 */ 1480 { 0x47, 0x01, 0x0062 }, /* ASP1/2_EN=1, ASP1_STP=1 */ 1481 { 0x47, 0x00, 0x9008 }, /* -PLL2_EN */ 1482 { 0x47, 0x68, 0x0000 }, /* TX2.A: pre-scale att.=0 dB */ 1483 { 0x47, 0x82, 0xfc03 }, /* ASP1/2_xxx_EN=1, ASP1/2_MCLK_EN=0, DMIC1_SCL_EN=1 */ 1484 { 0x47, 0xc0, 0x9999 }, /* test mode on */ 1485 { 0x47, 0xc5, 0x0000 }, /* GPIO hysteresis = 30 us */ 1486 { 0x47, 0xc0, 0x0000 }, /* test mode off */ 1487 {0} /* Terminator */ 1488 }; 1489 1490 static const struct cs8409_cir_param cs8409_cs42l42_bullseye_atn[] = { 1491 { 0x47, 0x65, 0x4000 }, /* EQ_SEL=1, EQ1/2_EN=0 */ 1492 { 0x47, 0x64, 0x4000 }, /* +EQ_ACC */ 1493 { 0x47, 0x65, 0x4010 }, /* +EQ2_EN */ 1494 { 0x47, 0x63, 0x0647 }, /* EQ_DATA_HI=0x0647 */ 1495 { 0x47, 0x64, 0xc0c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=0, EQ_DATA_LO=0x67 */ 1496 { 0x47, 0x63, 0x0647 }, /* EQ_DATA_HI=0x0647 */ 1497 { 0x47, 0x64, 0xc1c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=1, EQ_DATA_LO=0x67 */ 1498 { 0x47, 0x63, 0xf370 }, /* EQ_DATA_HI=0xf370 */ 1499 { 0x47, 0x64, 0xc271 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=2, EQ_DATA_LO=0x71 */ 1500 { 0x47, 0x63, 0x1ef8 }, /* EQ_DATA_HI=0x1ef8 */ 1501 { 0x47, 0x64, 0xc348 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=3, EQ_DATA_LO=0x48 */ 1502 { 0x47, 0x63, 0xc110 }, /* EQ_DATA_HI=0xc110 */ 1503 { 0x47, 0x64, 0xc45a }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=4, EQ_DATA_LO=0x5a */ 1504 { 0x47, 0x63, 0x1f29 }, /* EQ_DATA_HI=0x1f29 */ 1505 { 0x47, 0x64, 0xc574 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=5, EQ_DATA_LO=0x74 */ 1506 { 0x47, 0x63, 0x1d7a }, /* EQ_DATA_HI=0x1d7a */ 1507 { 0x47, 0x64, 0xc653 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=6, EQ_DATA_LO=0x53 */ 1508 { 0x47, 0x63, 0xc38c }, /* EQ_DATA_HI=0xc38c */ 1509 { 0x47, 0x64, 0xc714 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=7, EQ_DATA_LO=0x14 */ 1510 { 0x47, 0x63, 0x1ca3 }, /* EQ_DATA_HI=0x1ca3 */ 1511 { 0x47, 0x64, 0xc8c7 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=8, EQ_DATA_LO=0xc7 */ 1512 { 0x47, 0x63, 0xc38c }, /* EQ_DATA_HI=0xc38c */ 1513 { 0x47, 0x64, 0xc914 }, /* +EQ_WRT, +EQ_ACC, EQ_ADR=9, EQ_DATA_LO=0x14 */ 1514 { 0x47, 0x64, 0x0000 }, /* -EQ_ACC, -EQ_WRT */ 1515 {0} /* Terminator */ 1516 }; 1517 1518 /** 1519 * cs8409_enable_i2c_clock - Enable I2C clocks 1520 * @codec: the codec instance 1521 * @enable: Enable or disable I2C clocks 1522 * 1523 * Enable or Disable I2C clocks. 1524 */ 1525 static void cs8409_enable_i2c_clock(struct hda_codec *codec, unsigned int enable) 1526 { 1527 unsigned int retval; 1528 unsigned int newval; 1529 1530 retval = cs_vendor_coef_get(codec, 0x0); 1531 newval = (enable) ? (retval | 0x8) : (retval & 0xfffffff7); 1532 cs_vendor_coef_set(codec, 0x0, newval); 1533 } 1534 1535 /** 1536 * cs8409_i2c_wait_complete - Wait for I2C transaction 1537 * @codec: the codec instance 1538 * 1539 * Wait for I2C transaction to complete. 1540 * Return -1 if transaction wait times out. 1541 */ 1542 static int cs8409_i2c_wait_complete(struct hda_codec *codec) 1543 { 1544 int repeat = 5; 1545 unsigned int retval; 1546 1547 do { 1548 retval = cs_vendor_coef_get(codec, CIR_I2C_STATUS); 1549 if ((retval & 0x18) != 0x18) { 1550 usleep_range(2000, 4000); 1551 --repeat; 1552 } else 1553 return 0; 1554 1555 } while (repeat); 1556 1557 return -1; 1558 } 1559 1560 /** 1561 * cs8409_i2c_read - CS8409 I2C Read. 1562 * @codec: the codec instance 1563 * @i2c_address: I2C Address 1564 * @i2c_reg: Register to read 1565 * @paged: Is a paged transaction 1566 * 1567 * CS8409 I2C Read. 1568 * Returns negative on error, otherwise returns read value in bits 0-7. 1569 */ 1570 static int cs8409_i2c_read(struct hda_codec *codec, 1571 unsigned int i2c_address, 1572 unsigned int i2c_reg, 1573 unsigned int paged) 1574 { 1575 unsigned int i2c_reg_data; 1576 unsigned int read_data; 1577 1578 cs8409_enable_i2c_clock(codec, 1); 1579 cs_vendor_coef_set(codec, CIR_I2C_ADDR, i2c_address); 1580 1581 if (paged) { 1582 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg >> 8); 1583 if (cs8409_i2c_wait_complete(codec) < 0) { 1584 codec_err(codec, 1585 "%s() Paged Transaction Failed 0x%02x : 0x%04x\n", 1586 __func__, i2c_address, i2c_reg); 1587 return -EIO; 1588 } 1589 } 1590 1591 i2c_reg_data = (i2c_reg << 8) & 0x0ffff; 1592 cs_vendor_coef_set(codec, CIR_I2C_QREAD, i2c_reg_data); 1593 if (cs8409_i2c_wait_complete(codec) < 0) { 1594 codec_err(codec, "%s() Transaction Failed 0x%02x : 0x%04x\n", 1595 __func__, i2c_address, i2c_reg); 1596 return -EIO; 1597 } 1598 1599 /* Register in bits 15-8 and the data in 7-0 */ 1600 read_data = cs_vendor_coef_get(codec, CIR_I2C_QREAD); 1601 1602 cs8409_enable_i2c_clock(codec, 0); 1603 1604 return read_data & 0x0ff; 1605 } 1606 1607 /** 1608 * cs8409_i2c_write - CS8409 I2C Write. 1609 * @codec: the codec instance 1610 * @i2c_address: I2C Address 1611 * @i2c_reg: Register to write to 1612 * @i2c_data: Data to write 1613 * @paged: Is a paged transaction 1614 * 1615 * CS8409 I2C Write. 1616 * Returns negative on error, otherwise returns 0. 1617 */ 1618 static int cs8409_i2c_write(struct hda_codec *codec, 1619 unsigned int i2c_address, unsigned int i2c_reg, 1620 unsigned int i2c_data, 1621 unsigned int paged) 1622 { 1623 unsigned int i2c_reg_data; 1624 1625 cs8409_enable_i2c_clock(codec, 1); 1626 cs_vendor_coef_set(codec, CIR_I2C_ADDR, i2c_address); 1627 1628 if (paged) { 1629 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg >> 8); 1630 if (cs8409_i2c_wait_complete(codec) < 0) { 1631 codec_err(codec, 1632 "%s() Paged Transaction Failed 0x%02x : 0x%04x\n", 1633 __func__, i2c_address, i2c_reg); 1634 return -EIO; 1635 } 1636 } 1637 1638 i2c_reg_data = ((i2c_reg << 8) & 0x0ff00) | (i2c_data & 0x0ff); 1639 cs_vendor_coef_set(codec, CIR_I2C_QWRITE, i2c_reg_data); 1640 1641 if (cs8409_i2c_wait_complete(codec) < 0) { 1642 codec_err(codec, "%s() Transaction Failed 0x%02x : 0x%04x\n", 1643 __func__, i2c_address, i2c_reg); 1644 return -EIO; 1645 } 1646 1647 cs8409_enable_i2c_clock(codec, 0); 1648 1649 return 0; 1650 } 1651 1652 static int cs8409_cs42l42_volume_info(struct snd_kcontrol *kcontrol, 1653 struct snd_ctl_elem_info *uinfo) 1654 { 1655 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1656 u16 nid = get_amp_nid(kcontrol); 1657 u8 chs = get_amp_channels(kcontrol); 1658 1659 codec_dbg(codec, "%s() nid: %d\n", __func__, nid); 1660 switch (nid) { 1661 case CS8409_CS42L42_HP_PIN_NID: 1662 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1663 uinfo->count = chs == 3 ? 2 : 1; 1664 uinfo->value.integer.min = CS8409_CS42L42_HP_VOL_REAL_MIN; 1665 uinfo->value.integer.max = CS8409_CS42L42_HP_VOL_REAL_MAX; 1666 break; 1667 case CS8409_CS42L42_AMIC_PIN_NID: 1668 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 1669 uinfo->count = chs == 3 ? 2 : 1; 1670 uinfo->value.integer.min = CS8409_CS42L42_AMIC_VOL_REAL_MIN; 1671 uinfo->value.integer.max = CS8409_CS42L42_AMIC_VOL_REAL_MAX; 1672 break; 1673 default: 1674 break; 1675 } 1676 return 0; 1677 } 1678 1679 static void cs8409_cs42l42_update_volume(struct hda_codec *codec) 1680 { 1681 struct cs_spec *spec = codec->spec; 1682 int data; 1683 1684 mutex_lock(&spec->cs8409_i2c_mux); 1685 data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 1686 CS8409_CS42L42_REG_HS_VOLUME_CHA, 1); 1687 if (data >= 0) 1688 spec->cs42l42_hp_volume[0] = -data; 1689 else 1690 spec->cs42l42_hp_volume[0] = CS8409_CS42L42_HP_VOL_REAL_MIN; 1691 data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 1692 CS8409_CS42L42_REG_HS_VOLUME_CHB, 1); 1693 if (data >= 0) 1694 spec->cs42l42_hp_volume[1] = -data; 1695 else 1696 spec->cs42l42_hp_volume[1] = CS8409_CS42L42_HP_VOL_REAL_MIN; 1697 data = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 1698 CS8409_CS42L42_REG_AMIC_VOLUME, 1); 1699 if (data >= 0) 1700 spec->cs42l42_hs_mic_volume[0] = -data; 1701 else 1702 spec->cs42l42_hs_mic_volume[0] = CS8409_CS42L42_AMIC_VOL_REAL_MIN; 1703 mutex_unlock(&spec->cs8409_i2c_mux); 1704 spec->cs42l42_volume_init = 1; 1705 } 1706 1707 static int cs8409_cs42l42_volume_get(struct snd_kcontrol *kcontrol, 1708 struct snd_ctl_elem_value *ucontrol) 1709 { 1710 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1711 struct cs_spec *spec = codec->spec; 1712 hda_nid_t nid = get_amp_nid(kcontrol); 1713 int chs = get_amp_channels(kcontrol); 1714 long *valp = ucontrol->value.integer.value; 1715 1716 if (!spec->cs42l42_volume_init) { 1717 snd_hda_power_up(codec); 1718 cs8409_cs42l42_update_volume(codec); 1719 snd_hda_power_down(codec); 1720 } 1721 switch (nid) { 1722 case CS8409_CS42L42_HP_PIN_NID: 1723 if (chs & BIT(0)) 1724 *valp++ = spec->cs42l42_hp_volume[0]; 1725 if (chs & BIT(1)) 1726 *valp++ = spec->cs42l42_hp_volume[1]; 1727 break; 1728 case CS8409_CS42L42_AMIC_PIN_NID: 1729 if (chs & BIT(0)) 1730 *valp++ = spec->cs42l42_hs_mic_volume[0]; 1731 break; 1732 default: 1733 break; 1734 } 1735 return 0; 1736 } 1737 1738 static int cs8409_cs42l42_volume_put(struct snd_kcontrol *kcontrol, 1739 struct snd_ctl_elem_value *ucontrol) 1740 { 1741 struct hda_codec *codec = snd_kcontrol_chip(kcontrol); 1742 struct cs_spec *spec = codec->spec; 1743 hda_nid_t nid = get_amp_nid(kcontrol); 1744 int chs = get_amp_channels(kcontrol); 1745 long *valp = ucontrol->value.integer.value; 1746 int change = 0; 1747 char vol; 1748 1749 snd_hda_power_up(codec); 1750 switch (nid) { 1751 case CS8409_CS42L42_HP_PIN_NID: 1752 mutex_lock(&spec->cs8409_i2c_mux); 1753 if (chs & BIT(0)) { 1754 vol = -(*valp); 1755 change = cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 1756 CS8409_CS42L42_REG_HS_VOLUME_CHA, vol, 1); 1757 valp++; 1758 } 1759 if (chs & BIT(1)) { 1760 vol = -(*valp); 1761 change |= cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 1762 CS8409_CS42L42_REG_HS_VOLUME_CHB, vol, 1); 1763 } 1764 mutex_unlock(&spec->cs8409_i2c_mux); 1765 break; 1766 case CS8409_CS42L42_AMIC_PIN_NID: 1767 mutex_lock(&spec->cs8409_i2c_mux); 1768 if (chs & BIT(0)) { 1769 change = cs8409_i2c_write( 1770 codec, CS42L42_I2C_ADDR, 1771 CS8409_CS42L42_REG_AMIC_VOLUME, (char)*valp, 1); 1772 valp++; 1773 } 1774 mutex_unlock(&spec->cs8409_i2c_mux); 1775 break; 1776 default: 1777 break; 1778 } 1779 cs8409_cs42l42_update_volume(codec); 1780 snd_hda_power_down(codec); 1781 return change; 1782 } 1783 1784 static const DECLARE_TLV_DB_SCALE( 1785 cs8409_cs42l42_hp_db_scale, 1786 CS8409_CS42L42_HP_VOL_REAL_MIN * 100, 100, 1); 1787 1788 static const DECLARE_TLV_DB_SCALE( 1789 cs8409_cs42l42_amic_db_scale, 1790 CS8409_CS42L42_AMIC_VOL_REAL_MIN * 100, 100, 1); 1791 1792 static const struct snd_kcontrol_new cs8409_cs42l42_hp_volume_mixer = { 1793 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1794 .index = 0, 1795 .name = "Headphone Playback Volume", 1796 .subdevice = (HDA_SUBDEV_AMP_FLAG | HDA_SUBDEV_NID_FLAG), 1797 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE 1798 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), 1799 .info = cs8409_cs42l42_volume_info, 1800 .get = cs8409_cs42l42_volume_get, 1801 .put = cs8409_cs42l42_volume_put, 1802 .tlv = { .p = cs8409_cs42l42_hp_db_scale }, 1803 .private_value = HDA_COMPOSE_AMP_VAL( 1804 CS8409_CS42L42_HP_PIN_NID, 3, 0, HDA_OUTPUT) 1805 | HDA_AMP_VAL_MIN_MUTE 1806 }; 1807 1808 static const struct snd_kcontrol_new cs8409_cs42l42_amic_volume_mixer = { 1809 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1810 .index = 0, 1811 .name = "Mic Capture Volume", 1812 .subdevice = (HDA_SUBDEV_AMP_FLAG | HDA_SUBDEV_NID_FLAG), 1813 .access = (SNDRV_CTL_ELEM_ACCESS_READWRITE 1814 | SNDRV_CTL_ELEM_ACCESS_TLV_READ), 1815 .info = cs8409_cs42l42_volume_info, 1816 .get = cs8409_cs42l42_volume_get, 1817 .put = cs8409_cs42l42_volume_put, 1818 .tlv = { .p = cs8409_cs42l42_amic_db_scale }, 1819 .private_value = HDA_COMPOSE_AMP_VAL( 1820 CS8409_CS42L42_AMIC_PIN_NID, 1, 0, HDA_INPUT) 1821 | HDA_AMP_VAL_MIN_MUTE 1822 }; 1823 1824 /* Assert/release RTS# line to CS42L42 */ 1825 static void cs8409_cs42l42_reset(struct hda_codec *codec) 1826 { 1827 struct cs_spec *spec = codec->spec; 1828 1829 /* Assert RTS# line */ 1830 snd_hda_codec_write(codec, 1831 codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, 0); 1832 /* wait ~10ms */ 1833 usleep_range(10000, 15000); 1834 /* Release RTS# line */ 1835 snd_hda_codec_write(codec, 1836 codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, GPIO5_INT); 1837 /* wait ~10ms */ 1838 usleep_range(10000, 15000); 1839 1840 mutex_lock(&spec->cs8409_i2c_mux); 1841 1842 /* Clear interrupts, by reading interrupt status registers */ 1843 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1); 1844 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1309, 1); 1845 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130A, 1); 1846 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130F, 1); 1847 1848 mutex_unlock(&spec->cs8409_i2c_mux); 1849 1850 } 1851 1852 /* Configure CS42L42 slave codec for jack autodetect */ 1853 static void cs8409_cs42l42_enable_jack_detect(struct hda_codec *codec) 1854 { 1855 struct cs_spec *spec = codec->spec; 1856 1857 mutex_lock(&spec->cs8409_i2c_mux); 1858 1859 /* Set TIP_SENSE_EN for analog front-end of tip sense. */ 1860 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b70, 0x0020, 1); 1861 /* Clear WAKE# */ 1862 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b71, 0x0001, 1); 1863 /* Wait ~2.5ms */ 1864 usleep_range(2500, 3000); 1865 /* Set mode WAKE# output follows the combination logic directly */ 1866 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b71, 0x0020, 1); 1867 /* Clear interrupts status */ 1868 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1); 1869 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b7b, 1); 1870 /* Enable interrupt */ 1871 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1320, 0x03, 1); 1872 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b79, 0x00, 1); 1873 1874 mutex_unlock(&spec->cs8409_i2c_mux); 1875 } 1876 1877 /* Enable and run CS42L42 slave codec jack auto detect */ 1878 static void cs8409_cs42l42_run_jack_detect(struct hda_codec *codec) 1879 { 1880 struct cs_spec *spec = codec->spec; 1881 1882 mutex_lock(&spec->cs8409_i2c_mux); 1883 1884 /* Clear interrupts */ 1885 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1); 1886 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b77, 1); 1887 1888 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1102, 0x87, 1); 1889 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1f06, 0x86, 1); 1890 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1b74, 0x07, 1); 1891 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x131b, 0x01, 1); 1892 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1120, 0x80, 1); 1893 /* Wait ~110ms*/ 1894 usleep_range(110000, 200000); 1895 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x111f, 0x77, 1); 1896 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1120, 0xc0, 1); 1897 /* Wait ~10ms */ 1898 usleep_range(10000, 25000); 1899 1900 mutex_unlock(&spec->cs8409_i2c_mux); 1901 1902 } 1903 1904 static void cs8409_cs42l42_reg_setup(struct hda_codec *codec) 1905 { 1906 const struct cs8409_i2c_param *seq = cs42l42_init_reg_seq; 1907 struct cs_spec *spec = codec->spec; 1908 1909 mutex_lock(&spec->cs8409_i2c_mux); 1910 1911 for (; seq->addr; seq++) 1912 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, seq->addr, seq->reg, 1); 1913 1914 mutex_unlock(&spec->cs8409_i2c_mux); 1915 1916 } 1917 1918 /* 1919 * In the case of CS8409 we do not have unsolicited events from NID's 0x24 1920 * and 0x34 where hs mic and hp are connected. Companion codec CS42L42 will 1921 * generate interrupt via gpio 4 to notify jack events. We have to overwrite 1922 * generic snd_hda_jack_unsol_event(), read CS42L42 jack detect status registers 1923 * and then notify status via generic snd_hda_jack_unsol_event() call. 1924 */ 1925 static void cs8409_jack_unsol_event(struct hda_codec *codec, unsigned int res) 1926 { 1927 struct cs_spec *spec = codec->spec; 1928 int status_changed = 0; 1929 int reg_cdc_status; 1930 int reg_hs_status; 1931 int reg_ts_status; 1932 int type; 1933 struct hda_jack_tbl *jk; 1934 1935 /* jack_unsol_event() will be called every time gpio line changing state. 1936 * In this case gpio4 line goes up as a result of reading interrupt status 1937 * registers in previous cs8409_jack_unsol_event() call. 1938 * We don't need to handle this event, ignoring... 1939 */ 1940 if ((res & (1 << 4))) 1941 return; 1942 1943 mutex_lock(&spec->cs8409_i2c_mux); 1944 1945 /* Read jack detect status registers */ 1946 reg_cdc_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1308, 1); 1947 reg_hs_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1124, 1); 1948 reg_ts_status = cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x130f, 1); 1949 1950 /* Clear interrupts, by reading interrupt status registers */ 1951 cs8409_i2c_read(codec, CS42L42_I2C_ADDR, 0x1b7b, 1); 1952 1953 mutex_unlock(&spec->cs8409_i2c_mux); 1954 1955 /* If status values are < 0, read error has occurred. */ 1956 if (reg_cdc_status < 0 || reg_hs_status < 0 || reg_ts_status < 0) 1957 return; 1958 1959 /* HSDET_AUTO_DONE */ 1960 if (reg_cdc_status & CS42L42_HSDET_AUTO_DONE) { 1961 1962 type = ((reg_hs_status & CS42L42_HSTYPE_MASK) + 1); 1963 /* CS42L42 reports optical jack as type 4 1964 * We don't handle optical jack 1965 */ 1966 if (type != 4) { 1967 if (!spec->cs42l42_hp_jack_in) { 1968 status_changed = 1; 1969 spec->cs42l42_hp_jack_in = 1; 1970 } 1971 /* type = 3 has no mic */ 1972 if ((!spec->cs42l42_mic_jack_in) && (type != 3)) { 1973 status_changed = 1; 1974 spec->cs42l42_mic_jack_in = 1; 1975 } 1976 } else { 1977 if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) { 1978 status_changed = 1; 1979 spec->cs42l42_hp_jack_in = 0; 1980 spec->cs42l42_mic_jack_in = 0; 1981 } 1982 } 1983 1984 } else { 1985 /* TIP_SENSE INSERT/REMOVE */ 1986 switch (reg_ts_status) { 1987 case CS42L42_JACK_INSERTED: 1988 cs8409_cs42l42_run_jack_detect(codec); 1989 break; 1990 1991 case CS42L42_JACK_REMOVED: 1992 if (spec->cs42l42_hp_jack_in || spec->cs42l42_mic_jack_in) { 1993 status_changed = 1; 1994 spec->cs42l42_hp_jack_in = 0; 1995 spec->cs42l42_mic_jack_in = 0; 1996 } 1997 break; 1998 1999 default: 2000 /* jack in transition */ 2001 status_changed = 0; 2002 break; 2003 } 2004 } 2005 2006 if (status_changed) { 2007 2008 snd_hda_set_pin_ctl(codec, CS8409_CS42L42_SPK_PIN_NID, 2009 spec->cs42l42_hp_jack_in ? 0 : PIN_OUT); 2010 2011 /* Report jack*/ 2012 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_HP_PIN_NID, 0); 2013 if (jk) { 2014 snd_hda_jack_unsol_event(codec, 2015 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & AC_UNSOL_RES_TAG); 2016 } 2017 /* Report jack*/ 2018 jk = snd_hda_jack_tbl_get_mst(codec, CS8409_CS42L42_AMIC_PIN_NID, 0); 2019 if (jk) { 2020 snd_hda_jack_unsol_event(codec, 2021 (jk->tag << AC_UNSOL_RES_TAG_SHIFT) & AC_UNSOL_RES_TAG); 2022 } 2023 } 2024 } 2025 2026 #ifdef CONFIG_PM 2027 /* Manage PDREF, when transition to D3hot */ 2028 static int cs8409_suspend(struct hda_codec *codec) 2029 { 2030 struct cs_spec *spec = codec->spec; 2031 2032 mutex_lock(&spec->cs8409_i2c_mux); 2033 /* Power down CS42L42 ASP/EQ/MIX/HP */ 2034 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x1101, 0xfe, 1); 2035 mutex_unlock(&spec->cs8409_i2c_mux); 2036 /* Assert CS42L42 RTS# line */ 2037 snd_hda_codec_write(codec, 2038 codec->core.afg, 0, AC_VERB_SET_GPIO_DATA, 0); 2039 2040 snd_hda_shutup_pins(codec); 2041 2042 return 0; 2043 } 2044 #endif 2045 2046 /* Enable/Disable Unsolicited Response for gpio(s) 3,4 */ 2047 static void cs8409_enable_ur(struct hda_codec *codec, int flag) 2048 { 2049 /* GPIO4 INT# and GPIO3 WAKE# */ 2050 snd_hda_codec_write(codec, codec->core.afg, 2051 0, AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 2052 flag ? (GPIO3_INT | GPIO4_INT) : 0); 2053 2054 snd_hda_codec_write(codec, codec->core.afg, 2055 0, AC_VERB_SET_UNSOLICITED_ENABLE, 2056 flag ? AC_UNSOL_ENABLED : 0); 2057 2058 } 2059 2060 /* Vendor specific HW configuration 2061 * PLL, ASP, I2C, SPI, GPIOs, DMIC etc... 2062 */ 2063 static void cs8409_cs42l42_hw_init(struct hda_codec *codec) 2064 { 2065 const struct cs8409_cir_param *seq = cs8409_cs42l42_hw_cfg; 2066 const struct cs8409_cir_param *seq_bullseye = cs8409_cs42l42_bullseye_atn; 2067 struct cs_spec *spec = codec->spec; 2068 2069 if (spec->gpio_mask) { 2070 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK, 2071 spec->gpio_mask); 2072 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION, 2073 spec->gpio_dir); 2074 snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 2075 spec->gpio_data); 2076 } 2077 2078 for (; seq->nid; seq++) 2079 cs_vendor_coef_set(codec, seq->cir, seq->coeff); 2080 2081 if (codec->fixup_id == CS8409_BULLSEYE) 2082 for (; seq_bullseye->nid; seq_bullseye++) 2083 cs_vendor_coef_set(codec, seq_bullseye->cir, seq_bullseye->coeff); 2084 2085 /* Disable Unsolicited Response during boot */ 2086 cs8409_enable_ur(codec, 0); 2087 2088 /* Reset CS42L42 */ 2089 cs8409_cs42l42_reset(codec); 2090 2091 /* Initialise CS42L42 companion codec */ 2092 cs8409_cs42l42_reg_setup(codec); 2093 2094 if (codec->fixup_id == CS8409_WARLOCK || 2095 codec->fixup_id == CS8409_CYBORG) { 2096 /* FULL_SCALE_VOL = 0 for Warlock / Cyborg */ 2097 mutex_lock(&spec->cs8409_i2c_mux); 2098 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 0x2001, 0x01, 1); 2099 mutex_unlock(&spec->cs8409_i2c_mux); 2100 /* DMIC1_MO=00b, DMIC1/2_SR=1 */ 2101 cs_vendor_coef_set(codec, 0x09, 0x0003); 2102 } 2103 2104 /* Restore Volumes after Resume */ 2105 if (spec->cs42l42_volume_init) { 2106 mutex_lock(&spec->cs8409_i2c_mux); 2107 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 2108 CS8409_CS42L42_REG_HS_VOLUME_CHA, 2109 -spec->cs42l42_hp_volume[0], 2110 1); 2111 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 2112 CS8409_CS42L42_REG_HS_VOLUME_CHB, 2113 -spec->cs42l42_hp_volume[1], 2114 1); 2115 cs8409_i2c_write(codec, CS42L42_I2C_ADDR, 2116 CS8409_CS42L42_REG_AMIC_VOLUME, 2117 spec->cs42l42_hs_mic_volume[0], 2118 1); 2119 mutex_unlock(&spec->cs8409_i2c_mux); 2120 } 2121 2122 cs8409_cs42l42_update_volume(codec); 2123 2124 cs8409_cs42l42_enable_jack_detect(codec); 2125 2126 /* Enable Unsolicited Response */ 2127 cs8409_enable_ur(codec, 1); 2128 } 2129 2130 static int cs8409_cs42l42_init(struct hda_codec *codec) 2131 { 2132 int ret = snd_hda_gen_init(codec); 2133 2134 if (!ret) 2135 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT); 2136 2137 return ret; 2138 } 2139 2140 static const struct hda_codec_ops cs8409_cs42l42_patch_ops = { 2141 .build_controls = cs_build_controls, 2142 .build_pcms = snd_hda_gen_build_pcms, 2143 .init = cs8409_cs42l42_init, 2144 .free = cs_free, 2145 .unsol_event = cs8409_jack_unsol_event, 2146 #ifdef CONFIG_PM 2147 .suspend = cs8409_suspend, 2148 #endif 2149 }; 2150 2151 static void cs8409_cs42l42_fixups(struct hda_codec *codec, 2152 const struct hda_fixup *fix, int action) 2153 { 2154 struct cs_spec *spec = codec->spec; 2155 int caps; 2156 2157 switch (action) { 2158 case HDA_FIXUP_ACT_PRE_PROBE: 2159 snd_hda_add_verbs(codec, cs8409_cs42l42_init_verbs); 2160 /* verb exec op override */ 2161 spec->exec_verb = codec->core.exec_verb; 2162 codec->core.exec_verb = cs8409_cs42l42_exec_verb; 2163 2164 mutex_init(&spec->cs8409_i2c_mux); 2165 2166 codec->patch_ops = cs8409_cs42l42_patch_ops; 2167 2168 spec->gen.suppress_auto_mute = 1; 2169 spec->gen.no_primary_hp = 1; 2170 spec->gen.suppress_vmaster = 1; 2171 2172 /* GPIO 5 out, 3,4 in */ 2173 spec->gpio_dir = GPIO5_INT; 2174 spec->gpio_data = 0; 2175 spec->gpio_mask = 0x03f; 2176 2177 spec->cs42l42_hp_jack_in = 0; 2178 spec->cs42l42_mic_jack_in = 0; 2179 2180 /* Basic initial sequence for specific hw configuration */ 2181 snd_hda_sequence_write(codec, cs8409_cs42l42_init_verbs); 2182 2183 /* CS8409 is simple HDA bridge and intended to be used with a remote 2184 * companion codec. Most of input/output PIN(s) have only basic 2185 * capabilities. NID(s) 0x24 and 0x34 have only OUTC and INC 2186 * capabilities and no presence detect capable (PDC) and call to 2187 * snd_hda_gen_build_controls() will mark them as non detectable 2188 * phantom jacks. However, in this configuration companion codec 2189 * CS42L42 is connected to these pins and it has jack detect 2190 * capabilities. We have to override pin capabilities, 2191 * otherwise they will not be created as input devices. 2192 */ 2193 caps = snd_hdac_read_parm(&codec->core, CS8409_CS42L42_HP_PIN_NID, 2194 AC_PAR_PIN_CAP); 2195 if (caps >= 0) 2196 snd_hdac_override_parm(&codec->core, 2197 CS8409_CS42L42_HP_PIN_NID, AC_PAR_PIN_CAP, 2198 (caps | (AC_PINCAP_IMP_SENSE | AC_PINCAP_PRES_DETECT))); 2199 2200 caps = snd_hdac_read_parm(&codec->core, CS8409_CS42L42_AMIC_PIN_NID, 2201 AC_PAR_PIN_CAP); 2202 if (caps >= 0) 2203 snd_hdac_override_parm(&codec->core, 2204 CS8409_CS42L42_AMIC_PIN_NID, AC_PAR_PIN_CAP, 2205 (caps | (AC_PINCAP_IMP_SENSE | AC_PINCAP_PRES_DETECT))); 2206 2207 snd_hda_override_wcaps(codec, CS8409_CS42L42_HP_PIN_NID, 2208 (get_wcaps(codec, CS8409_CS42L42_HP_PIN_NID) | AC_WCAP_UNSOL_CAP)); 2209 2210 snd_hda_override_wcaps(codec, CS8409_CS42L42_AMIC_PIN_NID, 2211 (get_wcaps(codec, CS8409_CS42L42_AMIC_PIN_NID) | AC_WCAP_UNSOL_CAP)); 2212 break; 2213 case HDA_FIXUP_ACT_PROBE: 2214 2215 /* Set initial DMIC volume to -26 dB */ 2216 snd_hda_codec_amp_init_stereo(codec, CS8409_CS42L42_DMIC_ADC_PIN_NID, 2217 HDA_INPUT, 0, 0xff, 0x19); 2218 snd_hda_gen_add_kctl(&spec->gen, 2219 NULL, &cs8409_cs42l42_hp_volume_mixer); 2220 snd_hda_gen_add_kctl(&spec->gen, 2221 NULL, &cs8409_cs42l42_amic_volume_mixer); 2222 cs8409_cs42l42_hw_init(codec); 2223 snd_hda_codec_set_name(codec, "CS8409/CS42L42"); 2224 break; 2225 case HDA_FIXUP_ACT_INIT: 2226 cs8409_cs42l42_hw_init(codec); 2227 fallthrough; 2228 case HDA_FIXUP_ACT_BUILD: 2229 /* Run jack auto detect first time on boot 2230 * after controls have been added, to check if jack has 2231 * been already plugged in. 2232 * Run immediately after init. 2233 */ 2234 cs8409_cs42l42_run_jack_detect(codec); 2235 usleep_range(100000, 150000); 2236 break; 2237 default: 2238 break; 2239 } 2240 } 2241 2242 static int cs8409_cs42l42_exec_verb(struct hdac_device *dev, 2243 unsigned int cmd, unsigned int flags, unsigned int *res) 2244 { 2245 struct hda_codec *codec = container_of(dev, struct hda_codec, core); 2246 struct cs_spec *spec = codec->spec; 2247 2248 unsigned int nid = ((cmd >> 20) & 0x07f); 2249 unsigned int verb = ((cmd >> 8) & 0x0fff); 2250 2251 /* CS8409 pins have no AC_PINSENSE_PRESENCE 2252 * capabilities. We have to intercept 2 calls for pins 0x24 and 0x34 2253 * and return correct pin sense values for read_pin_sense() call from 2254 * hda_jack based on CS42L42 jack detect status. 2255 */ 2256 switch (nid) { 2257 case CS8409_CS42L42_HP_PIN_NID: 2258 if (verb == AC_VERB_GET_PIN_SENSE) { 2259 *res = (spec->cs42l42_hp_jack_in) ? AC_PINSENSE_PRESENCE : 0; 2260 return 0; 2261 } 2262 break; 2263 2264 case CS8409_CS42L42_AMIC_PIN_NID: 2265 if (verb == AC_VERB_GET_PIN_SENSE) { 2266 *res = (spec->cs42l42_mic_jack_in) ? AC_PINSENSE_PRESENCE : 0; 2267 return 0; 2268 } 2269 break; 2270 2271 default: 2272 break; 2273 } 2274 2275 return spec->exec_verb(dev, cmd, flags, res); 2276 } 2277 2278 static int patch_cs8409(struct hda_codec *codec) 2279 { 2280 int err; 2281 2282 if (!cs_alloc_spec(codec, CS8409_VENDOR_NID)) 2283 return -ENOMEM; 2284 2285 snd_hda_pick_fixup(codec, 2286 cs8409_models, cs8409_fixup_tbl, cs8409_fixups); 2287 2288 codec_dbg(codec, "Picked ID=%d, VID=%08x, DEV=%08x\n", 2289 codec->fixup_id, 2290 codec->bus->pci->subsystem_vendor, 2291 codec->bus->pci->subsystem_device); 2292 2293 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE); 2294 2295 err = cs_parse_auto_config(codec); 2296 if (err < 0) { 2297 cs_free(codec); 2298 return err; 2299 } 2300 2301 snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE); 2302 return 0; 2303 } 1228 2304 1229 2305 /* … … 1236 2312 HDA_CODEC_ENTRY(0x10134210, "CS4210", patch_cs4210), 1237 2313 HDA_CODEC_ENTRY(0x10134213, "CS4213", patch_cs4213), 2314 HDA_CODEC_ENTRY(0x10138409, "CS8409", patch_cs8409), 1238 2315 {0} /* terminator */ 1239 2316 }; -
GPL/trunk/alsa-kernel/pci/hda/patch_conexant.c
r689 r695 591 591 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 592 592 spec->mute_led_eapd = 0x1b; 593 spec->dynamic_eapd = 1;593 spec->dynamic_eapd = true; 594 594 #ifdef CONFIG_SND_HDA_GENERIC_LEDS 595 595 snd_hda_gen_add_mute_led_cdev(codec, cx_auto_vmaster_mute_led); -
GPL/trunk/alsa-kernel/pci/hda/patch_hdmi.c
r689 r695 165 165 bool dyn_pin_out; 166 166 bool dyn_pcm_assign; 167 bool dyn_pcm_no_legacy; 167 168 bool intel_hsw_fixup; /* apply Intel platform-specific fixups */ 168 169 /* … … 261 262 } 262 263 263 codec_warn(codec, "HDMI: pin nid %dnot registered\n", pin_nid);264 codec_warn(codec, "HDMI: pin NID 0x%x not registered\n", pin_nid); 264 265 return -EINVAL; 265 266 } … … 321 322 return cvt_idx; 322 323 323 codec_warn(codec, "HDMI: cvt nid %dnot registered\n", cvt_nid);324 codec_warn(codec, "HDMI: cvt NID 0x%x not registered\n", cvt_nid); 324 325 return -EINVAL; 325 326 } … … 646 647 int i; 647 648 649 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 648 650 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) 649 651 != AC_DIPXMIT_BEST) 650 652 return false; 651 653 652 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);653 654 for (i = 0; i < size; i++) { 654 655 val = snd_hda_codec_read(codec, pin_nid, 0, … … 695 696 dp_ai->CA = ca; 696 697 } else { 697 codec_dbg(codec, "HDMI: unknown connection type at pin %d\n", 698 pin_nid); 698 codec_dbg(codec, "HDMI: unknown connection type at pin NID 0x%x\n", pin_nid); 699 699 return; 700 700 } … … 709 709 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes, 710 710 sizeof(ai))) { 711 codec_dbg(codec, 712 "hdmi_pin_setup_infoframe: pin=%d channels=%d ca=0x%02x\n", 713 pin_nid, 714 active_channels, ca); 711 codec_dbg(codec, "%s: pin NID=0x%x channels=%d ca=0x%02x\n", 712 __func__, pin_nid, active_channels, ca); 715 713 hdmi_stop_infoframe_trans(codec, pin_nid); 716 714 hdmi_fill_audio_infoframe(codec, pin_nid, … … 804 802 805 803 codec_dbg(codec, 806 "HDMI hot plug event: Codec=%d Pin=%dDevice=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n",804 "HDMI hot plug event: Codec=%d NID=0x%x Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n", 807 805 codec->addr, jack->nid, jack->dev_id, !!(res & AC_UNSOL_RES_IA), 808 806 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV)); … … 882 880 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0); 883 881 pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT; 884 codec_dbg(codec, "Haswell HDMI audio: Power for pin0x%x is now D%d\n", nid, pwr);882 codec_dbg(codec, "Haswell HDMI audio: Power for NID 0x%x is now D%d\n", nid, pwr); 885 883 } 886 884 } … … 1129 1127 if (!per_cvt->assigned) { 1130 1128 codec_dbg(codec, 1131 "choose cvt %d for pin nid %d\n",1132 cvt_idx, nid);1129 "choose cvt %d for pin NID 0x%x\n", 1130 cvt_idx, nid); 1133 1131 snd_hda_codec_write_cache(codec, nid, 0, 1134 1132 AC_VERB_SET_CONNECT_SEL, … … 1328 1326 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { 1329 1327 codec_warn(codec, 1330 "HDMI: pin %dwcaps %#x does not support connection list\n",1328 "HDMI: pin NID 0x%x wcaps %#x does not support connection list\n", 1331 1329 pin_nid, get_wcaps(codec, pin_nid)); 1332 1330 return -EINVAL; … … 1355 1353 { 1356 1354 int i; 1355 1356 /* on the new machines, try to assign the pcm slot dynamically, 1357 * not use the preferred fixed map (legacy way) anymore. 1358 */ 1359 if (spec->dyn_pcm_no_legacy) 1360 goto last_try; 1357 1361 1358 1362 /* … … 1385 1389 } 1386 1390 1391 last_try: 1387 1392 /* the last try; check the empty slots in pins */ 1388 1393 for (i = 0; i < spec->num_nids; i++) { … … 1643 1648 1644 1649 codec_dbg(codec, 1645 "HDMI status: Codec=%d Pin=%dPresence_Detect=%d ELD_Valid=%d\n",1650 "HDMI status: Codec=%d NID=0x%x Presence_Detect=%d ELD_Valid=%d\n", 1646 1651 codec->addr, pin_nid, eld->monitor_present, eld->eld_valid); 1647 1652 … … 1851 1856 if (spec->intel_hsw_fixup) { 1852 1857 /* 1853 * On Intel platforms, device entries number is 1854 * changed dynamically. If there is a DP MST 1855 * hub connected, the device entries number is 3. 1856 * Otherwise, it is 1. 1857 * Here we manually set dev_num to 3, so that 1858 * we can initialize all the device entries when 1859 * bootup statically. 1858 * On Intel platforms, device entries count returned 1859 * by AC_PAR_DEVLIST_LEN is dynamic, and depends on 1860 * the type of receiver that is connected. Allocate pin 1861 * structures based on worst case. 1860 1862 */ 1861 dev_num = 3; 1862 spec->dev_num = 3; 1863 dev_num = spec->dev_num; 1863 1864 } else if (spec->dyn_pcm_assign && codec->dp_mst) { 1864 1865 dev_num = snd_hda_get_num_devices(codec, pin_nid) + 1; … … 1947 1948 SND_PCI_QUIRK(0x103c, 0x870f, "HP", 1), 1948 1949 SND_PCI_QUIRK(0x103c, 0x871a, "HP", 1), 1950 SND_PCI_QUIRK(0x1462, 0xec94, "MS-7C94", 1), 1949 1951 {} 1950 1952 }; … … 2815 2817 } 2816 2818 2817 codec_info(codec, "Can't find the HDMI/DP port for pin %d\n", pin_nid);2819 codec_info(codec, "Can't find the HDMI/DP port for pin NID 0x%x\n", pin_nid); 2818 2820 return -1; 2819 2821 } … … 2945 2947 /* Intel Haswell and onwards; audio component with eld notifier */ 2946 2948 static int intel_hsw_common_init(struct hda_codec *codec, hda_nid_t vendor_nid, 2947 const int *port_map, int port_num )2949 const int *port_map, int port_num, int dev_num) 2948 2950 { 2949 2951 struct hdmi_spec *spec; … … 2960 2962 spec->port_num = port_num; 2961 2963 spec->intel_hsw_fixup = true; 2964 spec->dev_num = dev_num; 2962 2965 2963 2966 intel_haswell_enable_all_pins(codec, true); … … 2985 2988 static int patch_i915_hsw_hdmi(struct hda_codec *codec) 2986 2989 { 2987 return intel_hsw_common_init(codec, 0x08, NULL, 0 );2990 return intel_hsw_common_init(codec, 0x08, NULL, 0, 3); 2988 2991 } 2989 2992 2990 2993 static int patch_i915_glk_hdmi(struct hda_codec *codec) 2991 2994 { 2992 return intel_hsw_common_init(codec, 0x0b, NULL, 0 );2995 return intel_hsw_common_init(codec, 0x0b, NULL, 0, 3); 2993 2996 } 2994 2997 … … 3001 3004 static const int map[] = {0x0, 0x4, 0x6, 0x8, 0xa, 0xb}; 3002 3005 3003 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map) );3006 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 3); 3004 3007 } 3005 3008 … … 3011 3014 */ 3012 3015 static const int map[] = {0x4, 0x6, 0x8, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf}; 3013 3014 return intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map)); 3016 int ret; 3017 3018 ret = intel_hsw_common_init(codec, 0x02, map, ARRAY_SIZE(map), 4); 3019 if (!ret) { 3020 struct hdmi_spec *spec = codec->spec; 3021 3022 spec->dyn_pcm_no_legacy = true; 3023 } 3024 3025 return ret; 3015 3026 } 3016 3027 -
GPL/trunk/alsa-kernel/pci/hda/patch_realtek.c
r689 r695 299 299 { 300 300 #ifdef CONFIG_SND_HDA_GENERIC_LEDS 301 if (action == HDA_FIXUP_ACT_PR OBE)301 if (action == HDA_FIXUP_ACT_PRE_PROBE) 302 302 snd_hda_gen_add_micmute_led_cdev(codec, NULL); 303 303 #endif … … 3776 3776 report |= SND_JACK_BTN_3; 3777 3777 3778 jack->jack->button_state = report;3778 snd_hda_jack_set_button_state(codec, jack->nid, report); 3779 3779 } 3780 3780 … … 3839 3839 { 3840 3840 struct alc_spec *spec = codec->spec; 3841 hda_nid_t hp_pin; 3841 3842 3842 3843 switch (action) { … … 3845 3846 snd_hda_jack_detect_enable_callback(codec, 0x55, 3846 3847 alc_headset_btn_callback); 3847 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", false, 3848 SND_JACK_HEADSET, alc_headset_btn_keymap); 3849 break; 3850 case HDA_FIXUP_ACT_INIT: 3848 break; 3849 case HDA_FIXUP_ACT_BUILD: 3850 hp_pin = alc_get_hp_pin(spec); 3851 if (!hp_pin || snd_hda_jack_bind_keymap(codec, 0x55, 3852 alc_headset_btn_keymap, 3853 hp_pin)) 3854 snd_hda_jack_add_kctl(codec, 0x55, "Headset Jack", 3855 false, SND_JACK_HEADSET, 3856 alc_headset_btn_keymap); 3857 3851 3858 alc_enable_headset_jack_key(codec); 3852 3859 break; … … 7036 7043 } 7037 7044 } 7045 #endif /* NOT_USED */ 7038 7046 7039 7047 static void alc285_fixup_hp_spectre_x360(struct hda_codec *codec, … … 7054 7062 } 7055 7063 } 7056 #endif /* NOT_USED */7057 7064 7058 7065 /* for hda_fixup_thinkpad_acpi() */ … … 7275 7282 ALC256_FIXUP_ACER_HEADSET_MIC, 7276 7283 ALC285_FIXUP_IDEAPAD_S740_COEF, 7284 ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST, 7277 7285 ALC295_FIXUP_ASUS_DACS, 7278 7286 ALC295_FIXUP_HP_OMEN, … … 8457 8465 {0} 8458 8466 }, 8459 .chained = true,8460 .chain_id = ALC289_FIXUP_ASUS_GA401,8461 8467 }, 8462 8468 [ALC225_FIXUP_DELL_WYSE_MIC_NO_PRESENCE] = { … … 8844 8850 { } 8845 8851 }, 8852 .chained = true, 8853 .chain_id = ALC289_FIXUP_ASUS_GA401, 8846 8854 }, 8847 8855 #endif … … 9117 9125 .chain_id = ALC269_FIXUP_THINKPAD_ACPI, 9118 9126 }, 9127 [ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST] = { 9128 .type = HDA_FIXUP_FUNC, 9129 .v.func = alc269_fixup_limit_int_mic_boost, 9130 .chained = true, 9131 .chain_id = ALC285_FIXUP_HP_MUTE_LED, 9132 }, 9119 9133 [ALC295_FIXUP_ASUS_DACS] = { 9120 9134 .type = HDA_FIXUP_FUNC, … … 9137 9151 { 0x1e, 0x411111f0 }, 9138 9152 { 0x21, 0x03211020 }, 9139 { 0}9153 {} 9140 9154 }, 9141 9155 .chained = true, 9142 9156 .chain_id = ALC269_FIXUP_HP_LINE1_MIC1_LED, 9143 9157 }, 9158 #endif 9144 9159 [ALC285_FIXUP_HP_SPECTRE_X360] = { 9145 9160 .type = HDA_FIXUP_FUNC, 9146 9161 .v.func = alc285_fixup_hp_spectre_x360, 9147 9162 }, 9148 #endif9149 9163 [ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP] = { 9150 9164 .type = HDA_FIXUP_FUNC, … … 9202 9216 SND_PCI_QUIRK(0x1025, 0x1291, "Acer Veriton Z4660G", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), 9203 9217 SND_PCI_QUIRK(0x1025, 0x129c, "Acer SWIFT SF314-55", ALC256_FIXUP_ACER_HEADSET_MIC), 9218 SND_PCI_QUIRK(0x1025, 0x1300, "Acer SWIFT SF314-56", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), 9204 9219 SND_PCI_QUIRK(0x1025, 0x1308, "Acer Aspire Z24-890", ALC286_FIXUP_ACER_AIO_HEADSET_MIC), 9205 9220 SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC), 9206 9221 SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), 9222 SND_PCI_QUIRK(0x1025, 0x142b, "Acer Swift SF314-42", ALC255_FIXUP_ACER_MIC_NO_PRESENCE), 9207 9223 SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), 9208 9224 SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC), … … 9369 9385 SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED), 9370 9386 SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED), 9387 SND_PCI_QUIRK(0x103c, 0x8898, "HP EliteBook 845 G8 Notebook PC", ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST), 9388 SND_PCI_QUIRK(0x103c, 0x88d0, "HP Pavilion 15-eh1xxx (mainboard 88D0)", ALC287_FIXUP_HP_GPIO_LED), 9371 9389 SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), 9372 9390 SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), … … 9552 9570 SND_PCI_QUIRK(0x17aa, 0x3176, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), 9553 9571 SND_PCI_QUIRK(0x17aa, 0x3178, "ThinkCentre Station", ALC283_FIXUP_HEADSET_MIC), 9572 SND_PCI_QUIRK(0x17aa, 0x31af, "ThinkCentre Station", ALC623_FIXUP_LENOVO_THINKSTATION_P340), 9554 9573 SND_PCI_QUIRK(0x17aa, 0x3818, "Lenovo C940", ALC298_FIXUP_LENOVO_SPK_VOLUME), 9555 9574 SND_PCI_QUIRK(0x17aa, 0x3827, "Ideapad S740", ALC285_FIXUP_IDEAPAD_S740_COEF), -
GPL/trunk/alsa-kernel/pci/hda/patch_sigmatel.c
r679 r695 4379 4379 spec->gen.automute_hook = stac_update_outputs; 4380 4380 4381 #ifndef TARGET_OS2 4382 if (spec->gpio_led) 4383 snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook); 4384 #endif 4381 4385 err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg); 4382 4386 if (err < 0) … … 4420 4424 #endif 4421 4425 4422 #ifdef CONFIG_SND_HDA_GENERIC_LEDS4423 if (spec->gpio_led)4424 snd_hda_gen_add_mute_led_cdev(codec, stac_vmaster_hook);4425 #endif4426 4426 if (spec->aloopback_ctl && 4427 4427 snd_hda_get_bool_hint(codec, "loopback") == 1) { -
GPL/trunk/alsa-kernel/pci/hda/thinkpad_helper.c
r679 r695 19 19 const struct hda_fixup *fix, int action) 20 20 { 21 if (action == HDA_FIXUP_ACT_PR OBE) {21 if (action == HDA_FIXUP_ACT_PRE_PROBE) { 22 22 if (!is_thinkpad(codec)) 23 23 return;
Note:
See TracChangeset
for help on using the changeset viewer.
