summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-07-26 14:26:42 +0200
committerDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2012-07-26 14:29:53 +0200
commitd9edbbe43d6a6d67a3d334e806b7b18fb0469dd4 (patch)
treece4bf2e50230a4b993c85e350e7f55988d8c5e1c
parent545adfb6077d754aec40e2e913655f4bd56e35da (diff)
downloaddevice_samsung_p3100-d9edbbe43d6a6d67a3d334e806b7b18fb0469dd4.zip
device_samsung_p3100-d9edbbe43d6a6d67a3d334e806b7b18fb0469dd4.tar.gz
device_samsung_p3100-d9edbbe43d6a6d67a3d334e806b7b18fb0469dd4.tar.bz2
added piranha power hal
Change-Id: Id372687a4c9965cf86b9c2afb4566603a1a215ee
-rw-r--r--p3100.mk10
-rwxr-xr-xp31xx-common.mk89
-rw-r--r--power/Android.mk27
-rw-r--r--power/power_piranha.c161
4 files changed, 238 insertions, 49 deletions
diff --git a/p3100.mk b/p3100.mk
index b88ff91..10d20db 100644
--- a/p3100.mk
+++ b/p3100.mk
@@ -22,17 +22,17 @@ DEVICE_PACKAGE_OVERLAYS += $(LOCAL_PATH)/overlay
# Audio
PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/configs/tiny_hw.xml:system/etc/sound/espressorf \
- $(LOCAL_PATH)/configs/audio_policy.conf:system/etc/audio_policy.conf
+ $(LOCAL_PATH)/configs/tiny_hw.xml:system/etc/sound/espressorf \
+ $(LOCAL_PATH)/configs/audio_policy.conf:system/etc/audio_policy.conf
# Packages
PRODUCT_PACKAGES += \
- SamsungServiceMode
+ SamsungServiceMode
# RIL
PRODUCT_PROPERTY_OVERRIDES += \
- ro.telephony.ril_class=Smdk4210RIL \
- mobiledata.interfaces=pdp0,wlan0,gprs,ppp0
+ ro.telephony.ril_class=Smdk4210RIL \
+ mobiledata.interfaces=pdp0,wlan0,gprs,ppp0
# These are the hardware-specific features
PRODUCT_COPY_FILES += \
diff --git a/p31xx-common.mk b/p31xx-common.mk
index 3cca000..9c176b0 100755
--- a/p31xx-common.mk
+++ b/p31xx-common.mk
@@ -30,73 +30,74 @@ PRODUCT_LOCALES += hdpi
# Init files
PRODUCT_COPY_FILES := \
- $(LOCAL_PATH)/init.espresso.usb.rc:root/init.espresso.usb.rc \
- $(LOCAL_PATH)/init.espresso.rc:root/init.espresso.rc \
- $(LOCAL_PATH)/ueventd.espresso.rc:root/ueventd.espresso.rc
+ $(LOCAL_PATH)/init.espresso.usb.rc:root/init.espresso.usb.rc \
+ $(LOCAL_PATH)/init.espresso.rc:root/init.espresso.rc \
+ $(LOCAL_PATH)/ueventd.espresso.rc:root/ueventd.espresso.rc
# Vold
PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/configs/vold.fstab:system/etc/vold.fstab
+ $(LOCAL_PATH)/configs/vold.fstab:system/etc/vold.fstab
# GPS
PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/configs/gps.conf:system/etc/gps.conf \
- $(LOCAL_PATH)/configs/gps.xml:system/etc/gps.xml
+ $(LOCAL_PATH)/configs/gps.conf:system/etc/gps.conf \
+ $(LOCAL_PATH)/configs/gps.xml:system/etc/gps.xml
# Wifi
PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/configs/wpa_supplicant.conf:system/etc/wifi/wpa_supplicant.conf
+ $(LOCAL_PATH)/configs/wpa_supplicant.conf:system/etc/wifi/wpa_supplicant.conf
PRODUCT_PROPERTY_OVERRIDES += \
- wifi.interface=wlan0 \
- wifi.supplicant_scan_interval=15
+ wifi.interface=wlan0 \
+ wifi.supplicant_scan_interval=15
# Media profiles
PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/configs/media_codecs.xml:system/etc/media_codecs.xml \
- $(LOCAL_PATH)/configs/media_profiles.xml:system/etc/media_profiles.xml
+ $(LOCAL_PATH)/configs/media_codecs.xml:system/etc/media_codecs.xml \
+ $(LOCAL_PATH)/configs/media_profiles.xml:system/etc/media_profiles.xml
# Keylayout
PRODUCT_COPY_FILES += \
- $(LOCAL_PATH)/usr/keychars/espresso-gpio-keypad.kcm:system/usr/keychars/espresso-gpio-keypad.kcm \
- $(LOCAL_PATH)/usr/keychars/Generic.kcm:system/usr/keychars/Generic.kcm \
- $(LOCAL_PATH)/usr/keychars/qwerty.kcm:system/usr/keychars/qwerty.kcm \
- $(LOCAL_PATH)/usr/keychars/qwerty2.kcm:system/usr/keychars/qwerty2.kcm \
- $(LOCAL_PATH)/usr/keychars/Virtual.kcm:system/usr/keychars/Virtual.kcm \
- $(LOCAL_PATH)/usr/keylayout/AVRCP.kl:system/usr/keylayout/AVRCP.kl \
- $(LOCAL_PATH)/usr/keylayout/espresso-gpio-keypad.kl:system/usr/keylayout/espresso-gpio-keypad.kl \
- $(LOCAL_PATH)/usr/keylayout/Generic.kl:system/usr/keylayout/Generic.kl \
- $(LOCAL_PATH)/usr/keylayout/qwerty.kl:system/usr/keylayout/qwerty.kl \
- $(LOCAL_PATH)/usr/keylayout/sec_keyboard.kl:system/usr/keylayout/sec_keyboard.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_04e8_Product_7021.kl:system/usr/keylayout/Vendor_04e8_Product_7021.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_05ac_Product_0239.kl:system/usr/keylayout/Vendor_05ac_Product_0239.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_22b8_Product_093d.kl:system/usr/keylayout/Vendor_22b8_Product_093d.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_045e_Product_028e.kl:system/usr/keylayout/Vendor_045e_Product_028e.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c216.kl:system/usr/keylayout/Vendor_046d_Product_c216.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c294.kl:system/usr/keylayout/Vendor_046d_Product_c294.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c299.kl:system/usr/keylayout/Vendor_046d_Product_c299.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c532.kl:system/usr/keylayout/Vendor_046d_Product_c532.kl \
- $(LOCAL_PATH)/usr/keylayout/Vendor_054c_Product_0268.kl:system/usr/keylayout/Vendor_054c_Product_0268.kl
+ $(LOCAL_PATH)/usr/keychars/espresso-gpio-keypad.kcm:system/usr/keychars/espresso-gpio-keypad.kcm \
+ $(LOCAL_PATH)/usr/keychars/Generic.kcm:system/usr/keychars/Generic.kcm \
+ $(LOCAL_PATH)/usr/keychars/qwerty.kcm:system/usr/keychars/qwerty.kcm \
+ $(LOCAL_PATH)/usr/keychars/qwerty2.kcm:system/usr/keychars/qwerty2.kcm \
+ $(LOCAL_PATH)/usr/keychars/Virtual.kcm:system/usr/keychars/Virtual.kcm \
+ $(LOCAL_PATH)/usr/keylayout/AVRCP.kl:system/usr/keylayout/AVRCP.kl \
+ $(LOCAL_PATH)/usr/keylayout/espresso-gpio-keypad.kl:system/usr/keylayout/espresso-gpio-keypad.kl \
+ $(LOCAL_PATH)/usr/keylayout/Generic.kl:system/usr/keylayout/Generic.kl \
+ $(LOCAL_PATH)/usr/keylayout/qwerty.kl:system/usr/keylayout/qwerty.kl \
+ $(LOCAL_PATH)/usr/keylayout/sec_keyboard.kl:system/usr/keylayout/sec_keyboard.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_04e8_Product_7021.kl:system/usr/keylayout/Vendor_04e8_Product_7021.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_05ac_Product_0239.kl:system/usr/keylayout/Vendor_05ac_Product_0239.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_22b8_Product_093d.kl:system/usr/keylayout/Vendor_22b8_Product_093d.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_045e_Product_028e.kl:system/usr/keylayout/Vendor_045e_Product_028e.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c216.kl:system/usr/keylayout/Vendor_046d_Product_c216.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c294.kl:system/usr/keylayout/Vendor_046d_Product_c294.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c299.kl:system/usr/keylayout/Vendor_046d_Product_c299.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_046d_Product_c532.kl:system/usr/keylayout/Vendor_046d_Product_c532.kl \
+ $(LOCAL_PATH)/usr/keylayout/Vendor_054c_Product_0268.kl:system/usr/keylayout/Vendor_054c_Product_0268.kl
# Packages
PRODUCT_PACKAGES += \
audio.a2dp.default \
audio.primary.piranha \
audio.usb.default \
- lights.piranha \
- libtinyalsa \
- libaudioutils \
- libinvensense_mpl \
- hwcomposer.omap4 \
- smc_pa_ctrl \
- tf_daemon \
- tinymix
+ hwcomposer.omap4 \
+ lights.piranha \
+ libtinyalsa \
+ libaudioutils \
+ libinvensense_mpl \
+ power.piranha \
+ smc_pa_ctrl \
+ tf_daemon \
+ tinymix
# Filesystem management tools
PRODUCT_PACKAGES += \
- static_busybox \
- make_ext4fs \
- setup_fs
+ static_busybox \
+ make_ext4fs \
+ setup_fs
# Charger
PRODUCT_PACKAGES += \
@@ -133,14 +134,14 @@ PRODUCT_PACKAGES += \
# Feature live wallpaper
PRODUCT_COPY_FILES += \
- packages/wallpapers/LivePicker/android.software.live_wallpaper.xml:system/etc/permissions/android.software.live_wallpaper.xml
+ packages/wallpapers/LivePicker/android.software.live_wallpaper.xml:system/etc/permissions/android.software.live_wallpaper.xml
PRODUCT_PROPERTY_OVERRIDES += \
- ro.opengles.version=131072
+ ro.opengles.version=131072
# Set default USB interface
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
- persist.sys.usb.config=mtp
+ persist.sys.usb.config=mtp
PRODUCT_TAGS += dalvik.gc.type-precise
diff --git a/power/Android.mk b/power/Android.mk
new file mode 100644
index 0000000..b7ad50f
--- /dev/null
+++ b/power/Android.mk
@@ -0,0 +1,27 @@
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+LOCAL_PATH := $(call my-dir)
+
+# HAL module implemenation stored in
+# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
+LOCAL_SHARED_LIBRARIES := liblog libcutils
+LOCAL_SRC_FILES := power_piranha.c
+LOCAL_MODULE := power.piranha
+LOCAL_MODULE_TAGS := optional
+include $(BUILD_SHARED_LIBRARY)
diff --git a/power/power_piranha.c b/power/power_piranha.c
new file mode 100644
index 0000000..0f0d7ef
--- /dev/null
+++ b/power/power_piranha.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define LOG_TAG "Piranha PowerHAL"
+#include <utils/Log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/power.h>
+
+#define BOOSTPULSE_PATH "/sys/devices/system/cpu/cpufreq/interactive/boostpulse"
+
+struct piranha_power_module {
+ struct power_module base;
+ pthread_mutex_t lock;
+ int boostpulse_fd;
+ int boostpulse_warned;
+};
+
+static void sysfs_write(char *path, char *s)
+{
+ char buf[80];
+ int len;
+ int fd = open(path, O_WRONLY);
+
+ if (fd < 0) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error opening %s: %s\n", path, buf);
+ return;
+ }
+
+ len = write(fd, s, strlen(s));
+ if (len < 0) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error writing to %s: %s\n", path, buf);
+ }
+
+ close(fd);
+}
+
+static void piranha_power_init(struct power_module *module)
+{
+ /*
+ * cpufreq interactive governor: timer 20ms, min sample 60ms,
+ * hispeed 700MHz at load 50%.
+ */
+
+ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/timer_rate",
+ "20000");
+ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/min_sample_time",
+ "60000");
+ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/hispeed_freq",
+ "700000");
+ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load",
+ "50");
+ sysfs_write("/sys/devices/system/cpu/cpufreq/interactive/above_hispeed_delay",
+ "100000");
+}
+
+static int boostpulse_open(struct piranha_power_module *piranha)
+{
+ char buf[80];
+
+ pthread_mutex_lock(&piranha->lock);
+
+ if (piranha->boostpulse_fd < 0) {
+ piranha->boostpulse_fd = open(BOOSTPULSE_PATH, O_WRONLY);
+
+ if (piranha->boostpulse_fd < 0) {
+ if (!piranha->boostpulse_warned) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error opening %s: %s\n", BOOSTPULSE_PATH, buf);
+ piranha->boostpulse_warned = 1;
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&piranha->lock);
+ return piranha->boostpulse_fd;
+}
+
+static void piranha_power_set_interactive(struct power_module *module, int on)
+{
+ /*
+ * Lower maximum frequency when screen is off. CPU 0 and 1 share a
+ * cpufreq policy.
+ */
+
+ sysfs_write("/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq",
+ on ? "1200000" : "700000");
+}
+
+static void piranha_power_hint(struct power_module *module, power_hint_t hint,
+ void *data)
+{
+ struct piranha_power_module *piranha = (struct piranha_power_module *) module;
+ char buf[80];
+ int len;
+
+ switch (hint) {
+ case POWER_HINT_INTERACTION:
+ if (boostpulse_open(piranha) >= 0) {
+ len = write(piranha->boostpulse_fd, "1", 1);
+
+ if (len < 0) {
+ strerror_r(errno, buf, sizeof(buf));
+ ALOGE("Error writing to %s: %s\n", BOOSTPULSE_PATH, buf);
+ }
+ }
+ break;
+
+ case POWER_HINT_VSYNC:
+ break;
+
+ default:
+ break;
+ }
+}
+
+static struct hw_module_methods_t power_module_methods = {
+ .open = NULL,
+};
+
+struct piranha_power_module HAL_MODULE_INFO_SYM = {
+ base: {
+ common: {
+ tag: HARDWARE_MODULE_TAG,
+ module_api_version: POWER_MODULE_API_VERSION_0_2,
+ hal_api_version: HARDWARE_HAL_API_VERSION,
+ id: POWER_HARDWARE_MODULE_ID,
+ name: "Piranha Power HAL",
+ author: "The Android Open Source Project",
+ methods: &power_module_methods,
+ },
+
+ init: piranha_power_init,
+ setInteractive: piranha_power_set_interactive,
+ powerHint: piranha_power_hint,
+ },
+
+ lock: PTHREAD_MUTEX_INITIALIZER,
+ boostpulse_fd: -1,
+ boostpulse_warned: 0,
+};