OSDN Git Service

hardware: libhardware: Power HAL add power hints
authorTodd Poynor <toddpoynor@google.com>
Tue, 24 Apr 2012 20:39:15 +0000 (13:39 -0700)
committerTodd Poynor <toddpoynor@google.com>
Wed, 25 Apr 2012 18:15:16 +0000 (11:15 -0700)
Change-Id: I8ab0376e4f5d8ef09d5b1062cbfbb30c30c5bb96
Signed-off-by: Todd Poynor <toddpoynor@google.com>
include/hardware/power.h
modules/power/power.c

index 825a74a..1cb2134 100644 (file)
@@ -30,6 +30,17 @@ __BEGIN_DECLS
  */
 #define POWER_HARDWARE_MODULE_ID "power"
 
+/*
+ * Power hint identifiers passed to (*powerHint)
+ */
+
+typedef enum {
+    /*
+     * VSYNC pulse request from SurfaceFlinger started or stopped.
+     */
+    POWER_HINT_VSYNC = 0x00000001,
+} power_hint_t;
+
 /**
  * Every hardware module must have a data structure named HAL_MODULE_INFO_SYM
  * and the fields of this data structure must begin with hw_module_t
@@ -40,7 +51,9 @@ typedef struct power_module {
 
     /*
      * (*init)() performs power management setup actions at runtime
-     * startup, such as to set default cpufreq parameters.
+     * startup, such as to set default cpufreq parameters.  This is
+     * called only by the Power HAL instance loaded by
+     * PowerManagerService.
      */
     void (*init)(struct power_module *module);
 
@@ -71,6 +84,25 @@ typedef struct power_module {
      * interactive state prior to turning on the screen.
      */
     void (*setInteractive)(struct power_module *module, int on);
+
+    /*
+     * (*powerHint) is called to pass hints on power requirements, which
+     * may result in adjustment of power/performance parameters of the
+     * cpufreq governor and other controls.  The possible hints are:
+     *
+     * POWER_HINT_VSYNC
+     *
+     *     Foreground app has started or stopped requesting a VSYNC pulse
+     *     from SurfaceFlinger.  If the app has started requesting VSYNC
+     *     then CPU and GPU load is expected soon, and it may be appropriate
+     *     to raise speeds of CPU, memory bus, etc.  The data parameter is
+     *     non-zero to indicate VSYNC pulse is now requested, or zero for
+     *     VSYNC pulse no longer requested.
+     *
+     * A particular platform may choose to ignore any hint.
+     */
+    void (*powerHint)(struct power_module *module, power_hint_t hint,
+                      void *data);
 } power_module_t;
 
 
index ef3fe94..7d8c112 100644 (file)
@@ -59,6 +59,13 @@ static void power_set_interactive(struct power_module *module, int on)
     }
 }
 
+static void power_hint(struct power_module *module, power_hint_t hint,
+                       void *data) {
+    switch (hint) {
+    default:
+        break;
+    }
+}
 
 static struct hw_module_methods_t power_module_methods = {
     .open = NULL,
@@ -77,4 +84,5 @@ struct power_module HAL_MODULE_INFO_SYM = {
 
     .init = power_init,
     .setInteractive = power_set_interactive,
+    .powerHint = power_hint,
 };