summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinhyung Choi <jinh0.choi@samsung.com>2016-10-24 15:36:22 +0900
committerSeokYeon Hwang <syeon.hwang@samsung.com>2016-11-02 19:32:10 +0900
commitc7d607bb43e8ca008ba8c0dcdc34dc148ae286a0 (patch)
tree98270eadb9d8d3d38a036d9a5435c2dba77a6595
parent8be043116387c9dbe1154e7819feb922404b91dc (diff)
downloadqemu-c7d607bb43e8ca008ba8c0dcdc34dc148ae286a0.tar.gz
qemu-c7d607bb43e8ca008ba8c0dcdc34dc148ae286a0.tar.bz2
qemu-c7d607bb43e8ca008ba8c0dcdc34dc148ae286a0.zip
ecs: handle device capabilities
* capability values are set by emulator daemon |-------| |-----| |---------| | emuld | -------> | ECS | --------> | clients | |-------| set |-----| result |---------| * ECS stores the value and send it when ECP requests. |-----| |-----| |---------| | ECP | --------> | ECS | --------> | clients | |-----| request |-----| result |---------| check sensor & nfc device status additionally. Change-Id: Icebefa564f0263afff0f0e1b139335c7c6f2ba3d Signed-off-by: Jinhyung Choi <jinh0.choi@samsung.com>
-rw-r--r--tizen/src/ecs/ecs.c109
-rw-r--r--tizen/src/ecs/ecs.h5
-rw-r--r--tizen/src/ecs/ecs_msg.c2
-rw-r--r--tizen/src/ecs/ecs_msg_device.c3
-rw-r--r--tizen/src/ecs/ecs_msg_injector.c4
-rw-r--r--tizen/src/hw/virtio/maru_virtio_sensor.c5
-rw-r--r--tizen/src/hw/virtio/maru_virtio_sensor.h2
7 files changed, 130 insertions, 0 deletions
diff --git a/tizen/src/ecs/ecs.c b/tizen/src/ecs/ecs.c
index c77b6c0a55..758579281c 100644
--- a/tizen/src/ecs/ecs.c
+++ b/tizen/src/ecs/ecs.c
@@ -51,6 +51,9 @@
#include "ecs.h"
#include "emul_state.h"
+#include "hw/virtio/maru_virtio_sensor.h"
+#include "hw/virtio/maru_virtio_nfc.h"
+
#include "debug_ch.h"
MULTI_DEBUG_CHANNEL(qemu, ecs);
@@ -77,6 +80,40 @@ static QemuThread ecs_thread_id;
static int suspend_state = 1;
+static char device_capabilities [16];
+
+enum ecs_check_cap_list {
+ CHECK_CAP_BATTERY = 0,
+ CHECK_CAP_LOCATION,
+ CHECK_CAP_NFC,
+ CHECK_CAP_TELEPHONY,
+ CHECK_CAP_ACCEL,
+ CHECK_CAP_GYRO,
+ CHECK_CAP_GEO,
+ CHECK_CAP_PROXI,
+ CHECK_CAP_LIGHT,
+ CHECK_CAP_PRESSURE,
+ CHECK_CAP_HEARTRATE,
+ CHECK_CAP_UV,
+ CHECK_CAP_PEDO
+};
+
+static int cap_device_list[] = {
+ 0x0001, // Battery
+ 0x0002, // Location
+ 0x0004, // NFC
+ 0x0008, // Telephony
+ 0x0010, // Accelerometer
+ 0x0020, // Gyroscope
+ 0x0040, // Magnetometer
+ 0x0080, // Proximity
+ 0x0100, // Light
+ 0x0200, // Pressure
+ 0x0400, // HeartRate
+ 0x0800, // Ultraviolet
+ 0x1000, // Pedometer
+};
+
void ecs_set_suspend_state(int state)
{
suspend_state = state;
@@ -87,6 +124,78 @@ int ecs_get_suspend_state(void)
return suspend_state;
}
+static void check_sensor_capability(int* capacity)
+{
+ int sensor_cap = get_sensor_capability();
+ if ((sensor_cap & sensor_cap_accel) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_ACCEL];
+ }
+ if ((sensor_cap & sensor_cap_geo) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_GEO];
+ }
+
+ if ((sensor_cap & sensor_cap_gyro) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_GYRO];
+ }
+
+ if ((sensor_cap & sensor_cap_proxi) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_PROXI];
+ }
+
+ if ((sensor_cap & sensor_cap_light) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_LIGHT];
+ }
+
+ if ((sensor_cap & sensor_cap_pressure) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_PRESSURE];
+ }
+
+ if ((sensor_cap & sensor_cap_uv) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_UV];
+ }
+
+ if ((sensor_cap & sensor_cap_hrm) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_HEARTRATE];
+ }
+
+ if ((sensor_cap & sensor_cap_pedo) == 0) {
+ *capacity &= ~cap_device_list[CHECK_CAP_PEDO];
+ }
+}
+
+extern VirtIONFC *vio_nfc;
+static void check_nfc_capability(int* capacity)
+{
+ if (!vio_nfc) {
+ *capacity &= ~cap_device_list[CHECK_CAP_NFC];
+ }
+}
+
+void ecs_set_device_capabilities(const char* cap)
+{
+ int capability = 0;
+
+ memset(device_capabilities, 0, sizeof(device_capabilities));
+
+ if (cap != NULL) {
+ capability = atoi(cap);
+ // check sensor capability
+ check_sensor_capability(&capability);
+ // check nfc capability
+ check_nfc_capability(&capability);
+
+ LOG_INFO("check_sensor_capability: %04x\n", capability);
+ snprintf(device_capabilities, sizeof(device_capabilities), "%d", capability);
+ }
+
+ make_send_device_ntf((char*)MSG_TYPE_CAP, MSG_GROUP_STATUS, 0, device_capabilities);
+}
+
+const char* ecs_get_device_capabilities(void)
+{
+ return device_capabilities;
+}
+
int ecs_write(int fd, const uint8_t *buf, int len)
{
int ret, remain;
diff --git a/tizen/src/ecs/ecs.h b/tizen/src/ecs/ecs.h
index 028c2f0675..3458dfaaa5 100644
--- a/tizen/src/ecs/ecs.h
+++ b/tizen/src/ecs/ecs.h
@@ -55,6 +55,7 @@
#define MSG_TYPE_HDS "hds"
#define MSG_TYPE_PACKAGE "package"
#define MSG_TYPE_SYSTEM "system"
+#define MSG_TYPE_CAP "cap"
#define MSG_GROUP_STATUS 15
@@ -95,4 +96,8 @@ int ecs_get_suspend_state(void);
void ecs_set_suspend_state(int state);
void ecs_suspend_lock_state(int state);
+/* Device capabilities check */
+const char* ecs_get_device_capabilities(void);
+void ecs_set_device_capabilities(const char* cap);
+
#endif /* __ECS_H__ */
diff --git a/tizen/src/ecs/ecs_msg.c b/tizen/src/ecs/ecs_msg.c
index 3eb314823a..305eb77051 100644
--- a/tizen/src/ecs/ecs_msg.c
+++ b/tizen/src/ecs/ecs_msg.c
@@ -197,6 +197,8 @@ void send_shutdown_request(int action)
if (!ret) {
LOG_SEVERE("fail to send evdi shutdown system call to emuld.\n");
}
+
+ ecs_set_device_capabilities(NULL);
}
bool ntf_to_injector(const char *data, const int len)
diff --git a/tizen/src/ecs/ecs_msg_device.c b/tizen/src/ecs/ecs_msg_device.c
index 1cdbe91fa0..4e7f5c1e84 100644
--- a/tizen/src/ecs/ecs_msg_device.c
+++ b/tizen/src/ecs/ecs_msg_device.c
@@ -436,6 +436,9 @@ bool msgproc_device_req(ECS_Client *ccli, ECS__DeviceReq *msg)
g_snprintf(vminfo, sizeof(vminfo) - 1, "%s %s %s",
get_vm_name(), get_profile_name(), get_platform_version());
msgproc_device_ans(ccli, cmd, true, vminfo);
+ } else if (!strcmp(cmd, MSG_TYPE_CAP)) {
+ const char* cap = ecs_get_device_capabilities();
+ make_send_device_ntf(cmd, MSG_GROUP_STATUS, 0, (char*)cap);
} else if (!strcmp(cmd, "nfc")) {
msgproc_device_req_nfc(ccli, msg);
} else if (!strcmp(cmd, "sdcard")) {
diff --git a/tizen/src/ecs/ecs_msg_injector.c b/tizen/src/ecs/ecs_msg_injector.c
index a65f70c044..c577ea3b9e 100644
--- a/tizen/src/ecs/ecs_msg_injector.c
+++ b/tizen/src/ecs/ecs_msg_injector.c
@@ -463,6 +463,10 @@ static bool injector_req_handle(char *cat, type_action action, const char *data)
LOG_WARNING("VirtFS is not enabled.\n");
return false;
#endif
+ } else if (!strcmp(cat, MSG_TYPE_CAP)) {
+ LOG_INFO("set capabilities: %s\n", data);
+ ecs_set_device_capabilities(data);
+ return true;
} else if (!strcmp(cat, MSG_TYPE_PACKAGE)) {
do_package(cat, action, data);
return true;
diff --git a/tizen/src/hw/virtio/maru_virtio_sensor.c b/tizen/src/hw/virtio/maru_virtio_sensor.c
index b6522ac4b8..94d892d619 100644
--- a/tizen/src/hw/virtio/maru_virtio_sensor.c
+++ b/tizen/src/hw/virtio/maru_virtio_sensor.c
@@ -726,6 +726,11 @@ static void parse_sensor_capability(char *lists)
LOG_INFO("sensor device capabilty enabled with %02x\n", sensor_capability);
}
+int get_sensor_capability(void)
+{
+ return sensor_capability;
+}
+
static void virtio_sensor_realize(DeviceState *dev, Error **errp)
{
LOG_INFO("initialize virtio-sensor device\n");
diff --git a/tizen/src/hw/virtio/maru_virtio_sensor.h b/tizen/src/hw/virtio/maru_virtio_sensor.h
index 1c0a743934..1cb5b19de9 100644
--- a/tizen/src/hw/virtio/maru_virtio_sensor.h
+++ b/tizen/src/hw/virtio/maru_virtio_sensor.h
@@ -143,6 +143,8 @@ typedef struct VirtIOSENSOR {
char *sensors;
} VirtIOSENSOR;
+int get_sensor_capability(void);
+
void req_sensor_data(enum sensor_types type, enum request_cmd req, char *data, int len);
#define get_sensor_accel() \