1 /* 2 * Copyright Samsung Electronics Co.,LTD. 3 * Copyright (C) 2017 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef __HARDWARE_EXYNOS_ACRYLIC_DEVICE_H__ 19 #define __HARDWARE_EXYNOS_ACRYLIC_DEVICE_H__ 20 21 #include <string> 22 23 class AcrylicDevice { 24 public: 25 AcrylicDevice(const char *path); 26 virtual ~AcrylicDevice(); 27 int ioctl(int cmd, void *arg); 28 private: 29 bool open(); 30 31 std::string mDevPath; 32 int mDevFD; 33 }; 34 35 #define MAX_DEVICE_FD 3 36 class AcrylicRedundantDevice { 37 public: 38 AcrylicRedundantDevice(const char *path); 39 ~AcrylicRedundantDevice(); 40 int ioctl_unique(int cmd, void *arg); 41 int ioctl_current(int cmd, void *arg); 42 int ioctl_broadcast(int cmd, void *arg); ioctl_single(int cmd,void * arg)43 int ioctl_single(int cmd, void *arg) { 44 int ret = ioctl_current(cmd, arg); 45 46 mFdIdx++; 47 mFdIdx = mFdIdx % MAX_DEVICE_FD; 48 return ret; 49 50 } 51 private: 52 bool open(); 53 54 std:: string mDevPath; 55 int mDevFd[MAX_DEVICE_FD]; 56 int mFdIdx; 57 }; 58 59 #endif //__HARDWARE_EXYNOS_ACRYLIC_DEVICE_H__ 60