SamsungSensorBase::SamsungSensorBase(const char *dev_name, const char *data_name, int sensor_code) : SensorBase(dev_name, data_name), mEnabled(false), //cvt_zxl modify mHasPendingEvent(false), mInputReader(4), mSensorCode(sensor_code), mLock(PTHREAD_MUTEX_INITIALIZER) { mPendingEvent.version = sizeof(sensors_event_t); memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); if (!data_fd) return; mInputSysfsEnable = makeSysfsName(input_name, "enable"); if (!mInputSysfsEnable) { ALOGE("%s: unable to allocate mem for %s:enable", __func__, data_name); return; } mInputSysfsPollDelay = makeSysfsName(input_name, "poll_delay"); if (!mInputSysfsPollDelay) { ALOGE("%s: unable to allocate mem for %s:poll_delay", __func__, data_name); return; } int flags = fcntl(data_fd, F_GETFL, 0); fcntl(data_fd, F_SETFL, flags | O_NONBLOCK); }
IioSensorBase::IioSensorBase(const char *dev_name, const char *data_name, const char *enable_name, const char *chan_name, int iio_chan_type) : SensorBase(dev_name, data_name), mEnabled(true), mHasPendingEvent(false), mInputReader(MAX_BUFFER_FOR_EVENT), mIioChanType(iio_chan_type), mIioSysfsChanFp(NULL) { pthread_mutex_init(&mLock, NULL); ALOGV("%s(): dev_name=%s", __func__, dev_name); mPendingEvent.version = sizeof(sensors_event_t); memset(mPendingEvent.data, 0, sizeof(mPendingEvent.data)); if (!mDataFd) return; mInputSysfsEnable = makeSysfsName(mInputName, enable_name); if (!mInputSysfsEnable) { ALOGE("%s: unable to allocate mem for %s:%s", __func__, data_name, enable_name); return; } mInputSysfsSamplingFrequency = makeSysfsName(mInputName, "sampling_frequency"); if (!mInputSysfsSamplingFrequency) { ALOGE("%s: unable to allocate mem for %s:poll_delay", __func__, data_name); return; } mIioSysfsChan = makeSysfsName(mInputName, chan_name); if (!mIioSysfsChan) { ALOGE("%s: unable to allocate mem for %s:%s", __func__, data_name, chan_name); return; } mIioSysfsChanFp = fopen(mIioSysfsChan, "r"); if (mIioSysfsChanFp == NULL) { ALOGE("%s: unable to open %s", __func__, mIioSysfsChan); return; } int flags = fcntl(mDataFd, F_GETFL, 0); fcntl(mDataFd, F_SETFL, flags | O_NONBLOCK); enable(0, 0); }