1 /* 2 * Copyright (C) 2024 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 <cstdint> 20 21 #include "AdpfTypes.h" 22 23 namespace aidl::google::hardware::power::impl::pixel { 24 25 class SessionChannel { 26 public: 27 SessionChannel(int32_t tgid, int32_t uid, int64_t id, int32_t offset); 28 void getDesc(ChannelQueueDesc *_return_desc); 29 bool isValid() const; 30 ChannelQueue *getQueue(); 31 int32_t getTgid() const; 32 int32_t getUid() const; 33 int64_t getId() const; 34 // write is the lowest 16 bits, read is the upper 16 bits 35 uint32_t getWriteBitmask() const; 36 uint32_t getReadBitmask() const; 37 38 private: 39 int32_t mTgid = -1; 40 int32_t mUid = -1; 41 // An ID starting from 0 increasing sequentially, representing 42 // location in the session array. If a channel dies, it isn't removed 43 // but killed, so that the order remains the same for everyone. It will 44 // be replaced when new sessions come along. The first 15 sessions 45 // all get unique sets of bits to communicate with their client, 46 // and 16+ have to share the last slot. It's worth considering making 47 // another thread if we go beyond 16. 48 const int64_t mId = -1; 49 const uint32_t mReadMask = 0; 50 const uint32_t mWriteMask = 0; 51 ChannelQueue mChannelQueue; 52 }; 53 54 } // namespace aidl::google::hardware::power::impl::pixel 55