aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_i915.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/hda/hda_i915.c')
-rw-r--r--sound/pci/hda/hda_i915.c67
1 files changed, 61 insertions, 6 deletions
diff --git a/sound/pci/hda/hda_i915.c b/sound/pci/hda/hda_i915.c
index 9d07e4edacdb..8b4940ba33d6 100644
--- a/sound/pci/hda/hda_i915.c
+++ b/sound/pci/hda/hda_i915.c
@@ -20,24 +20,71 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <sound/core.h> 21#include <sound/core.h>
22#include <drm/i915_powerwell.h> 22#include <drm/i915_powerwell.h>
23#include "hda_priv.h"
23#include "hda_i915.h" 24#include "hda_i915.h"
24 25
25static void (*get_power)(void); 26/* Intel HSW/BDW display HDA controller Extended Mode registers.
26static void (*put_power)(void); 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
34static int (*get_power)(void);
35static int (*put_power)(void);
36static int (*get_cdclk)(void);
27 37
28void hda_display_power(bool enable) 38int hda_display_power(bool enable)
29{ 39{
30 if (!get_power || !put_power) 40 if (!get_power || !put_power)
31 return; 41 return -ENODEV;
32 42
33 pr_debug("HDA display power %s \n", 43 pr_debug("HDA display power %s \n",
34 enable ? "Enable" : "Disable"); 44 enable ? "Enable" : "Disable");
35 if (enable) 45 if (enable)
36 get_power(); 46 return get_power();
37 else 47 else
38 put_power(); 48 return put_power();
49}
50
51void 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);
39} 85}
40 86
87
41int hda_i915_init(void) 88int hda_i915_init(void)
42{ 89{
43 int err = 0; 90 int err = 0;
@@ -55,6 +102,10 @@ int hda_i915_init(void)
55 return -ENODEV; 102 return -ENODEV;
56 } 103 }
57 104
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
58 pr_debug("HDA driver get symbol successfully from i915 module\n"); 109 pr_debug("HDA driver get symbol successfully from i915 module\n");
59 110
60 return err; 111 return err;
@@ -70,6 +121,10 @@ int hda_i915_exit(void)
70 symbol_put(i915_release_power_well); 121 symbol_put(i915_release_power_well);
71 put_power = NULL; 122 put_power = NULL;
72 } 123 }
124 if (get_cdclk) {
125 symbol_put(i915_get_cdclk_freq);
126 get_cdclk = NULL;
127 }
73 128
74 return 0; 129 return 0;
75} 130}