[Previous] [Contents] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

pm_modeattr()

Get the power modes and capabilities supported by a power managed object

Synopsis:

#include <sys/pm.h>

int pm_modeattr(pm_hdl_t hdl, 
                pmd_mode_attr_t *modes, 
		int nmodes); 

Arguments:

hdl
Handle to the object -- obtained via pm_attach().
modes
Pointer to where the list of modes are returned.
nmodes
Number of modes that are returned.

Library:

libpm

Description:

the pm_modeattr() is used to get a list of the power modes supported by a power managed object.

For each mode, the pmd_mode_attr_t describes:

mode
The power mode.
flags
Describe the driver capabilities for that mode:
PMD_MODE_ATTR_NORAM
Support the PM_MODE_NORAM flag and can be used for system power modes where system RAM is disabled.
PMD_MODE_ATTR_HWVOL
Support the PM_MODE_HWVOL flag and can be used for system power modes where peripheral device registers are lost.
PMD_MODE_ATTR_WAKEUP
Support system wakeup functionality and can be used to configure the device to act as a wakeup source for low power system standby modes.

Returns:

If successful, the number of modes supported by the object , or -1 when an error occurred (errno is set).

Errors:

EBADF
hdl is not a valid handle.
EFAULT
A fault occurred accessing modes.

Examples:

#include <sys/pm.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <alloca.h>

int
main(void)
{
   pm_hdl_t    hdl;
   int         i;
   
   int         nmode;
   pmd_mode_attr_t *modes;

   hdl = pm_attach("object", O_RDONLY);
   if (!pm_valid_hdl(hdl)) {
       perror("pm_attach");
       return EXIT_FAILURE;
   }

   nmode = pm_modeattr(fd, 0, 0);
   if (nmode < 0) {
      perror("pm_modeattr");
      return EXIT_FAILURE;
      }
   printf("Device supports %d modes:", nmode);

   modes = alloca(nmode * sizeof(*modes));
   if (modes == 0) {
      perror("alloca");
      return EXIT_FAILURE;
      }

   nmode = pm_modeattr(fd, modes, nmode);
   if (nmode < 0) {
      perror("pm_modeattr");
      return EXIT_FAILURE;
      }
      
   for (i = 0; i < nmode; i++) {
   printf("%d: mode=0x%x flags=0x%x\n", i, 
          modes[i].mode, 
          modes[i].flags);
     }
   return EXIT_SUCCESS;
}

Classification:

Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

pm_power_mode_t, pm_attach(), pm_getattr(), pm_setmode(), pm_getmodes()


[Previous] [Contents] [Next]