Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 1 | /* |
| 2 | * hda_i915.c - routines for Haswell HDA controller power well support |
| 3 | * |
| 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. |
| 8 | * |
| 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. |
| 13 | * |
| 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. |
| 17 | */ |
| 18 | |
| 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" |
| 24 | |
Takashi Iwai | 74b0c2d | 2014-06-13 15:14:34 +0200 | [diff] [blame^] | 25 | static int (*get_power)(void); |
| 26 | static int (*put_power)(void); |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 27 | |
Takashi Iwai | 74b0c2d | 2014-06-13 15:14:34 +0200 | [diff] [blame^] | 28 | int hda_display_power(bool enable) |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 29 | { |
| 30 | if (!get_power || !put_power) |
Takashi Iwai | 74b0c2d | 2014-06-13 15:14:34 +0200 | [diff] [blame^] | 31 | return -ENODEV; |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 32 | |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 33 | pr_debug("HDA display power %s \n", |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 34 | enable ? "Enable" : "Disable"); |
| 35 | if (enable) |
Takashi Iwai | 74b0c2d | 2014-06-13 15:14:34 +0200 | [diff] [blame^] | 36 | return get_power(); |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 37 | else |
Takashi Iwai | 74b0c2d | 2014-06-13 15:14:34 +0200 | [diff] [blame^] | 38 | return put_power(); |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | int hda_i915_init(void) |
| 42 | { |
| 43 | int err = 0; |
| 44 | |
| 45 | get_power = symbol_request(i915_request_power_well); |
| 46 | if (!get_power) { |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 47 | pr_warn("hda-i915: get_power symbol get fail\n"); |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 48 | return -ENODEV; |
| 49 | } |
| 50 | |
| 51 | put_power = symbol_request(i915_release_power_well); |
| 52 | if (!put_power) { |
| 53 | symbol_put(i915_request_power_well); |
| 54 | get_power = NULL; |
| 55 | return -ENODEV; |
| 56 | } |
| 57 | |
Takashi Iwai | 4e76a88 | 2014-02-25 12:21:03 +0100 | [diff] [blame] | 58 | pr_debug("HDA driver get symbol successfully from i915 module\n"); |
Wang Xingchao | 99a2008 | 2013-05-30 22:07:10 +0800 | [diff] [blame] | 59 | |
| 60 | return err; |
| 61 | } |
| 62 | |
| 63 | int hda_i915_exit(void) |
| 64 | { |
| 65 | if (get_power) { |
| 66 | symbol_put(i915_request_power_well); |
| 67 | get_power = NULL; |
| 68 | } |
| 69 | if (put_power) { |
| 70 | symbol_put(i915_release_power_well); |
| 71 | put_power = NULL; |
| 72 | } |
| 73 | |
| 74 | return 0; |
| 75 | } |