/testbed/sys/pmf.h

http://rtems-atapi.googlecode.com/ · C Header · 133 lines · 82 code · 24 blank · 27 comment · 1 complexity · 00a5a294934848aba4d015775dbfefa9 MD5 · raw file

  1. /* $NetBSD: pmf.h,v 1.18 2010/02/24 22:38:10 dyoung Exp $ */
  2. /*-
  3. * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  16. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  17. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  19. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. * POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef _SYS_PMF_H
  28. #define _SYS_PMF_H
  29. #ifdef _KERNEL
  30. #include <sys/types.h>
  31. #include "sys/device_if.h"
  32. typedef enum {
  33. PMFE_DISPLAY_ON,
  34. PMFE_DISPLAY_REDUCED,
  35. PMFE_DISPLAY_STANDBY,
  36. PMFE_DISPLAY_SUSPEND,
  37. PMFE_DISPLAY_OFF,
  38. PMFE_DISPLAY_BRIGHTNESS_UP,
  39. PMFE_DISPLAY_BRIGHTNESS_DOWN,
  40. PMFE_AUDIO_VOLUME_UP,
  41. PMFE_AUDIO_VOLUME_DOWN,
  42. PMFE_AUDIO_VOLUME_TOGGLE,
  43. PMFE_CHASSIS_LID_CLOSE,
  44. PMFE_CHASSIS_LID_OPEN
  45. } pmf_generic_event_t;
  46. struct pmf_qual {
  47. const device_suspensor_t *pq_suspensor;
  48. devact_level_t pq_actlvl;
  49. };
  50. typedef struct pmf_qual pmf_qual_t;
  51. extern const pmf_qual_t * const PMF_Q_NONE;
  52. extern const pmf_qual_t * const PMF_Q_SELF;
  53. extern const pmf_qual_t * const PMF_Q_DRVCTL;
  54. extern const device_suspensor_t
  55. * const device_suspensor_self,
  56. * const device_suspensor_system,
  57. * const device_suspensor_drvctl;
  58. void pmf_init(void);
  59. bool pmf_event_inject(device_t, pmf_generic_event_t);
  60. bool pmf_event_register(device_t, pmf_generic_event_t,
  61. void (*)(device_t), bool);
  62. void pmf_event_deregister(device_t, pmf_generic_event_t,
  63. void (*)(device_t), bool);
  64. bool pmf_set_platform(const char *, const char *);
  65. const char *pmf_get_platform(const char *);
  66. bool pmf_system_resume(const pmf_qual_t *);
  67. bool pmf_system_bus_resume(const pmf_qual_t *);
  68. bool pmf_system_suspend(const pmf_qual_t *);
  69. void pmf_system_shutdown(int);
  70. bool pmf_device_register1(device_t,
  71. bool (*)(device_t, const pmf_qual_t *),
  72. bool (*)(device_t, const pmf_qual_t *),
  73. bool (*)(device_t, int));
  74. /* compatibility */
  75. #define pmf_device_register(__d, __s, __r) \
  76. pmf_device_register1((__d), (__s), (__r), NULL)
  77. void pmf_device_deregister(device_t);
  78. bool pmf_device_suspend(device_t, const pmf_qual_t *);
  79. bool pmf_device_resume(device_t, const pmf_qual_t *);
  80. bool pmf_device_recursive_suspend(device_t, const pmf_qual_t *);
  81. bool pmf_device_recursive_resume(device_t, const pmf_qual_t *);
  82. bool pmf_device_descendants_resume(device_t, const pmf_qual_t *);
  83. bool pmf_device_subtree_resume(device_t, const pmf_qual_t *);
  84. bool pmf_device_descendants_release(device_t, const pmf_qual_t *);
  85. bool pmf_device_subtree_release(device_t, const pmf_qual_t *);
  86. struct ifnet;
  87. void pmf_class_network_register(device_t, struct ifnet *);
  88. bool pmf_class_input_register(device_t);
  89. bool pmf_class_display_register(device_t);
  90. void pmf_qual_recursive_copy(pmf_qual_t *, const pmf_qual_t *);
  91. void pmf_self_suspensor_init(device_t, device_suspensor_t *,
  92. pmf_qual_t *);
  93. static inline const device_suspensor_t *
  94. pmf_qual_suspension(const pmf_qual_t *pq)
  95. {
  96. return pq->pq_suspensor;
  97. }
  98. static inline devact_level_t
  99. pmf_qual_depth(const pmf_qual_t *pq)
  100. {
  101. return pq->pq_actlvl;
  102. }
  103. static inline bool
  104. pmf_qual_descend_ok(const pmf_qual_t *pq)
  105. {
  106. return pq->pq_actlvl == DEVACT_LEVEL_FULL;
  107. }
  108. #endif /* !_KERNEL */
  109. #endif /* !_SYS_PMF_H */