From 46a81d7c8dc1eade47b416026857ece336a1353a Mon Sep 17 00:00:00 2001 From: TaeminYeom Date: Thu, 19 Jan 2023 15:18:08 +0900 Subject: [PATCH] display: change not use sensor in rotation API Initial design is using sensor when there is no display rotation module in device. But the spec was changed because of newly added parameter initial display state. Change-Id: Ibf34b0b31a691324bf486d3511b797a833279ec7 Signed-off-by: TaeminYeom --- CMakeLists.txt | 1 - packaging/capi-system-device.spec | 1 - src/display.c | 111 ++++---------------------------------- 3 files changed, 10 insertions(+), 103 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f6868e..b10ff46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,6 @@ SET(PKG_MODULES vconf capi-base-common capi-system-info - sensor gio-2.0 tracker libsyscommon diff --git a/packaging/capi-system-device.spec b/packaging/capi-system-device.spec index 56ecf3e..f6a904e 100644 --- a/packaging/capi-system-device.spec +++ b/packaging/capi-system-device.spec @@ -9,7 +9,6 @@ Source1: capi-system-device.manifest BuildRequires: cmake BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) -BuildRequires: pkgconfig(sensor) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(gio-2.0) diff --git a/src/display.c b/src/display.c index fdfab3f..e467559 100644 --- a/src/display.c +++ b/src/display.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "display.h" @@ -51,7 +50,6 @@ #define DISPLAY_WHITE_BALANCE_OFFSET_MAX 2047 #define DISPLAY_WHITE_BALANCE_OFFSET_MIN 0 -#define SENSOR_SHIFT_TYPE 16 #define ROTATION_ANGLE_DEGREE_MAX 360 static int display_cnt = -1; @@ -60,9 +58,6 @@ struct display { int dim_max; } *display_arr; -static bool g_sensor_initialized; -static int g_sensor_listener; - static int alloc_display(void) { int i; @@ -486,90 +481,6 @@ int is_feature_display_supported(void) return true; } -static int display_sensor_listener_start(void) -{ - sensor_t sensor; - int ret; - bool ret_bool; - - if (!g_sensor_initialized) { - ret = sensord_get_default_sensor(AUTO_ROTATION_SENSOR, &sensor); - if (ret < 0) { - _E("Failed to get auto rotation sensor"); - return ret; - } - - ret = sensord_connect(sensor); - if (ret < 0) { - _E("Failed to connect auto rotation sensor"); - return ret; - } - g_sensor_listener = ret; - g_sensor_initialized = true; - } - - ret_bool = sensord_start(g_sensor_listener, 0); - if (!ret_bool) { - _E("Failed to start auto rotaton sensor"); - sensord_disconnect(g_sensor_listener); - return DEVICE_ERROR_OPERATION_FAILED; - } - - return DEVICE_ERROR_NONE; -} - -static int display_sensor_listener_stop(void) -{ - int ret; - ret = sensord_stop(g_sensor_listener); - if (ret < 0) - return ret; - - return DEVICE_ERROR_NONE; -} - -static int sensor_get_rotation_angle(device_display_rotation_angle_e *angle) -{ - int ret, count, event; - sensor_data_t *sensor_datas; - - ret = display_sensor_listener_start(); - if (ret < 0) - return ret; - - ret = sensord_get_data_list(g_sensor_listener, - AUTO_ROTATION_SENSOR << SENSOR_SHIFT_TYPE | 0x1, - &sensor_datas, - &count); - if (ret < 0 || count <= 0) { - _E("Failed to read the value of auto-rotation sensor"); - display_sensor_listener_stop(); - return DEVICE_ERROR_OPERATION_FAILED; - } - - event = (int)sensor_datas->values[0]; - switch (event) { - case AUTO_ROTATION_DEGREE_0: - *angle = DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_0; - break; - case AUTO_ROTATION_DEGREE_90: - *angle = DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_90; - break; - case AUTO_ROTATION_DEGREE_180: - *angle = DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_180; - break; - case AUTO_ROTATION_DEGREE_270: - *angle = DEVICE_DISPLAY_ROTATION_ANGLE_DEGREE_270; - break; - default: - *angle = DEVICE_DISPLAY_ROTATION_ANGLE_UNKNOWN; - break; - } - - free(sensor_datas); - return display_sensor_listener_stop(); -} - int device_display_get_rotation_angle(int display_index, device_display_rotation_angle_e *angle, device_display_init_direction_e *init_direction) @@ -605,21 +516,19 @@ int device_display_get_rotation_angle(int display_index, g_variant_get(reply, "(iii)", &ret, &reply_angle, &reply_init_direction); g_variant_unref(reply); - if (ret < 0 && ret != -ENODEV) { + + if (ret == -ENODEV) { + _E("Get display rotation is not supported"); + return DEVICE_ERROR_OPERATION_FAILED; + } else if (ret < 0) { _E("Failed to get display rotation angle"); - return ret; - } else if (ret >= 0) { - *angle = reply_angle; - *init_direction = reply_init_direction; - return DEVICE_ERROR_NONE; + return DEVICE_ERROR_OPERATION_FAILED; } - /* - * If the device don't support display rotation, - * get the display rotation angle using capi-system-sensor. - */ - *init_direction = DEVICE_DISPLAY_INIT_DIRECTION_VERTICAL; - return sensor_get_rotation_angle(angle); + *angle = reply_angle; + *init_direction = reply_init_direction; + + return DEVICE_ERROR_NONE; } int device_display_set_rotation_angle(int display_index, -- 2.7.4