PageRenderTime 26ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

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