#include <vconf.h>
#include <libsyscommon/libgdbus.h>
#include <system_info.h>
-#include <sensor_internal.h>
#include <glib.h>
#include "display.h"
#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;
int dim_max;
} *display_arr;
-static bool g_sensor_initialized;
-static int g_sensor_listener;
-
static int alloc_display(void)
{
int i;
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)
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,