treble backports...

This commit is contained in:
PythonLimited 2019-03-21 16:51:02 +01:00
parent 3876947d6b
commit a1666b1f7f
17 changed files with 663 additions and 94 deletions

View file

@ -1,3 +1,4 @@
subdirs = [
"sensors",
"light",
]

View file

@ -1,4 +1,2 @@
# Audio
AUDIO_FEATURE_ENABLED_LOW_LATENCY_CAPTURE := true
BOARD_USES_ALSA_AUDIO := true
BOARD_USES_GENERIC_AUDIO := true

31
light/Android.bp Normal file
View file

@ -0,0 +1,31 @@
// Copyright (C) 2018 The LineageOS 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.
cc_binary {
name: "android.hardware.light@2.0-service.s3ve3g",
relative_install_path: "hw",
init_rc: ["android.hardware.light@2.0-service.s3ve3g.rc"],
srcs: ["service.cpp", "Light.cpp"],
shared_libs: [
"libbase",
"libcutils",
"libhardware",
"libhidlbase",
"libhidltransport",
"libhwbinder",
"libutils",
"android.hardware.light@2.0",
],
proprietary: true,
}

251
light/Light.cpp Normal file
View file

@ -0,0 +1,251 @@
/*
* Copyright (C) 2018 The LineageOS 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.
*/
#define LOG_TAG "LightService"
#include "Light.h"
#include <android-base/logging.h>
#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif
#ifndef max
#define max(a,b) ((a)<(b)?(b):(a))
#endif
// Number of steps to use in the duty array
#define LED_DUTY_STEPS 60
// Brightness ramp up/down time for blinking
#define LED_RAMP_MS 500
namespace {
using android::hardware::light::V2_0::LightState;
static uint32_t rgbToBrightness(const LightState& state) {
uint32_t color = state.color & 0x00ffffff;
return ((77*((color>>16)&0x00ff))
+ (150*((color>>8)&0x00ff)) + (29*(color&0x00ff))) >> 8;
}
static bool isLit(const LightState& state) {
return (state.color & 0x00ffffff);
}
} // anonymous namespace
namespace android {
namespace hardware {
namespace light {
namespace V2_0 {
namespace implementation {
Light::Light(std::ofstream&& lcd_backlight, std::ofstream&& button_backlight0, std::ofstream&& button_backlight1,
std::ofstream&& red_led, std::ofstream&& green_led, std::ofstream&& blue_led,
std::ofstream&& red_blink, std::ofstream&& green_blink, std::ofstream&& blue_blink,
std::ofstream&& red_ramp_ms, std::ofstream&& green_ramp_ms, std::ofstream&& blue_ramp_ms,
std::ofstream&& red_duty_steps, std::ofstream&& green_duty_steps, std::ofstream&& blue_duty_steps)
: mLcdBacklight(std::move(lcd_backlight)),
mButtonBacklight0(std::move(button_backlight0)),
mButtonBacklight1(std::move(button_backlight1)),
mRedLed(std::move(red_led)),
mGreenLed(std::move(green_led)),
mBlueLed(std::move(blue_led)),
mRedBlink(std::move(red_blink)),
mGreenBlink(std::move(green_blink)),
mBlueBlink(std::move(blue_blink)),
mRedRampMs(std::move(red_ramp_ms)),
mGreenRampMs(std::move(green_ramp_ms)),
mBlueRampMs(std::move(blue_ramp_ms)),
mRedDutySteps(std::move(red_duty_steps)),
mGreenDutySteps(std::move(green_duty_steps)),
mBlueDutySteps(std::move(blue_duty_steps)) {
auto attnFn(std::bind(&Light::setAttentionLight, this, std::placeholders::_1));
auto backlightFn(std::bind(&Light::setLcdBacklight, this, std::placeholders::_1));
auto batteryFn(std::bind(&Light::setBatteryLight, this, std::placeholders::_1));
auto buttonsFn(std::bind(&Light::setButtonsBacklight, this, std::placeholders::_1));
auto notifFn(std::bind(&Light::setNotificationLight, this, std::placeholders::_1));
mLights.emplace(std::make_pair(Type::ATTENTION, attnFn));
mLights.emplace(std::make_pair(Type::BACKLIGHT, backlightFn));
mLights.emplace(std::make_pair(Type::BATTERY, batteryFn));
mLights.emplace(std::make_pair(Type::BUTTONS, buttonsFn));
mLights.emplace(std::make_pair(Type::NOTIFICATIONS, notifFn));
}
// Methods from ::android::hardware::light::V2_0::ILight follow.
Return<Status> Light::setLight(Type type, const LightState& state) {
auto it = mLights.find(type);
if (it == mLights.end()) {
return Status::LIGHT_NOT_SUPPORTED;
}
it->second(state);
return Status::SUCCESS;
}
Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
std::vector<Type> types;
for (auto const& light : mLights) {
types.push_back(light.first);
}
_hidl_cb(types);
return Void();
}
void Light::setAttentionLight(const LightState& state) {
std::lock_guard<std::mutex> lock(mLock);
mAttentionState = state;
setSpeakerBatteryLightLocked();
}
void Light::setLcdBacklight(const LightState& state) {
std::lock_guard<std::mutex> lock(mLock);
uint32_t brightness = rgbToBrightness(state);
mLcdBacklight << brightness << std::endl;
}
void Light::setButtonsBacklight(const LightState& state) {
std::lock_guard<std::mutex> lock(mLock);
uint32_t brightness = rgbToBrightness(state);
mButtonBacklight0 << brightness << std::endl;
mButtonBacklight1 << brightness << std::endl;
}
void Light::setBatteryLight(const LightState& state) {
std::lock_guard<std::mutex> lock(mLock);
mBatteryState = state;
setSpeakerBatteryLightLocked();
}
void Light::setNotificationLight(const LightState& state) {
std::lock_guard<std::mutex> lock(mLock);
uint32_t brightness;
uint32_t color;
uint32_t rgb[3];
mNotificationState = state;
// If a brightness has been applied by the user
brightness = (mNotificationState.color & 0xFF000000) >> 24;
if (brightness > 0 && brightness < 0xFF) {
// Retrieve each of the RGB colors
color = mNotificationState.color & 0x00FFFFFF;
rgb[0] = (color >> 16) & 0xFF;
rgb[1] = (color >> 8) & 0xFF;
rgb[2] = color & 0xFF;
// Apply the brightness level
if (rgb[0] > 0)
rgb[0] = (rgb[0] * brightness) / 0xFF;
if (rgb[1] > 0)
rgb[1] = (rgb[1] * brightness) / 0xFF;
if (rgb[2] > 0)
rgb[2] = (rgb[2] * brightness) / 0xFF;
// Update with the new color
mNotificationState.color = (rgb[0] << 16) + (rgb[1] << 8) + rgb[2];
}
setSpeakerBatteryLightLocked();
}
void Light::setSpeakerBatteryLightLocked() {
if (isLit(mNotificationState)) {
setSpeakerLightLocked(mNotificationState);
} else if (isLit(mAttentionState)) {
setSpeakerLightLocked(mAttentionState);
} else {
setSpeakerLightLocked(mBatteryState);
}
}
void Light::setSpeakerLightLocked(const LightState& state) {
int len;
int red, green, blue;
int onMS, offMS;
unsigned int colorRGB;
switch (state.flashMode) {
case Flash::TIMED:
onMS = state.flashOnMs;
offMS = state.flashOffMs;
break;
case Flash::NONE:
default:
onMS = 0;
offMS = 0;
break;
}
colorRGB = state.color;
red = (colorRGB >> 16) & 0xFF;
green = (colorRGB >> 8) & 0xFF;
blue = colorRGB & 0xFF;
mRedLed << red << std::endl;
mGreenLed << green << std::endl;
mBlueLed << blue << std::endl;
if (onMS > 0 && offMS > 0) {
char dutystr[(3+1)*LED_DUTY_STEPS+1];
char* p = dutystr;
int stepMS;
int n;
onMS = max(onMS, LED_RAMP_MS);
offMS = max(offMS, LED_RAMP_MS);
stepMS = (onMS+offMS)/LED_DUTY_STEPS;
p += sprintf(p, "0");
for (n = 1; n < (onMS/stepMS); ++n) {
p += sprintf(p, ",%d", min((100*n*stepMS)/LED_RAMP_MS, 100));
}
for (n = 0; n < LED_DUTY_STEPS-(onMS/stepMS); ++n) {
p += sprintf(p, ",%d", 100 - min((100*n*stepMS)/LED_RAMP_MS, 100));
}
p += sprintf(p, "\n");
if (red) {
mRedDutySteps << dutystr << std::endl;
mRedRampMs << stepMS << std::endl;
mRedBlink << 1 << std::endl;
}
if (green) {
mGreenDutySteps << dutystr << std::endl;
mGreenRampMs << stepMS << std::endl;
mGreenBlink << 1 << std::endl;
}
if (blue) {
mBlueDutySteps << dutystr << std::endl;
mBlueRampMs << stepMS << std::endl;
mBlueBlink << 1 << std::endl;
}
}
}
} // namespace implementation
} // namespace V2_0
} // namespace light
} // namespace hardware
} // namespace android

83
light/Light.h Normal file
View file

@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 The LineageOS 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.
*/
#ifndef ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
#define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
#include <android/hardware/light/2.0/ILight.h>
#include <hidl/Status.h>
#include <fstream>
#include <mutex>
#include <unordered_map>
namespace android {
namespace hardware {
namespace light {
namespace V2_0 {
namespace implementation {
struct Light : public ILight {
Light(std::ofstream&& lcd_backlight, std::ofstream&& button_backlight0, std::ofstream&& button_backlight1,
std::ofstream&& red_led, std::ofstream&& green_led, std::ofstream&& blue_led,
std::ofstream&& red_blink, std::ofstream&& green_blink, std::ofstream&& blue_blink,
std::ofstream&& red_ramp_ms, std::ofstream&& green_ramp_ms, std::ofstream&& blue_ramp_ms,
std::ofstream&& red_duty_steps, std::ofstream&& green_duty_steps, std::ofstream&& blue_duty_steps);
// Methods from ::android::hardware::light::V2_0::ILight follow.
Return<Status> setLight(Type type, const LightState& state) override;
Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
private:
void setAttentionLight(const LightState& state);
void setBatteryLight(const LightState& state);
void setButtonsBacklight(const LightState& state);
void setLcdBacklight(const LightState& state);
void setNotificationLight(const LightState& state);
void setSpeakerBatteryLightLocked();
void setSpeakerLightLocked(const LightState& state);
std::ofstream mLcdBacklight;
std::ofstream mButtonBacklight0;
std::ofstream mButtonBacklight1;
std::ofstream mRedLed;
std::ofstream mGreenLed;
std::ofstream mBlueLed;
std::ofstream mRedBlink;
std::ofstream mGreenBlink;
std::ofstream mBlueBlink;
std::ofstream mRedRampMs;
std::ofstream mGreenRampMs;
std::ofstream mBlueRampMs;
std::ofstream mRedDutySteps;
std::ofstream mGreenDutySteps;
std::ofstream mBlueDutySteps;
LightState mAttentionState;
LightState mBatteryState;
LightState mNotificationState;
std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
std::mutex mLock;
};
} // namespace implementation
} // namespace V2_0
} // namespace light
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H

View file

@ -0,0 +1,35 @@
on init
# LCD backlight
chown system system /sys/class/leds/lcd-backlight/brightness
# Button backlight
chown system system /sys/class/leds/button-backlight1/brightness
chown system system /sys/class/leds/button-backlight/brightness
# RGB lights
chown system system /sys/class/leds/red/brightness
chown system system /sys/class/leds/green/brightness
chown system system /sys/class/leds/blue/brightness
chown system system /sys/class/leds/red/blink
chown system system /sys/class/leds/green/blink
chown system system /sys/class/leds/blue/blink
chown system system /sys/class/leds/red/ramp_step_ms
chown system system /sys/class/leds/green/ramp_step_ms
chown system system /sys/class/leds/blue/ramp_step_ms
chown system system /sys/class/leds/red/duty_pcts
chown system system /sys/class/leds/green/duty_pcts
chown system system /sys/class/leds/blue/duty_pcts
chmod 0660 /sys/class/leds/red/ramp_step_ms
chmod 0660 /sys/class/leds/green/ramp_step_ms
chmod 0660 /sys/class/leds/blue/ramp_step_ms
chmod 0660 /sys/class/leds/red/duty_pcts
chmod 0660 /sys/class/leds/green/duty_pcts
chmod 0660 /sys/class/leds/blue/duty_pcts
service light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service.cancro
class hal
user system
group system

179
light/service.cpp Normal file
View file

@ -0,0 +1,179 @@
/*
* Copyright (C) 2018 The LineageOS 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.
*/
#define LOG_TAG "android.hardware.light@2.0-service.cancro"
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>
#include <utils/Errors.h>
#include "Light.h"
// libhwbinder:
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
// Generated HIDL files
using android::hardware::light::V2_0::ILight;
using android::hardware::light::V2_0::implementation::Light;
const static std::string kLcdBacklightPath = "/sys/class/leds/lcd-backlight/brightness";
const static std::string kButtonBacklight0Path = "/sys/class/leds/button-backlight/brightness";
const static std::string kButtonBacklight1Path = "/sys/class/leds/button-backlight1/brightness";
const static std::string kRedLedPath = "/sys/class/leds/red/brightness";
const static std::string kGreenLedPath = "/sys/class/leds/green/brightness";
const static std::string kBlueLedPath = "/sys/class/leds/blue/brightness";
const static std::string kRedBlinkPath = "/sys/class/leds/red/blink";
const static std::string kGreenBlinkPath = "/sys/class/leds/green/blink";
const static std::string kBlueBlinkPath = "/sys/class/leds/blue/blink";
const static std::string kRedLedTimePath = "/sys/class/leds/red/led_time";
const static std::string kGreenLedTimePath = "/sys/class/leds/green/led_time";
const static std::string kBlueLedTimePath = "/sys/class/leds/blue/led_time";
const static std::string kRedRampMsPath = "/sys/class/leds/red/ramp_step_ms";
const static std::string kGreenRampMsPath = "/sys/class/leds/green/ramp_step_ms";
const static std::string kBlueRampMsPath = "/sys/class/leds/blue/ramp_step_ms";
const static std::string kRedDutyStepsPath = "/sys/class/leds/red/duty_pcts";
const static std::string kGreenDutyStepsPath = "/sys/class/leds/green/duty_pcts";
const static std::string kBlueDutyStepsPath = "/sys/class/leds/blue/duty_pcts";
int main() {
uint32_t lcdMaxBrightness = 255;
std::ofstream lcdBacklight(kLcdBacklightPath);
if (!lcdBacklight) {
LOG(ERROR) << "Failed to open " << kLcdBacklightPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream buttonBacklight0(kButtonBacklight0Path);
if (!buttonBacklight0) {
LOG(WARNING) << "Failed to open " << kButtonBacklight0Path << ", error=" << errno
<< " (" << strerror(errno) << ")";
}
std::ofstream buttonBacklight1(kButtonBacklight1Path);
if (!buttonBacklight1) {
LOG(WARNING) << "Failed to open " << kButtonBacklight1Path << ", error=" << errno
<< " (" << strerror(errno) << ")";
}
std::ofstream redLed(kRedLedPath);
if (!redLed) {
LOG(ERROR) << "Failed to open " << kRedLedPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream greenLed(kGreenLedPath);
if (!greenLed) {
LOG(ERROR) << "Failed to open " << kGreenLedPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream blueLed(kBlueLedPath);
if (!blueLed) {
LOG(ERROR) << "Failed to open " << kBlueLedPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream redBlink(kRedBlinkPath);
if (!redBlink) {
LOG(ERROR) << "Failed to open " << kRedBlinkPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream greenBlink(kGreenBlinkPath);
if (!greenBlink) {
LOG(ERROR) << "Failed to open " << kGreenBlinkPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream blueBlink(kBlueBlinkPath);
if (!blueBlink) {
LOG(ERROR) << "Failed to open " << kBlueBlinkPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream redRampMs(kRedRampMsPath);
if (!redRampMs) {
LOG(ERROR) << "Failed to open " << kRedRampMsPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream greenRampMs(kGreenRampMsPath);
if (!greenRampMs) {
LOG(ERROR) << "Failed to open " << kGreenRampMsPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream blueRampMs(kBlueRampMsPath);
if (!blueRampMs) {
LOG(ERROR) << "Failed to open " << kBlueRampMsPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream redDutySteps(kRedDutyStepsPath);
if (!redDutySteps) {
LOG(ERROR) << "Failed to open " << kRedDutyStepsPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream blueDutySteps(kBlueDutyStepsPath);
if (!blueDutySteps) {
LOG(ERROR) << "Failed to open " << kBlueDutyStepsPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
std::ofstream greenDutySteps(kGreenDutyStepsPath);
if (!greenDutySteps) {
LOG(ERROR) << "Failed to open " << kGreenDutyStepsPath << ", error=" << errno
<< " (" << strerror(errno) << ")";
return -errno;
}
android::sp<ILight> service = new Light(
std::move(lcdBacklight), std::move(buttonBacklight0), std::move(buttonBacklight1),
std::move(redLed), std::move(greenLed), std::move(blueLed),
std::move(redBlink), std::move(greenBlink), std::move(blueBlink),
std::move(redRampMs), std::move(greenRampMs), std::move(blueRampMs),
std::move(redDutySteps), std::move(greenDutySteps), std::move(blueDutySteps));
configureRpcThreadpool(1, true);
android::status_t status = service->registerAsService();
if (status != android::OK) {
LOG(ERROR) << "Cannot register Light HAL service";
return 1;
}
LOG(INFO) << "Light HAL Ready.";
joinRpcThreadpool();
// Under normal cases, execution will not reach this line.
LOG(ERROR) << "Light HAL failed to join thread pool.";
return 1;
}

View file

@ -201,7 +201,9 @@ PRODUCT_PACKAGES += \
# Power HAL
PRODUCT_PACKAGES += \
android.hardware.power@1.0-service-qti
android.hardware.power@1.0-impl \
android.hardware.power@1.0-service \
power.msm8226
# Radio
PRODUCT_PACKAGES += \

View file

@ -1,5 +1,5 @@
#
# Copyright 2019 The LineageOS Project
# Copyright 2016 The CyanogenMod Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -18,7 +18,7 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(TARGET_POWERHAL_HEADER_PATH)
LOCAL_SRC_FILES := power.c
LOCAL_SHARED_LIBRARIES := liblog libcutils
LOCAL_SHARED_LIBRARIES := liblog libcutils libhardware
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := power.msm8226

View file

@ -23,7 +23,8 @@
#include <string.h>
#include <stdlib.h>
#include <utils/Log.h>
#include <log/log.h>
#include <pthread.h>
#include "power.h"
@ -38,7 +39,8 @@
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static int boostpulse_fd = -1;
static int current_power_profile = -1;
// Balanced profile by default
static int current_power_profile = 1;
static int requested_power_profile = -1;
static int sysfs_write_str(char *path, char *s)
@ -103,68 +105,16 @@ static void power_set_interactive_ext(int on) {
static void power_set_interactive(__attribute__((unused)) struct power_module *module, int on)
{
if (!is_profile_valid(current_power_profile)) {
ALOGD("%s: no power profile selected yet", __func__);
return;
}
/* We want to first set the input device state otherwise
* it never gets turned off/on when our HAL isnt compatible with the power_profiles from
* our framework
*/
power_set_interactive_ext(on);
if (on) {
sysfs_write_int(INTERACTIVE_PATH "hispeed_freq",
profiles[current_power_profile].hispeed_freq);
sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
profiles[current_power_profile].go_hispeed_load);
sysfs_write_int(INTERACTIVE_PATH "target_loads",
profiles[current_power_profile].target_loads);
sysfs_write_int(CPUFREQ_PATH "scaling_min_freq",
profiles[current_power_profile].scaling_min_freq);
} else {
sysfs_write_int(INTERACTIVE_PATH "hispeed_freq",
profiles[current_power_profile].hispeed_freq_off);
sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
profiles[current_power_profile].go_hispeed_load_off);
sysfs_write_int(INTERACTIVE_PATH "target_loads",
profiles[current_power_profile].target_loads_off);
sysfs_write_int(CPUFREQ_PATH "scaling_min_freq",
profiles[current_power_profile].scaling_min_freq_off);
}
}
static void set_power_profile(int profile)
static void set_power_profile(__attribute__((unused)) int profile)
{
if (!is_profile_valid(profile)) {
ALOGE("%s: unknown profile: %d", __func__, profile);
return;
}
if (profile == current_power_profile)
return;
ALOGD("%s: setting profile %d", __func__, profile);
sysfs_write_int(INTERACTIVE_PATH "boost",
profiles[profile].boost);
sysfs_write_int(INTERACTIVE_PATH "boostpulse_duration",
profiles[profile].boostpulse_duration);
sysfs_write_int(INTERACTIVE_PATH "go_hispeed_load",
profiles[profile].go_hispeed_load);
sysfs_write_int(INTERACTIVE_PATH "hispeed_freq",
profiles[profile].hispeed_freq);
sysfs_write_int(INTERACTIVE_PATH "min_sample_time",
profiles[profile].min_sample_time);
sysfs_write_int(INTERACTIVE_PATH "timer_rate",
profiles[profile].timer_rate);
sysfs_write_int(INTERACTIVE_PATH "above_hispeed_delay",
profiles[profile].above_hispeed_delay);
sysfs_write_int(INTERACTIVE_PATH "target_loads",
profiles[profile].target_loads);
sysfs_write_int(CPUFREQ_PATH "scaling_max_freq",
profiles[profile].scaling_max_freq);
sysfs_write_int(CPUFREQ_PATH "scaling_min_freq",
profiles[profile].scaling_min_freq);
current_power_profile = profile;
return;
}
static void power_hint(__attribute__((unused)) struct power_module *module,
@ -175,28 +125,6 @@ static void power_hint(__attribute__((unused)) struct power_module *module,
switch (hint) {
case POWER_HINT_INTERACTION:
if (!is_profile_valid(current_power_profile)) {
ALOGD("%s: no power profile selected yet", __func__);
return;
}
if (!profiles[current_power_profile].boostpulse_duration)
return;
if (boostpulse_open() >= 0) {
snprintf(buf, sizeof(buf), "%d", 1);
len = write(boostpulse_fd, &buf, sizeof(buf));
if (len < 0) {
strerror_r(errno, buf, sizeof(buf));
ALOGE("Error writing to boostpulse: %s\n", buf);
pthread_mutex_lock(&lock);
close(boostpulse_fd);
boostpulse_fd = -1;
pthread_mutex_unlock(&lock);
}
}
break;
case POWER_HINT_SET_PROFILE:
pthread_mutex_lock(&lock);
set_power_profile(*(int32_t *)data);
@ -262,7 +190,7 @@ struct power_module HAL_MODULE_INFO_SYM = {
.module_api_version = POWER_MODULE_API_VERSION_0_2,
.hal_api_version = HARDWARE_HAL_API_VERSION,
.id = POWER_HARDWARE_MODULE_ID,
.name = "msm8226 Power HAL",
.name = "MSM8226 Power HAL",
.author = "The LineageOS Project",
.methods = &power_module_methods,
},
@ -272,4 +200,3 @@ struct power_module HAL_MODULE_INFO_SYM = {
.powerHint = power_hint,
.getFeature = get_feature
};

View file

@ -70,7 +70,8 @@ static power_profile profiles[PROFILE_MAX] = {
.target_loads = 80,
.target_loads_off = 90,
.scaling_max_freq = 1401600,
.scaling_min_freq = 787200,
// Our scaling_min_freq shouldnt be above our minimum any time!
.scaling_min_freq = 384000,
.scaling_min_freq_off = 300000,
},
[PROFILE_HIGH_PERFORMANCE] = {

View file

@ -34,9 +34,33 @@ LOCAL_SHARED_LIBRARIES := \
libdl \
liblog \
libutils \
libhardware
LOCAL_STRIP_MODULE := false
LOCAL_VENDOR_MODULE := true
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_PROPRIETARY_MODULE := true
LOCAL_MODULE := android.hardware.sensors@1.0-service.s3ve3g
LOCAL_INIT_RC := android.hardware.sensors@1.0-service.s3ve3g.rc
LOCAL_SRC_FILES := \
service.cpp
LOCAL_SHARED_LIBRARIES := \
liblog \
libcutils \
libdl \
libbase \
libutils
LOCAL_SHARED_LIBRARIES += \
libhidlbase \
libhidltransport \
android.hardware.sensors@1.0
include $(BUILD_EXECUTABLE)
include $(call all-makefiles-under, $(LOCAL_PATH))

View file

@ -17,7 +17,7 @@
#include <hardware/sensors.h>
#include <algorithm>
#include <pthread.h>
#include <cutils/log.h>
#include <log/log.h>
#include "SensorEventQueue.h"

View file

@ -0,0 +1,5 @@
service sensors-hal-1-0 /vendor/bin/hw/android.hardware.sensors@1.0-service.s3ve3g
class hal
user root
group system input wakelock
capabilities BLOCK_SUSPEND SYS_NICE

View file

@ -18,7 +18,7 @@
#include "multihal.h"
#define LOG_NDEBUG 1
#include <cutils/log.h>
#include <log/log.h>
#include <cutils/atomic.h>
#include <hardware/sensors.h>

31
sensors/service.cpp Normal file
View file

@ -0,0 +1,31 @@
/*
* Copyright (C) 2016 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.
*/
#define LOG_TAG "android.hardware.sensors@1.0-service.wt88047"
#include <android/hardware/sensors/1.0/ISensors.h>
#include <hidl/LegacySupport.h>
using android::hardware::sensors::V1_0::ISensors;
using android::hardware::defaultPassthroughServiceImplementation;
int main() {
/* Sensors framework service needs at least two threads.
* One thread blocks on a "poll"
* The second thread is needed for all other HAL methods.
*/
return defaultPassthroughServiceImplementation<ISensors>(2);
}

View file

@ -53,8 +53,9 @@ ro.qualcomm.cabl=0
ro.sf.lcd_density=320
debug.hwui.use_buffer_age=false
# Android GO
ro.config.low_ram=true
# Memory optimizations
ro.vendor.qti.sys.fw.bservice_enable=true
ro.vendor.qti.am.reschedule_service=true
# GPS
persist.gps.qc_nlp_in_use=1