Created
January 27, 2021 21:05
-
-
Save MagneFire/9961d7b2bc33ed48f0fe0da3c31838fc to your computer and use it in GitHub Desktop.
PowerHAL testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. /usr/local/oecore-x86_64/environment-setup-armv7vehf-neon-oe-linux-gnueabi | |
arm-oe-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard --sysroot=/usr/local/oecore-x86_64/sysroots/armv7vehf-neon-oe-linux-gnueabi -I<LOCATION TO ANDROID HEADERS> -o powerhal-test powerhal-test.c -lhardware |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <stdio.h> | |
#include <hardware/hardware.h> | |
#include <hardware/hwcomposer.h> | |
#include <hardware/power.h> | |
int main(int argc, char* argv[]) { | |
hw_module_t *hwc_module = NULL; | |
hw_device_t *hwc_dev = NULL; | |
hwc_composer_device_1_t *hwc_device = NULL; | |
// Open hardware composer | |
hw_get_module(HWC_HARDWARE_MODULE_ID, (const hw_module_t **)(&hwc_module)); | |
fprintf(stderr, "== hwcomposer module ==\n"); | |
fprintf(stderr, " * Address: %p\n", hwc_module); | |
fprintf(stderr, " * Module API Version: %x\n", hwc_module->module_api_version); | |
fprintf(stderr, " * HAL API Version: %x\n", hwc_module->hal_api_version); /* should be zero */ | |
fprintf(stderr, " * Identifier: %s\n", hwc_module->id); | |
fprintf(stderr, " * Name: %s\n", hwc_module->name); | |
fprintf(stderr, " * Author: %s\n", hwc_module->author); | |
fprintf(stderr, "== hwcomposer module ==\n"); | |
// Open hardware composer device | |
hwc_module->methods->open(hwc_module, HWC_HARDWARE_COMPOSER, &hwc_dev); | |
fprintf(stderr, "== hwcomposer device ==\n"); | |
fprintf(stderr, " * Version: %x (interpreted as %x)\n", hwc_dev->version, 42); | |
fprintf(stderr, " * Module: %p\n", hwc_dev->module); | |
fprintf(stderr, "== hwcomposer device ==\n"); | |
hwc_device = (hwc_composer_device_1_t*)hwc_dev; | |
power_module_t *pwr_module = NULL; | |
// Open power module for setting interactive state based on screen on/off. | |
if (!hw_get_module(POWER_HARDWARE_MODULE_ID, (const hw_module_t **)(&pwr_module))) { | |
pwr_module->init(pwr_module); | |
fprintf(stderr, "== power module ==\n"); | |
fprintf(stderr, " * Address: %p\n", pwr_module); | |
fprintf(stderr, " * Module API Version: %x\n", pwr_module->common.module_api_version); | |
fprintf(stderr, " * HAL API Version: %x\n", pwr_module->common.hal_api_version); /* should be zero */ | |
fprintf(stderr, " * Identifier: %s\n", pwr_module->common.id); | |
fprintf(stderr, " * Name: %s\n", pwr_module->common.name); | |
fprintf(stderr, " * Author: %s\n", pwr_module->common.author); | |
fprintf(stderr, "== power module ==\n"); | |
} else { | |
fprintf(stderr, "PowerHAL is missing or not working, display doze mode may not work\n"); | |
} | |
//autosuspend_disable(); | |
//pwr_module->setInteractive(pwr_module, 1); | |
//pwr_module->setFeature(pwr_module, 1, 0); | |
//pwr_module->powerHint(pwr_module, 2, NULL); // same as below | |
pwr_module->powerHint(pwr_module, POWER_HINT_INTERACTION, NULL); | |
//pwr_module->powerHint(pwr_module, 5, (void*)1); | |
pwr_module->setInteractive(pwr_module, 0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment