1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <vector> 20 21 #include <binder/IInterface.h> 22 #include <cutils/compiler.h> 23 #include <graphicsenv/GpuStatsInfo.h> 24 #include <graphicsenv/GraphicsEnv.h> 25 26 namespace android { 27 28 /* 29 * This class defines the Binder IPC interface for GPU-related queries and 30 * control. 31 */ 32 class IGpuService : public IInterface { 33 public: 34 DECLARE_META_INTERFACE(GpuService) 35 36 // set GPU stats from GraphicsEnvironment. 37 virtual void setGpuStats(const std::string& driverPackageName, 38 const std::string& driverVersionName, uint64_t driverVersionCode, 39 int64_t driverBuildTime, const std::string& appPackageName, 40 const int32_t vulkanVersion, GraphicsEnv::Driver driver, 41 bool isDriverLoaded, int64_t driverLoadingTime) = 0; 42 43 // set target stats. 44 virtual void setTargetStats(const std::string& appPackageName, const uint64_t driverVersionCode, 45 const GraphicsEnv::Stats stats, const uint64_t value = 0) = 0; 46 47 // get GPU global stats from GpuStats module. 48 virtual status_t getGpuStatsGlobalInfo(std::vector<GpuStatsGlobalInfo>* outStats) const = 0; 49 50 // get GPU app stats from GpuStats module. 51 virtual status_t getGpuStatsAppInfo(std::vector<GpuStatsAppInfo>* outStats) const = 0; 52 }; 53 54 class BnGpuService : public BnInterface<IGpuService> { 55 public: 56 enum IGpuServiceTag { 57 SET_GPU_STATS = IBinder::FIRST_CALL_TRANSACTION, 58 GET_GPU_STATS_GLOBAL_INFO, 59 GET_GPU_STATS_APP_INFO, 60 SET_TARGET_STATS, 61 // Always append new enum to the end. 62 }; 63 64 status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, 65 uint32_t flags = 0) override; 66 67 protected: 68 virtual status_t shellCommand(int in, int out, int err, std::vector<String16>& args) = 0; 69 }; 70 71 } // namespace android 72