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 #include "SessionChannel.h"
18 
19 #include "AdpfTypes.h"
20 
21 namespace aidl::google::hardware::power::impl::pixel {
22 
SessionChannel(int32_t tgid,int32_t uid,int64_t id,int32_t offset)23 SessionChannel::SessionChannel(int32_t tgid, int32_t uid, int64_t id, int32_t offset)
24     : mTgid(tgid),
25       mUid(uid),
26       mId(id),
27       mReadMask(1u << (offset + 16)),
28       mWriteMask(1u << offset),
29       mChannelQueue(kFMQQueueSize, true) {}
30 
getDesc(ChannelQueueDesc * _return_desc)31 void SessionChannel::getDesc(ChannelQueueDesc *_return_desc) {
32     *_return_desc = mChannelQueue.dupeDesc();
33 }
34 
isValid() const35 bool SessionChannel::isValid() const {
36     return mChannelQueue.isValid();
37 }
38 
getQueue()39 ChannelQueue *SessionChannel::getQueue() {
40     return &mChannelQueue;
41 }
42 
getTgid() const43 int32_t SessionChannel::getTgid() const {
44     return mTgid;
45 }
46 
getUid() const47 int32_t SessionChannel::getUid() const {
48     return mUid;
49 }
50 
getId() const51 int64_t SessionChannel::getId() const {
52     return mId;
53 }
54 
getReadBitmask() const55 uint32_t SessionChannel::getReadBitmask() const {
56     return mReadMask;
57 }
58 
getWriteBitmask() const59 uint32_t SessionChannel::getWriteBitmask() const {
60     return mWriteMask;
61 }
62 
63 }  // namespace aidl::google::hardware::power::impl::pixel
64