From: Ramasamy Date: Fri, 24 Jul 2015 07:29:28 +0000 (+0900) Subject: Adding Ultraviolet sensor support for Note 4 X-Git-Tag: submit/tizen/20151218.070016~50 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F30%2F44630%2F9;p=platform%2Fcore%2Fsystem%2Fsensord.git Adding Ultraviolet sensor support for Note 4 - Added/updated files to support ultraviolet sensor for Note 4. - Added build support - Added API support - Added configuration for Note 4 UV sensor Change-Id: I7de07724d3498372c9a39c5da272eec4674e6af2 --- diff --git a/packaging/sensord.spec b/packaging/sensord.spec index b9bf107..aa45fd0 100755 --- a/packaging/sensord.spec +++ b/packaging/sensord.spec @@ -25,6 +25,7 @@ BuildRequires: pkgconfig(capi-system-info) %define geo_state ON %define pressure_state ON %define temperature_state ON +%define ultraviolet_state ON %define orientation_state ON %define gravity_state ON %define linear_accel_state ON @@ -85,7 +86,8 @@ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DACCEL=%{accel_state} \ -DLINEAR_ACCEL=%{linear_accel_state} -DRV=%{rv_state} \ -DGEOMAGNETIC_RV=%{geomagnetic_rv_state} -DGAMING_RV=%{gaming_rv_state} \ -DUNCAL_GYRO=%{uncal_gyro_state} -DAUTO_ROTATION=%{auto_rotation_state} \ - -DTILT=%{tilt_state} -DTEST_SUITE=%{build_test_suite} \ + -DTILT=%{tilt_state} -DULTRAVIOLET=%{ultraviolet_state} \ + -DTEST_SUITE=%{build_test_suite} \ -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} %build diff --git a/sensor_plugins.xml.in b/sensor_plugins.xml.in index a088a2a..ba602e6 100755 --- a/sensor_plugins.xml.in +++ b/sensor_plugins.xml.in @@ -7,6 +7,7 @@ + @@ -27,5 +28,6 @@ + diff --git a/sensors.xml.in b/sensors.xml.in index b97ec83..58f7fb4 100755 --- a/sensors.xml.in +++ b/sensors.xml.in @@ -366,5 +366,12 @@ + + + + + + + diff --git a/src/libsensord/CMakeLists.txt b/src/libsensord/CMakeLists.txt index bd56d4b..db78c9a 100755 --- a/src/libsensord/CMakeLists.txt +++ b/src/libsensord/CMakeLists.txt @@ -61,6 +61,7 @@ install(FILES sensor_gaming_rv.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/ install(FILES sensor_temperature.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_motion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_fusion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) +install(FILES sensor_ultraviolet.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_deprecated.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES sensor_uncal_gyro.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/) install(FILES ${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/src/libsensord/client_common.cpp b/src/libsensord/client_common.cpp index 29d056f..5783414 100755 --- a/src/libsensord/client_common.cpp +++ b/src/libsensord/client_common.cpp @@ -46,6 +46,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, FUSION_SENSOR, 0, 1), FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, TILT_SENSOR, 0, 1), FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, UNCAL_GYROSCOPE_SENSOR, 0, 1), + FILL_LOG_ELEMENT(LOG_ID_SENSOR_TYPE, ULTRAVIOLET_SENSOR, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, GEOMAGNETIC_CALIBRATION_NEEDED_EVENT, 0, 1), FILL_LOG_ELEMENT(LOG_ID_EVENT, PROXIMITY_CHANGE_STATE_EVENT, 0,1), @@ -71,6 +72,7 @@ log_element g_log_elements[] = { FILL_LOG_ELEMENT(LOG_ID_EVENT, FUSION_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, TILT_RAW_DATA_EVENT, 0, 10), FILL_LOG_ELEMENT(LOG_ID_EVENT, UNCAL_GYRO_RAW_DATA_EVENT, 0, 10), + FILL_LOG_ELEMENT(LOG_ID_EVENT, ULTRAVIOLET_RAW_DATA_EVENT, 0, 10), }; typedef unordered_map log_map; diff --git a/src/libsensord/sensor_internal.h b/src/libsensord/sensor_internal.h index 477e6f0..7711d01 100755 --- a/src/libsensord/sensor_internal.h +++ b/src/libsensord/sensor_internal.h @@ -57,7 +57,7 @@ extern "C" #include #include #include - +#include typedef void (*sensor_cb_t)(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data); typedef void (*sensorhub_cb_t)(sensor_t sensor, unsigned int event_type, sensorhub_data_t *data, void *user_data); diff --git a/src/libsensord/sensor_internal_deprecated.h b/src/libsensord/sensor_internal_deprecated.h index 85bcce7..35f60e7 100755 --- a/src/libsensord/sensor_internal_deprecated.h +++ b/src/libsensord/sensor_internal_deprecated.h @@ -56,6 +56,7 @@ extern "C" #include #include #include +#include #include #define MAX_KEY_LEN 30 diff --git a/src/ultraviolet/CMakeLists.txt b/src/ultraviolet/CMakeLists.txt index 2ec2925..218c8dd 100644 --- a/src/ultraviolet/CMakeLists.txt +++ b/src/ultraviolet/CMakeLists.txt @@ -26,5 +26,5 @@ add_library(${SENSOR_HAL_NAME} SHARED target_link_libraries(${SENSOR_NAME} ${uv_pkgs_LDFLAGS} "-lm") target_link_libraries(${SENSOR_HAL_NAME} ${uv_pkgs_LDFLAGS}) -install(TARGETS ${SENSOR_NAME} DESTINATION lib/sensord) -install(TARGETS ${SENSOR_HAL_NAME} DESTINATION lib/sensord) +install(TARGETS ${SENSOR_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/sensord) +install(TARGETS ${SENSOR_HAL_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/sensord) diff --git a/src/ultraviolet/ultraviolet_sensor.cpp b/src/ultraviolet/ultraviolet_sensor.cpp index c3f221e..c673c02 100755 --- a/src/ultraviolet/ultraviolet_sensor.cpp +++ b/src/ultraviolet/ultraviolet_sensor.cpp @@ -35,7 +35,7 @@ ultraviolet_sensor::ultraviolet_sensor() { m_name = string(SENSOR_NAME); - register_supported_event(ULTRAVIOLET_EVENT_RAW_DATA_REPORT_ON_TIME); + register_supported_event(ULTRAVIOLET_RAW_DATA_EVENT); physical_sensor::set_poller(ultraviolet_sensor::working, this); } @@ -54,9 +54,9 @@ bool ultraviolet_sensor::init() return false; } - sensor_properties_t properties; + sensor_properties_s properties; - if (!m_sensor_hal->get_properties(properties)) { + if (m_sensor_hal->get_properties(properties) == false) { ERR("sensor->get_properties() is failed!\n"); return false; } @@ -88,11 +88,12 @@ bool ultraviolet_sensor::process_event(void) m_sensor_hal->get_sensor_data(event.data); + AUTOLOCK(m_client_info_mutex); - if (get_client_cnt(ULTRAVIOLET_EVENT_RAW_DATA_REPORT_ON_TIME)) { + if (get_client_cnt(ULTRAVIOLET_RAW_DATA_EVENT)) { event.sensor_id = get_id(); - event.event_type = ULTRAVIOLET_EVENT_RAW_DATA_REPORT_ON_TIME; + event.event_type = ULTRAVIOLET_RAW_DATA_EVENT; raw_to_base(event.data); push(event); } @@ -120,7 +121,7 @@ bool ultraviolet_sensor::on_stop(void) return stop_poll(); } -bool ultraviolet_sensor::get_properties(sensor_properties_t &properties) +bool ultraviolet_sensor::get_properties(sensor_properties_s &properties) { return m_sensor_hal->get_properties(properties); } @@ -134,7 +135,7 @@ int ultraviolet_sensor::get_sensor_data(unsigned int type, sensor_data_t &data) if (ret < 0) return -1; - if (type == ULTRAVIOLET_BASE_DATA_SET) { + if (type == ULTRAVIOLET_RAW_DATA_EVENT) { raw_to_base(data); return 0; } @@ -153,21 +154,6 @@ bool ultraviolet_sensor::set_interval(unsigned long interval) void ultraviolet_sensor::raw_to_base(sensor_data_t &data) { - /* - double lsb = data.values[0]; - double comp_lsb; - - const double c = 0.89; - const double e = 2.12; - const double f = -132.8; - - if (lsb > 108.8f) - comp_lsb = e * lsb + f; - else - comp_lsb = c * lsb; - - data.values[0] = comp_lsb * m_resolution; - */ data.values[0] = data.values[0] * m_resolution; data.value_count = 1; } diff --git a/src/ultraviolet/ultraviolet_sensor.h b/src/ultraviolet/ultraviolet_sensor.h index 945af49..95f404b 100755 --- a/src/ultraviolet/ultraviolet_sensor.h +++ b/src/ultraviolet/ultraviolet_sensor.h @@ -31,14 +31,12 @@ public: virtual ~ultraviolet_sensor(); bool init(); - sensor_type_t get_type(void); + virtual sensor_type_t get_type(void); static bool working(void *inst); - - bool set_interval(unsigned long interval); - virtual bool get_properties(sensor_properties_t &properties); - int get_sensor_data(unsigned int type, sensor_data_t &data); - + virtual bool set_interval(unsigned long interval); + virtual bool get_properties(sensor_properties_s &properties); + virtual int get_sensor_data(unsigned int type, sensor_data_t &data); private: sensor_hal *m_sensor_hal; float m_resolution; diff --git a/src/ultraviolet/ultraviolet_sensor_hal.cpp b/src/ultraviolet/ultraviolet_sensor_hal.cpp index 0729a29..9c63734 100755 --- a/src/ultraviolet/ultraviolet_sensor_hal.cpp +++ b/src/ultraviolet/ultraviolet_sensor_hal.cpp @@ -27,7 +27,7 @@ using std::ifstream; -#define SENSOR_TYPE_ULTRAVIOLET "ULTRAVIOLET" +#define SENSOR_TYPE_ULTRAVIOLET "ULTRAVIOLET" #define ELEMENT_NAME "NAME" #define ELEMENT_VENDOR "VENDOR" #define ELEMENT_RAW_DATA_UNIT "RAW_DATA_UNIT" @@ -211,7 +211,7 @@ bool ultraviolet_sensor_hal::update_value(bool wait) ++read_input_cnt; - if (ultraviolet_event.type == EV_REL && ultraviolet_event.code == REL_MISC) { + if (ultraviolet_event.type == EV_REL && ultraviolet_event.code == REL_X) { ultraviolet_raw = (int)ultraviolet_event.value - BIAS; ultraviolet = true; } else if (ultraviolet_event.type == EV_SYN) { @@ -246,15 +246,14 @@ int ultraviolet_sensor_hal::get_sensor_data(sensor_data_t &data) { AUTOLOCK(m_value_mutex); data.accuracy = SENSOR_ACCURACY_GOOD; - data.timestamp = m_fired_time ; + data.timestamp = m_fired_time; data.value_count = 1; data.values[0] = (float) m_ultraviolet; return 0; } - -bool ultraviolet_sensor_hal::get_properties(sensor_properties_t &properties) +bool ultraviolet_sensor_hal::get_properties(sensor_properties_s &properties) { properties.name = m_chip_name; properties.vendor = m_vendor; diff --git a/src/ultraviolet/ultraviolet_sensor_hal.h b/src/ultraviolet/ultraviolet_sensor_hal.h index 87caf83..1925b7a 100755 --- a/src/ultraviolet/ultraviolet_sensor_hal.h +++ b/src/ultraviolet/ultraviolet_sensor_hal.h @@ -37,7 +37,8 @@ public: bool set_interval(unsigned long val); bool is_data_ready(bool wait); virtual int get_sensor_data(sensor_data_t &data); - virtual bool get_properties(sensor_properties_t &properties); + bool get_properties(sensor_properties_s &properties); + private: string m_model_id; string m_vendor;