Linux 3.12.39
[linux/fpc-iii.git] / sound / pci / hda / hda_i915.c
blob9e136beaa59133c1c1e7c302bfe1fea470732fa9
1 /*
2 * hda_i915.c - routines for Haswell HDA controller power well support
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the Free
6 * Software Foundation; either version 2 of the License, or (at your option)
7 * any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #include <linux/init.h>
20 #include <linux/module.h>
21 #include <sound/core.h>
22 #include <drm/i915_powerwell.h>
23 #include "hda_i915.h"
25 static int (*get_power)(void);
26 static int (*put_power)(void);
27 static int (*get_cdclk)(void);
29 int hda_display_power(bool enable)
31 if (!get_power || !put_power)
32 return -ENODEV;
34 snd_printdd("HDA display power %s \n",
35 enable ? "Enable" : "Disable");
36 if (enable)
37 return get_power();
38 else
39 return put_power();
42 int haswell_get_cdclk(void)
44 if (!get_cdclk)
45 return -EINVAL;
46 return get_cdclk();
49 int hda_i915_init(void)
51 int err = 0;
53 get_power = symbol_request(i915_request_power_well);
54 if (!get_power) {
55 snd_printk(KERN_WARNING "hda-i915: get_power symbol get fail\n");
56 return -ENODEV;
59 put_power = symbol_request(i915_release_power_well);
60 if (!put_power) {
61 symbol_put(i915_request_power_well);
62 get_power = NULL;
63 return -ENODEV;
66 get_cdclk = symbol_request(i915_get_cdclk_freq);
67 if (!get_cdclk) /* may have abnormal BCLK and audio playback rate */
68 snd_printd("hda-i915: get_cdclk symbol get fail\n");
70 snd_printd("HDA driver get symbol successfully from i915 module\n");
72 return err;
75 int hda_i915_exit(void)
77 if (get_power) {
78 symbol_put(i915_request_power_well);
79 get_power = NULL;
81 if (put_power) {
82 symbol_put(i915_release_power_well);
83 put_power = NULL;
85 if (get_cdclk) {
86 symbol_put(i915_get_cdclk_freq);
87 get_cdclk = NULL;
90 return 0;