hda_i915.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <linux/init.h>
  19. #include <linux/module.h>
  20. #include <sound/core.h>
  21. #include <drm/i915_powerwell.h>
  22. #include "hda_i915.h"
  23. static void (*get_power)(void);
  24. static void (*put_power)(void);
  25. void hda_display_power(bool enable)
  26. {
  27. if (!get_power || !put_power)
  28. return;
  29. snd_printdd("HDA display power %s \n",
  30. enable ? "Enable" : "Disable");
  31. if (enable)
  32. get_power();
  33. else
  34. put_power();
  35. }
  36. int hda_i915_init(void)
  37. {
  38. int err = 0;
  39. get_power = symbol_request(i915_request_power_well);
  40. if (!get_power) {
  41. snd_printk(KERN_WARNING "hda-i915: get_power symbol get fail\n");
  42. return -ENODEV;
  43. }
  44. put_power = symbol_request(i915_release_power_well);
  45. if (!put_power) {
  46. symbol_put(i915_request_power_well);
  47. get_power = NULL;
  48. return -ENODEV;
  49. }
  50. snd_printd("HDA driver get symbol successfully from i915 module\n");
  51. return err;
  52. }
  53. int hda_i915_exit(void)
  54. {
  55. if (get_power) {
  56. symbol_put(i915_request_power_well);
  57. get_power = NULL;
  58. }
  59. if (put_power) {
  60. symbol_put(i915_release_power_well);
  61. put_power = NULL;
  62. }
  63. return 0;
  64. }