sm8250-common: power: Rebase on LA.UM.8.12.r1-11900-sm8250.0

This commit is contained in:
LuK1337
2020-06-23 14:43:35 +02:00
parent 54b02a5e52
commit e032e7cc78
24 changed files with 800 additions and 1050 deletions

View File

@@ -26,18 +26,18 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#define LOG_TAG "QCOM PowerHAL"
#include "powerhintparser.h"
#include <cutils/log.h>
#include <cutils/properties.h>
#include <fcntl.h>
#include <string.h>
#include <cutils/properties.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string.h>
#include <unistd.h>
#include "powerhintparser.h"
#define LOG_TAG "QTI PowerHAL"
int parsePowerhintXML() {
xmlDocPtr doc;
xmlNodePtr currNode;
const char *opcode_str, *value_str, *type_str;
@@ -45,18 +45,18 @@ int parsePowerhintXML() {
int numParams = 0;
static int hintCount;
if (access(POWERHINT_XML, F_OK) < 0) {
if(access(POWERHINT_XML, F_OK) < 0) {
return -1;
}
doc = xmlReadFile(POWERHINT_XML, "UTF-8", XML_PARSE_RECOVER);
if (!doc) {
if(!doc) {
ALOGE("Document not parsed successfully");
return -1;
}
currNode = xmlDocGetRootElement(doc);
if (!currNode) {
if(!currNode) {
ALOGE("Empty document");
xmlFreeDoc(doc);
xmlCleanupParser();
@@ -64,7 +64,7 @@ int parsePowerhintXML() {
}
// Confirm the root-element of the tree
if (xmlStrcmp(currNode->name, BAD_CAST "Powerhint")) {
if(xmlStrcmp(currNode->name, BAD_CAST "Powerhint")) {
ALOGE("document of the wrong type, root node != root");
xmlFreeDoc(doc);
xmlCleanupParser();
@@ -73,34 +73,39 @@ int parsePowerhintXML() {
currNode = currNode->xmlChildrenNode;
for (; currNode != NULL; currNode = currNode->next) {
if (currNode->type != XML_ELEMENT_NODE) continue;
for(; currNode != NULL; currNode=currNode->next) {
if(currNode->type != XML_ELEMENT_NODE)
continue;
xmlNodePtr node = currNode;
if (hintCount == MAX_HINT) {
ALOGE("Number of hints exceeded the max count of %d\n", MAX_HINT);
if(hintCount == MAX_HINT) {
ALOGE("Number of hints exceeded the max count of %d\n",MAX_HINT);
break;
}
if (!xmlStrcmp(node->name, BAD_CAST "Hint")) {
if (xmlHasProp(node, BAD_CAST "type")) {
type_str = (const char*)xmlGetProp(node, BAD_CAST "type");
if (type_str == NULL) {
ALOGE("xmlGetProp failed on type");
xmlFreeDoc(doc);
xmlCleanupParser();
return -1;
}
type = strtol(type_str, NULL, 16);
if(!xmlStrcmp(node->name, BAD_CAST "Hint")) {
if(xmlHasProp(node, BAD_CAST "type")) {
type_str = (const char*)xmlGetProp(node, BAD_CAST "type");
if (type_str == NULL)
{
ALOGE("xmlGetProp failed on type");
xmlFreeDoc(doc);
xmlCleanupParser();
return -1;
}
type = strtol(type_str, NULL, 16);
}
node = node->children;
while (node != NULL) {
if (!xmlStrcmp(node->name, BAD_CAST "Resource")) {
if (xmlHasProp(node, BAD_CAST "opcode")) {
opcode_str = (const char*)xmlGetProp(node, BAD_CAST "opcode");
if (opcode_str == NULL) {
while(node != NULL) {
if(!xmlStrcmp(node->name, BAD_CAST "Resource")) {
if(xmlHasProp(node, BAD_CAST "opcode")) {
opcode_str = (const char*)xmlGetProp(node, BAD_CAST "opcode");
if (opcode_str == NULL)
{
ALOGE("xmlGetProp failed on opcode");
xmlFreeDoc(doc);
xmlCleanupParser();
@@ -108,9 +113,10 @@ int parsePowerhintXML() {
}
opcode = strtol(opcode_str, NULL, 16);
}
if (xmlHasProp(node, BAD_CAST "value")) {
if(xmlHasProp(node, BAD_CAST "value")) {
value_str = (const char*)xmlGetProp(node, BAD_CAST "value");
if (value_str == NULL) {
if (value_str == NULL)
{
ALOGE("xmlGetProp failed on value");
xmlFreeDoc(doc);
xmlCleanupParser();
@@ -118,12 +124,12 @@ int parsePowerhintXML() {
}
value = strtol(value_str, NULL, 16);
}
if (opcode > 0) {
if (numParams < (MAX_PARAM - 1)) {
if(opcode > 0) {
if(numParams < (MAX_PARAM-1)) {
powerhint[hintCount].paramList[numParams++] = opcode;
powerhint[hintCount].paramList[numParams++] = value;
} else {
ALOGE("Maximum parameters exceeded for Hint ID %x\n", type);
ALOGE("Maximum parameters exceeded for Hint ID %x\n",type);
opcode = value = 0;
break;
}
@@ -145,27 +151,29 @@ int parsePowerhintXML() {
return 0;
}
int* getPowerhint(int hint_id, int* params) {
int* result = NULL;
int* getPowerhint(int hint_id, int *params) {
if (!hint_id) return result;
int *result = NULL;
ALOGI("Powerhal hint received=%x\n", hint_id);
if(!hint_id)
return result;
if (!powerhint[0].numParams) {
parsePowerhintXML();
ALOGI("Powerhal hint received=%x\n",hint_id);
if(!powerhint[0].numParams) {
parsePowerhintXML();
}
for (int i = 0; i < MAX_HINT; i++) {
if (hint_id == powerhint[i].type) {
*params = powerhint[i].numParams;
result = powerhint[i].paramList;
break;
}
for(int i = 0; i < MAX_HINT; i++) {
if(hint_id == powerhint[i].type) {
*params = powerhint[i].numParams;
result = powerhint[i].paramList;
break;
}
}
/*for (int j = 0; j < *params; j++)
ALOGI("Powerhal resource again%x = \n", result[j]);*/
return result;
return result;
}