Skip to content

Commit 88b5a85

Browse files
committed
Merge tag 'sound-3.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound fixes from Takashi Iwai: "This contains a few fixes for HD-audio: yet another Dell headset pin quirk, a fixup for Thinkpad T540P, and an improved fix for Haswell/Broadwell HDMI clock setup" * tag 'sound-3.16-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: ALSA: hda - restore BCLK M/N value as per CDCLK for HSW/BDW display HDA controller drm/i915: provide interface for audio driver to query cdclk ALSA: hda - Add a fixup for Thinkpad T540p ALSA: hda - Add another headset pin quirk for some Dell machines
2 parents b82207b + e4d9e51 commit 88b5a85

File tree

6 files changed

+101
-41
lines changed

6 files changed

+101
-41
lines changed

drivers/gpu/drm/i915/intel_pm.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6038,6 +6038,27 @@ int i915_release_power_well(void)
60386038
}
60396039
EXPORT_SYMBOL_GPL(i915_release_power_well);
60406040

6041+
/*
6042+
* Private interface for the audio driver to get CDCLK in kHz.
6043+
*
6044+
* Caller must request power well using i915_request_power_well() prior to
6045+
* making the call.
6046+
*/
6047+
int i915_get_cdclk_freq(void)
6048+
{
6049+
struct drm_i915_private *dev_priv;
6050+
6051+
if (!hsw_pwr)
6052+
return -ENODEV;
6053+
6054+
dev_priv = container_of(hsw_pwr, struct drm_i915_private,
6055+
power_domains);
6056+
6057+
return intel_ddi_get_cdclk_freq(dev_priv);
6058+
}
6059+
EXPORT_SYMBOL_GPL(i915_get_cdclk_freq);
6060+
6061+
60416062
#define POWER_DOMAIN_MASK (BIT(POWER_DOMAIN_NUM) - 1)
60426063

60436064
#define HSW_ALWAYS_ON_POWER_DOMAINS ( \

include/drm/i915_powerwell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
/* For use by hda_i915 driver */
3333
extern int i915_request_power_well(void);
3434
extern int i915_release_power_well(void);
35+
extern int i915_get_cdclk_freq(void);
3536

3637
#endif /* _I915_POWERWELL_H_ */

sound/pci/hda/hda_i915.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,20 @@
2020
#include <linux/module.h>
2121
#include <sound/core.h>
2222
#include <drm/i915_powerwell.h>
23+
#include "hda_priv.h"
2324
#include "hda_i915.h"
2425

26+
/* Intel HSW/BDW display HDA controller Extended Mode registers.
27+
* EM4 (M value) and EM5 (N Value) are used to convert CDClk (Core Display
28+
* Clock) to 24MHz BCLK: BCLK = CDCLK * M / N
29+
* The values will be lost when the display power well is disabled.
30+
*/
31+
#define ICH6_REG_EM4 0x100c
32+
#define ICH6_REG_EM5 0x1010
33+
2534
static int (*get_power)(void);
2635
static int (*put_power)(void);
36+
static int (*get_cdclk)(void);
2737

2838
int hda_display_power(bool enable)
2939
{
@@ -38,6 +48,43 @@ int hda_display_power(bool enable)
3848
return put_power();
3949
}
4050

51+
void haswell_set_bclk(struct azx *chip)
52+
{
53+
int cdclk_freq;
54+
unsigned int bclk_m, bclk_n;
55+
56+
if (!get_cdclk)
57+
return;
58+
59+
cdclk_freq = get_cdclk();
60+
switch (cdclk_freq) {
61+
case 337500:
62+
bclk_m = 16;
63+
bclk_n = 225;
64+
break;
65+
66+
case 450000:
67+
default: /* default CDCLK 450MHz */
68+
bclk_m = 4;
69+
bclk_n = 75;
70+
break;
71+
72+
case 540000:
73+
bclk_m = 4;
74+
bclk_n = 90;
75+
break;
76+
77+
case 675000:
78+
bclk_m = 8;
79+
bclk_n = 225;
80+
break;
81+
}
82+
83+
azx_writew(chip, EM4, bclk_m);
84+
azx_writew(chip, EM5, bclk_n);
85+
}
86+
87+
4188
int hda_i915_init(void)
4289
{
4390
int err = 0;
@@ -55,6 +102,10 @@ int hda_i915_init(void)
55102
return -ENODEV;
56103
}
57104

105+
get_cdclk = symbol_request(i915_get_cdclk_freq);
106+
if (!get_cdclk) /* may have abnormal BCLK and audio playback rate */
107+
pr_warn("hda-i915: get_cdclk symbol get fail\n");
108+
58109
pr_debug("HDA driver get symbol successfully from i915 module\n");
59110

60111
return err;
@@ -70,6 +121,10 @@ int hda_i915_exit(void)
70121
symbol_put(i915_release_power_well);
71122
put_power = NULL;
72123
}
124+
if (get_cdclk) {
125+
symbol_put(i915_get_cdclk_freq);
126+
get_cdclk = NULL;
127+
}
73128

74129
return 0;
75130
}

sound/pci/hda/hda_i915.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818

1919
#ifdef CONFIG_SND_HDA_I915
2020
int hda_display_power(bool enable);
21+
void haswell_set_bclk(struct azx *chip);
2122
int hda_i915_init(void);
2223
int hda_i915_exit(void);
2324
#else
2425
static inline int hda_display_power(bool enable) { return 0; }
26+
static inline void haswell_set_bclk(struct azx *chip) { return; }
2527
static inline int hda_i915_init(void)
2628
{
2729
return -ENODEV;

sound/pci/hda/hda_intel.c

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
#include <linux/vga_switcheroo.h>
6363
#include <linux/firmware.h>
6464
#include "hda_codec.h"
65-
#include "hda_i915.h"
6665
#include "hda_controller.h"
6766
#include "hda_priv.h"
67+
#include "hda_i915.h"
6868

6969

7070
static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
@@ -288,21 +288,8 @@ static char *driver_short_names[] = {
288288
[AZX_DRIVER_GENERIC] = "HD-Audio Generic",
289289
};
290290

291-
292-
/* Intel HSW/BDW display HDA controller Extended Mode registers.
293-
* EM4 (M value) and EM5 (N Value) are used to convert CDClk (Core Display
294-
* Clock) to 24MHz BCLK: BCLK = CDCLK * M / N
295-
* The values will be lost when the display power well is disabled.
296-
*/
297-
#define ICH6_REG_EM4 0x100c
298-
#define ICH6_REG_EM5 0x1010
299-
300291
struct hda_intel {
301292
struct azx chip;
302-
303-
/* HSW/BDW display HDA controller to restore BCLK from CDCLK */
304-
unsigned int bclk_m;
305-
unsigned int bclk_n;
306293
};
307294

308295

@@ -598,22 +585,6 @@ static int param_set_xint(const char *val, const struct kernel_param *kp)
598585
#define azx_del_card_list(chip) /* NOP */
599586
#endif /* CONFIG_PM */
600587

601-
static void haswell_save_bclk(struct azx *chip)
602-
{
603-
struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
604-
605-
hda->bclk_m = azx_readw(chip, EM4);
606-
hda->bclk_n = azx_readw(chip, EM5);
607-
}
608-
609-
static void haswell_restore_bclk(struct azx *chip)
610-
{
611-
struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
612-
613-
azx_writew(chip, EM4, hda->bclk_m);
614-
azx_writew(chip, EM5, hda->bclk_n);
615-
}
616-
617588
#if defined(CONFIG_PM_SLEEP) || defined(SUPPORT_VGA_SWITCHEROO)
618589
/*
619590
* power management
@@ -641,12 +612,6 @@ static int azx_suspend(struct device *dev)
641612
chip->irq = -1;
642613
}
643614

644-
/* Save BCLK M/N values before they become invalid in D3.
645-
* Will test if display power well can be released now.
646-
*/
647-
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
648-
haswell_save_bclk(chip);
649-
650615
if (chip->msi)
651616
pci_disable_msi(chip->pci);
652617
pci_disable_device(pci);
@@ -668,7 +633,7 @@ static int azx_resume(struct device *dev)
668633

669634
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
670635
hda_display_power(true);
671-
haswell_restore_bclk(chip);
636+
haswell_set_bclk(chip);
672637
}
673638
pci_set_power_state(pci, PCI_D0);
674639
pci_restore_state(pci);
@@ -713,10 +678,9 @@ static int azx_runtime_suspend(struct device *dev)
713678
azx_stop_chip(chip);
714679
azx_enter_link_reset(chip);
715680
azx_clear_irq_pending(chip);
716-
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
717-
haswell_save_bclk(chip);
681+
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
718682
hda_display_power(false);
719-
}
683+
720684
return 0;
721685
}
722686

@@ -736,7 +700,7 @@ static int azx_runtime_resume(struct device *dev)
736700

737701
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL) {
738702
hda_display_power(true);
739-
haswell_restore_bclk(chip);
703+
haswell_set_bclk(chip);
740704
}
741705

742706
/* Read STATESTS before controller reset */
@@ -1426,6 +1390,10 @@ static int azx_first_init(struct azx *chip)
14261390

14271391
/* initialize chip */
14281392
azx_init_pci(chip);
1393+
1394+
if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
1395+
haswell_set_bclk(chip);
1396+
14291397
azx_init_chip(chip, (probe_only[dev] & 2) == 0);
14301398

14311399
/* codec detection */

sound/pci/hda/patch_realtek.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4880,6 +4880,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
48804880
SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
48814881
SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad T440s", ALC292_FIXUP_TPT440_DOCK),
48824882
SND_PCI_QUIRK(0x17aa, 0x220e, "Thinkpad T440p", ALC292_FIXUP_TPT440_DOCK),
4883+
SND_PCI_QUIRK(0x17aa, 0x2210, "Thinkpad T540p", ALC292_FIXUP_TPT440_DOCK),
48834884
SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
48844885
SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
48854886
SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
@@ -5085,6 +5086,18 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = {
50855086
{0x1b, 0x411111f0},
50865087
{0x1d, 0x40700001},
50875088
{0x1e, 0x411111f0}),
5089+
SND_HDA_PIN_QUIRK(0x10ec0293, 0x1028, "Dell", ALC293_FIXUP_DELL1_MIC_NO_PRESENCE,
5090+
{0x12, 0x40000000},
5091+
{0x13, 0x90a60140},
5092+
{0x14, 0x90170110},
5093+
{0x15, 0x0221401f},
5094+
{0x16, 0x411111f0},
5095+
{0x18, 0x411111f0},
5096+
{0x19, 0x411111f0},
5097+
{0x1a, 0x411111f0},
5098+
{0x1b, 0x411111f0},
5099+
{0x1d, 0x40700001},
5100+
{0x1e, 0x411111f0}),
50885101
{}
50895102
};
50905103

0 commit comments

Comments
 (0)