universal7885: SamsungParts: add gpu, selinux and update related sepolicy

This commit is contained in:
roynatech2544 2021-10-25 00:04:38 +09:00
commit c1a9d9f071
No known key found for this signature in database
GPG key ID: 9675C32163D88D30
36 changed files with 632 additions and 170 deletions

View file

@ -0,0 +1,10 @@
hidl_interface {
name: "vendor.eureka.hardware.gpu@1.0",
root: "vendor.eureka",
srcs: [
"types.hal",
"IGpu.hal",
],
interfaces: [ "android.hidl.base@1.0" ],
gen_java: true,
}

View file

@ -0,0 +1,20 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.gpu@1.0;
interface IGpu {
setGpuWritable(Enable enable) generates (int32_t result);
readGpustats() generates (int32_t value);
};

View file

@ -0,0 +1,19 @@
// FIXME: your file license if you have one
cc_binary {
name: "vendor.eureka.hardware.gpu@1.0-service",
relative_install_path: "hw",
proprietary: true,
srcs: [
"Gpu.cpp",
"service.cpp",
],
shared_libs: [
"libhidlbase",
"libutils",
"liblog",
"vendor.eureka.hardware.gpu@1.0",
],
init_rc: [ "vendor.eureka.hardware.gpu@1.0-service.rc" ],
vintf_fragments: [ "vendor.eureka.hardware.gpu@1.0.xml" ],
}

View file

@ -0,0 +1,53 @@
// Copyright (C) 2021 Eureka Team
//
// 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 "Gpu.h"
#include <iostream>
#include <fstream>
#include <sstream>
namespace vendor::eureka::hardware::gpu::V1_0 {
Return<int32_t> Gpu::setGpuWritable(gpu::V1_0::Enable enable) {
std::ofstream file;
std::string writevalue;
if (enable == Enable::ENABLE){
writevalue = "1";
}else{
writevalue = "0";
}
file.open("/sys/devices/platform/11500000.mali/tmu");
file << writevalue;
file.close();
return 0;
}
Return<int32_t> Gpu::readGpustats(void) {
std::ifstream file;
std::string value;
int32_t intvalue;
file.open("/sys/devices/platform/11500000.mali/tmu");
if (file.is_open()) {
getline(file, value);
file.close();
std::stringstream val(value);
val >> intvalue;
return intvalue;
}
return -1;
}
IGpu *Gpu::getInstance(void){
return new Gpu();
}
} // namespace android::hardware::gpu::implementation

View file

@ -0,0 +1,39 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
#pragma once
#include <vendor/eureka/hardware/gpu/1.0/IGpu.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace vendor::eureka::hardware::gpu::V1_0 {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
struct Gpu : public IGpu {
// Methods from ::vendor::eureka::hardware::gpu::V1_0::IGpu follow.
Return<int32_t> setGpuWritable(Enable enable);
Return<int32_t> readGpustats(void);
// Methods from ::android::hidl::base::V1_0::IBase follow.
static IGpu* getInstance(void);
};
} // namespace android::hardware::gpu::implementation

View file

@ -0,0 +1,49 @@
// Copyright (C) 2021 Eureka Team
//
// 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 "vendor.eureka.hardware.gpu@1.0-service"
#include <vendor/eureka/hardware/gpu/1.0/IGpu.h>
#include <hidl/LegacySupport.h>
#include "Gpu.h"
using vendor::eureka::hardware::gpu::V1_0::IGpu;
using vendor::eureka::hardware::gpu::V1_0::Gpu;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::sp;
int main() {
int ret;
android::sp<IGpu> service = Gpu::getInstance();
configureRpcThreadpool(1, true /*callerWillJoin*/);
if (service != nullptr) {
ret = service->registerAsService();
if(ret != 0) {
ALOGE("Can't register instance of Gpu HAL, nullptr");
}else{
ALOGI("registered Gpu HAL");
}
} else {
ALOGE("Can't create instance of Gpu HAL, nullptr");
}
joinRpcThreadpool();
return -1; // should never get here
}

View file

@ -0,0 +1,5 @@
service vendor.gpu-hal /vendor/bin/hw/vendor.eureka.hardware.gpu@1.0-service
interface vendor.eureka.hardware.gpu@1.0::IGpu default
class hal
user root
group root

View file

@ -0,0 +1,11 @@
<manifest version="1.0" type="device" target-level="3">
<hal format="hidl">
<name>vendor.eureka.hardware.gpu</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IGpu</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View file

@ -0,0 +1,20 @@
// Copyright (C) 2021 Eureka Team
//
// 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.
package vendor.eureka.hardware.gpu@1.0;
enum Enable : int32_t {
ENABLE,
DISABLE,
};