| Index: device/generic_sensor/iio/sensor_data_iio.cc
|
| diff --git a/device/generic_sensor/iio/sensor_data_iio.cc b/device/generic_sensor/iio/sensor_data_iio.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8432e680137988e67bb895a4f58df51ad45c4dcc
|
| --- /dev/null
|
| +++ b/device/generic_sensor/iio/sensor_data_iio.cc
|
| @@ -0,0 +1,51 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "device/generic_sensor/iio/sensor_data_iio.h"
|
| +#include "device/sensors/public/cpp/device_sensors_consts.h"
|
| +
|
| +namespace device {
|
| +
|
| +namespace {
|
| +
|
| +using mojom::SensorType;
|
| +
|
| +const base::FilePath::CharType* kSensorsBasePath =
|
| + FILE_PATH_LITERAL("/sys/bus/iio/devices");
|
| +
|
| +const char* kAmbientLightFileNames[][5] = {
|
| + {"in_illuminance0_input", "in_illuminance_input", "in_illuminance0_raw",
|
| + "in_illuminance_raw", "illuminance0_input"}};
|
| +
|
| +// An exampleaw_content_browser_client.cc of other sensor:
|
| +//
|
| +// const char* kAccelerometerFileNames[3][3] = {
|
| +// { "x1", "x2", "x3", },
|
| +// { "y1", "y2", "y3", },
|
| +// { "z1", "z2", "z3", },
|
| +// };
|
| +
|
| +} // namespace
|
| +
|
| +bool InitSensorData(SensorType type, SensorDataIio* data) {
|
| + DCHECK(data);
|
| +
|
| + switch (type) {
|
| + case SensorType::AMBIENT_LIGHT:
|
| + data->sensor_file_names[0] = &kAmbientLightFileNames[0][0];
|
| + data->sensor_file_names_cols = arraysize(*kAmbientLightFileNames);
|
| + data->sensor_file_names_rows = arraysize(kAmbientLightFileNames);
|
| + data->reporting_mode = mojom::ReportingMode::ON_CHANGE;
|
| + data->default_configuration =
|
| + PlatformSensorConfiguration(kDefaultAmbientLightFrequencyHz);
|
| + break;
|
| + default:
|
| + NOTIMPLEMENTED();
|
| + return false;
|
| + }
|
| + data->base_path_sensor_iio = kSensorsBasePath;
|
| + return true;
|
| +}
|
| +
|
| +} // namespace device
|
|
|