1 /* 2 * Copyright (C) 2012 Samsung 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 #ifndef SAMSUNG_SENSORBASE_H 18 #define SAMSUNG_SENSORBASE_H 19 20 #include <stdint.h> 21 #include <errno.h> 22 #include <sys/cdefs.h> 23 #include <sys/types.h> 24 25 #include "sensors.h" 26 #include "SensorBase.h" 27 #include "InputEventReader.h" 28 29 /*****************************************************************************/ 30 #define MAX_BUFFER_FOR_EVENT 4 31 32 class IioSensorBase:public SensorBase { 33 protected: 34 bool mEnabled; 35 bool mHasPendingEvent; 36 InputEventCircularReader mInputReader; 37 sensors_event_t mPendingEvent; 38 char *mInputSysfsEnable; 39 char *mInputSysfsSamplingFrequency; 40 char *mIioSysfsChan; 41 int mIioChanType; 42 FILE *mIioSysfsChanFp; 43 pthread_mutex_t mLock; 44 45 char *makeSysfsName(const char *input_name, 46 const char *input_file); 47 48 virtual bool readValue(int *value); 49 virtual void handleData(int value); 50 51 public: 52 IioSensorBase(const char* dev_name, 53 const char* data_name, 54 const char* enable_name, 55 const char* chan_name, 56 int iio_chan_type); 57 58 virtual ~IioSensorBase(); 59 virtual int enable(int32_t handle, int en); 60 virtual int setDelay(int32_t handle, int64_t ns); 61 virtual int readEvents(sensors_event_t *data, int count); 62 }; 63 #endif /* SAMSUNG_SENSORBASE_H */ 64