cs4281pm-24.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*******************************************************************************
  2. *
  3. * "cs4281pm.c" -- Cirrus Logic-Crystal CS4281 linux audio driver.
  4. *
  5. * Copyright (C) 2000,2001 Cirrus Logic Corp.
  6. * -- tom woller (twoller@crystal.cirrus.com) or
  7. * (audio@crystal.cirrus.com).
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  22. *
  23. * 12/22/00 trw - new file.
  24. *
  25. *******************************************************************************/
  26. #ifndef NOT_CS4281_PM
  27. #include <linux/pm.h>
  28. #define cs_pm_register(a, b, c) pm_register((a), (b), (c));
  29. #define cs_pm_unregister_all(a) pm_unregister_all((a));
  30. static int cs4281_suspend(struct cs4281_state *s);
  31. static int cs4281_resume(struct cs4281_state *s);
  32. /*
  33. * for now (12/22/00) only enable the pm_register PM support.
  34. * allow these table entries to be null.
  35. #define CS4281_SUSPEND_TBL cs4281_suspend_tbl
  36. #define CS4281_RESUME_TBL cs4281_resume_tbl
  37. */
  38. #define CS4281_SUSPEND_TBL cs4281_suspend_null
  39. #define CS4281_RESUME_TBL cs4281_resume_null
  40. static int cs4281_pm_callback(struct pm_dev *dev, pm_request_t rqst, void *data)
  41. {
  42. struct cs4281_state *state;
  43. CS_DBGOUT(CS_PM, 2, printk(KERN_INFO
  44. "cs4281: cs4281_pm_callback dev=%p rqst=0x%x state=%p\n",
  45. dev,(unsigned)rqst,data));
  46. state = (struct cs4281_state *) dev->data;
  47. if (state) {
  48. switch(rqst) {
  49. case PM_SUSPEND:
  50. CS_DBGOUT(CS_PM, 2, printk(KERN_INFO
  51. "cs4281: PM suspend request\n"));
  52. if(cs4281_suspend(state))
  53. {
  54. CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO
  55. "cs4281: PM suspend request refused\n"));
  56. return 1;
  57. }
  58. break;
  59. case PM_RESUME:
  60. CS_DBGOUT(CS_PM, 2, printk(KERN_INFO
  61. "cs4281: PM resume request\n"));
  62. if(cs4281_resume(state))
  63. {
  64. CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO
  65. "cs4281: PM resume request refused\n"));
  66. return 1;
  67. }
  68. break;
  69. }
  70. }
  71. return 0;
  72. }
  73. #else /* CS4281_PM */
  74. #define CS4281_SUSPEND_TBL cs4281_suspend_null
  75. #define CS4281_RESUME_TBL cs4281_resume_null
  76. #endif /* CS4281_PM */