• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #ifndef ANDROID_HARDWARE_POWERSTATS_RAILDATAPROVIDER_H
3 #define ANDROID_HARDWARE_POWERSTATS_RAILDATAPROVIDER_H
4 #include <fmq/MessageQueue.h>
5 #include <pixelpowerstats/PowerStats.h>
6 namespace android {
7 namespace hardware {
8 namespace google {
9 namespace pixel {
10 namespace powerstats {
11 typedef MessageQueue<EnergyData, kSynchronizedReadWrite> MessageQueueSync;
12 struct RailData {
13     std::string devicePath;
14     uint32_t index;
15     std::string subsysName;
16     uint32_t samplingRate;
17 };
18 struct OnDeviceMmt {
19     std::mutex mLock;
20     bool hwEnabled;
21     std::vector<std::string> devicePaths;
22     std::map<std::string, RailData> railsInfo;
23     std::vector<EnergyData> reading;
24     std::unique_ptr<MessageQueueSync> fmqSynchronized;
25 };
26 class RailDataProvider : public IRailDataProvider {
27 public:
28     RailDataProvider();
29     // Methods from ::android::hardware::power::stats::V1_0::IPowerStats follow.
30     Return<void> getRailInfo(IPowerStats::getRailInfo_cb _hidl_cb) override;
31     Return<void> getEnergyData(const hidl_vec<uint32_t>& railIndices,
32                         IPowerStats::getEnergyData_cb _hidl_cb) override;
33     Return<void> streamEnergyData(uint32_t timeMs, uint32_t samplingRate,
34                         IPowerStats::streamEnergyData_cb _hidl_cb) override;
35  private:
36      OnDeviceMmt mOdpm;
37      void findIioPowerMonitorNodes();
38      size_t parsePowerRails();
39      int parseIioEnergyNode(std::string devName);
40      Status parseIioEnergyNodes();
41 };
42 }  // namespace powerstats
43 }  // namespace pixel
44 }  // namespace google
45 }  // namespace hardware
46 }  // namespace android
47 #endif  // ANDROID_HARDWARE_POWERSTATS_RAILDATAPROVIDER_H
48