X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=entry.c;h=a914f44b80e5d15cd864b3a21797983a1c09e455;hb=9e3bf320c3743b81b9260eff7ed78082999bc612;hp=9aaf0ca48ea698ab528bc68fa9179900b612c065;hpb=be25f03c702f4ca2834c789cf808fe68e6220c4f;p=android-x86%2Fhardware-intel-libsensors.git diff --git a/entry.c b/entry.c index 9aaf0ca..a914f44 100644 --- a/entry.c +++ b/entry.c @@ -1,12 +1,27 @@ /* - * Copyright (C) 2014 Intel Corporation. - */ +// Copyright (c) 2015 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +*/ #include #include #include "enumeration.h" #include "control.h" #include "description.h" +#include "utils.h" + +#include /* This is the IIO Sensors HAL module entry points file */ @@ -15,9 +30,15 @@ static int init_count; static int activate (__attribute__((unused)) struct sensors_poll_device_t* dev, int handle, int enabled) { + int64_t entry_ts; + int ret; + int elapsed_ms; + if (init_count == 0 || handle < 0 || handle >= sensor_count) return -EINVAL; + entry_ts = get_timestamp_thread(); + /* * The Intel sensor hub seems to have trouble enabling sensors before * a sampling rate has been configured, and setting the sampling rate @@ -38,7 +59,18 @@ static int activate (__attribute__((unused)) struct sensors_poll_device_t* dev, sensor[handle].quirks ^= QUIRK_INITIAL_RATE; } - return sensor_activate(handle, enabled, 0); + ret = sensor_activate(handle, enabled, 0); + + elapsed_ms = (int) ((get_timestamp_thread() - entry_ts) / 1000000); + + if (elapsed_ms) { + if (enabled) + ALOGI("Activation of sensor %s took %d ms\n", sensor[handle].friendly_name, elapsed_ms); + else + ALOGI("Deactivation of sensor %s took %d ms\n", sensor[handle].friendly_name, elapsed_ms); + } + + return ret; }