![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Set the power mode a power managed object
#include <sys/pm.h>
int pm_setmode(pm_hdl_t hdl,
pm_power_mode_t mode,
unsigned flags);
libpm
The pm_setmode() is used to change the power mode of a power managed object.
The power manager determines whether the requested power mode change is allowed, subject to the current system power management policy. Even if the change is allowed by the power manager, the driver for the object may impose its own power management policy that refuses the request. For example, it may refuse to power down a device that is in use. mode can be either a generic power mode or a object specific power mode. See pm_power_mode_t. The flags variable controls the behavior of the power mode change:
#include <sys/pm.h> #include <fcntl.h> #include <stdlib.h>
int
main(void)
{
pm_hdl_t hdl;
hdl = pm_attach("object", O_RDWR);
if (!pm_valid_hdl(hdl)) {
perror("pm_attach");
return EXIT_FAILURE;
}
// try to set device to active
if (pm_setmode(fd, PM_MODE_ACTIVE, 0) == -1) {
perror("pm_setmode");
// try to force device to active
if (pm_setmode(fd, PM_MODE_ACTIVE, PM_MODE_FORCE) == -1) {
perror("pm_setmode");
}
}
return EXIT_SUCCESS;
}
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |
pm_power_mode_t, pm_attach(), pm_getattr(), pm_getmodes(), pm_modeattr()
![]() |
![]() |
![]() |