Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add cpuSetOptions API to org.codeaurora.Performance class

Change-Id: I66f7e910f4fee0a9d443356b00b452872628d3f0
  • Loading branch information...
commit 0d31e233a06ea4e9eea1efe1e4318ebadc50811f 1 parent 11466d3
David Ng authored existz committed
11 core/java/org/codeaurora/Performance.java
... ... @@ -1,5 +1,5 @@
1 1 /*
2   - * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
  2 + * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
3 3 *
4 4 * Redistribution and use in source and binary forms, with or without
5 5 * modification, are permitted provided that the following conditions are met:
@@ -49,6 +49,15 @@ public void cpuBoost(int ntasks) {
49 49 native_cpu_boost(ntasks);
50 50 }
51 51
  52 + /** @hide */ public static final int CPUOPT_CPU0_PWRCLSP = 1;
  53 + /** @hide */ public static final int CPUOPT_CPU0_FREQMIN = 2;
  54 +
  55 + /** &hide */
  56 + public int cpuSetOptions(int reqType, int reqValue) {
  57 + return native_cpu_setoptions(reqType, reqValue);
  58 + }
  59 +
52 60 private native void native_cpu_boost(int ntasks);
  61 + private native int native_cpu_setoptions(int reqtype, int reqvalue);
53 62 private native void native_deinit();
54 63 }
35 core/jni/org_codeaurora_Performance.cpp
... ... @@ -1,5 +1,5 @@
1 1 /*
2   - * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
  2 + * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
3 3 *
4 4 * Redistribution and use in source and binary forms, with or without
5 5 * modification, are permitted provided that the following conditions are met:
@@ -46,8 +46,9 @@ namespace android
46 46
47 47 // ----------------------------------------------------------------------------
48 48
49   -static void (*cpu_boost)(int) = NULL;
50   -static void *dlhandle = NULL;
  49 +static void (*cpu_boost)(int) = NULL;
  50 +static int (*cpu_setoptions)(int, int) = NULL;
  51 +static void *dlhandle = NULL;
51 52
52 53 // ----------------------------------------------------------------------------
53 54
@@ -79,11 +80,15 @@ org_codeaurora_performance_native_init()
79 80
80 81 dlerror();
81 82
82   - *(void **) (&cpu_boost) = dlsym(dlhandle, "perf_cpu_boost");
  83 + cpu_boost = (void (*) (int))dlsym(dlhandle, "perf_cpu_boost");
83 84 if ((rc = dlerror()) != NULL) {
84 85 goto cleanup;
85 86 }
86   - *(void **) (&init) = dlsym(dlhandle, "libqc_opt_init");
  87 + cpu_setoptions = (int (*) (int, int))dlsym(dlhandle, "perf_cpu_setoptions");
  88 + if ((rc = dlerror()) != NULL) {
  89 + goto cleanup;
  90 + }
  91 + init = (void (*) ())dlsym(dlhandle, "libqc_opt_init");
87 92 if ((rc = dlerror()) != NULL) {
88 93 goto cleanup;
89 94 }
@@ -91,7 +96,8 @@ org_codeaurora_performance_native_init()
91 96 return;
92 97
93 98 cleanup:
94   - cpu_boost = NULL;
  99 + cpu_boost = NULL;
  100 + cpu_setoptions = NULL;
95 101 if (dlhandle) {
96 102 dlclose(dlhandle);
97 103 dlhandle = NULL;
@@ -104,9 +110,10 @@ org_codeaurora_performance_native_deinit(JNIEnv *env, jobject clazz)
104 110 void (*deinit)(void);
105 111
106 112 if (dlhandle) {
107   - cpu_boost = NULL;
  113 + cpu_boost = NULL;
  114 + cpu_setoptions = NULL;
108 115
109   - *(void **) (&deinit) = dlsym(dlhandle, "libqc_opt_deinit");
  116 + deinit = (void (*) ())dlsym(dlhandle, "libqc_opt_deinit");
110 117 if (deinit) {
111 118 (*deinit)();
112 119 }
@@ -124,10 +131,22 @@ org_codeaurora_performance_native_cpu_boost(JNIEnv *env, jobject clazz, jint nta
124 131 }
125 132 }
126 133
  134 +static jint
  135 +org_codeaurora_performance_native_cpu_setoptions(JNIEnv *env, jobject clazz,
  136 + jint reqtype, jint reqvalue)
  137 +{
  138 + if (cpu_setoptions) {
  139 + return (*cpu_setoptions)(reqtype, reqvalue);
  140 + }
  141 + return 0;
  142 +}
  143 +
  144 +
127 145 // ----------------------------------------------------------------------------
128 146
129 147 static JNINativeMethod gMethods[] = {
130 148 {"native_cpu_boost", "(I)V", (void *)org_codeaurora_performance_native_cpu_boost},
  149 + {"native_cpu_setoptions", "(II)I", (int *)org_codeaurora_performance_native_cpu_setoptions},
131 150 {"native_deinit", "()V", (void *)org_codeaurora_performance_native_deinit},
132 151 };
133 152

0 comments on commit 0d31e23

Please sign in to comment.
Something went wrong with that request. Please try again.