Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the app and process name #150

Open
wants to merge 1 commit into
base: celadon/u/mr0/master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 34 additions & 15 deletions src/intel/common/intel_check.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <cutils/log.h>
#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
Expand All @@ -7,6 +8,7 @@
#include <sys/types.h>
#include <sys/syscall.h>
#include <stdbool.h>
#include <string.h>
#include <cutils/properties.h>
#include "util/macros.h"
#include "util/log.h"
Expand All @@ -26,35 +28,48 @@ get_pid_name(pid_t pid, char *task_name)
char process_path[BUF_SIZE];
char name_buf[BUF_SIZE];

sprintf(process_path, "/proc/%d/status", pid);
snprintf(process_path, sizeof(process_path), "/proc/%d/status", pid);
FILE* fp = fopen(process_path, "r");
if(NULL != fp){
if( fgets(name_buf, BUF_SIZE-1, fp)== NULL ){
fclose(fp);
}
if (fp == NULL) {
mesa_loge("failed to open %s\n", process_path);
return;
}
if( fgets(name_buf, BUF_SIZE-1, fp)== NULL ){
mesa_loge("get pid name fail\n");
fclose(fp);
sscanf(name_buf, "%*s %s", task_name);
return;
}
fclose(fp);
sscanf(name_buf, "%*s %s", task_name);
}

static bool
use_dgpu_render(char *target)
{
char dGPU_prop[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(dGPU_prop, "persist.vendor.intel.dGPU.%s", target);
snprintf(dGPU_prop, sizeof(dGPU_prop), "persist.vendor.intel.dGPUwSys.%s", target);
if (property_get(dGPU_prop, vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
}
}
char dGPU_prop1[BUF_SIZE];
char vendor_buf1[PROPERTY_VALUE_MAX];
snprintf(dGPU_prop1, sizeof(dGPU_prop1), "persist.vendor.intel.dGPUwLocal%s", target);
   if (property_get(dGPU_prop1, vendor_buf1, NULL) > 0) {
      if (vendor_buf1[0] == '1') {
         return true;
}
}

return false;
}

static bool
is_target_process(const char *target)
{
static const char *str_char[] = { "k.lite:refinery", "k.lite:transfer", NULL };
static const char *str_char[] = { "k.auto:transfer", "android.vending", "k.auto:refinery", ".fisheye", "mark.auto:video", NULL };
const char **ptr = str_char;

// Prefer dGPU for compositing in surfaceflinger since dGPU covers more
Expand All @@ -65,9 +80,12 @@ is_target_process(const char *target)
for (ptr = str_char; *ptr != NULL; ptr++) {
if (!strcmp(target, *ptr)) {
char vendor_buf[PROPERTY_VALUE_MAX];
if (property_get("persist.vendor.intel.dGPU.ABenchMark.lite",
vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
char vendor_buf1[PROPERTY_VALUE_MAX];
if ((property_get("persist.vendor.intel.dGPUwSys.benchmark.auto",
vendor_buf, NULL) > 0) ||
(property_get("persist.vendor.intel.dGPUwLocal.auto",
vendor_buf1, NULL) > 0)) {
if ((vendor_buf[0] == '1') || (vendor_buf1[0] == '1')) {
return true;
}
}
Expand All @@ -79,21 +97,22 @@ is_target_process(const char *target)
bool intel_is_dgpu_render(void)
{
pid_t process_id = getpid();
char process_name[BUF_SIZE];
char process_name[BUF_SIZE] = {0};

get_pid_name(process_id, process_name);
return (use_dgpu_render(process_name) || is_target_process(process_name));
char *app_name = strrchr(process_name, '.');
return (use_dgpu_render(process_name) || is_target_process(process_name) || use_dgpu_render(app_name));
}

bool intel_lower_ctx_priority(void)
{
pid_t process_id = getpid();
char process_name[BUF_SIZE];
char process_name[BUF_SIZE] = {0};
get_pid_name(process_id, process_name);

char lower_pri[BUF_SIZE];
char vendor_buf[PROPERTY_VALUE_MAX];
sprintf(lower_pri, "persist.vendor.intel.lowPir.%s",process_name);
snprintf(lower_pri, sizeof(lower_pri), "persist.vendor.intel.lowPir.%s", process_name);
if (property_get(lower_pri, vendor_buf, NULL) > 0) {
if (vendor_buf[0] == '1') {
return true;
Expand Down
Loading