deviced: Enable vibrator and check whether it is available at runtime 10/35910/3
authorJiyoung Yun <jy910.yun@samsung.com>
Thu, 26 Feb 2015 03:51:46 +0000 (12:51 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Mon, 2 Mar 2015 02:34:26 +0000 (18:34 -0800)
Deviced will check if there is an external vibrator plugin.
It should be named 'libhaptic-module.so' in lib directory.
If not, it checks whether this target supports the input force feedback.
If there is no valid module, it will return fail
and do not register any function and method related to vibrator.

Change-Id: I3bc1da9cb378fac1ecea3cb0480915e0485c229f
Signed-off-by: Jiyoung Yun <jy910.yun@samsung.com>
CMakeLists.txt
packaging/deviced.spec
src/core/edbus-handler.c
src/haptic/external.c
src/haptic/haptic.c
src/haptic/standard.c

index 30c795c..304e348 100755 (executable)
@@ -112,13 +112,11 @@ SET(SRCS ${SRCS}
        src/led/torch.c
 )
 
-IF(TIZEN_VIBRATOR)
 SET(SRCS ${SRCS}
        src/haptic/haptic.c
        src/haptic/external.c
        src/haptic/standard.c
        src/haptic/emulator.c)
-ENDIF(TIZEN_VIBRATOR)
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
index 34de28a..5cfb87b 100755 (executable)
@@ -10,7 +10,6 @@
 %bcond_with sdcard
 %bcond_with sim
 %bcond_with usb
-%bcond_with vibrator
 
 Name:       deviced
 Summary:    Deviced
@@ -208,9 +207,6 @@ export CFLAGS+=" -DX11_SUPPORT"
 %if %{with usb}
        -DTIZEN_USB:BOOL=ON \
 %endif
-%if %{with vibrator}
-       -DTIZEN_VIBRATOR:BOOL=ON \
-%endif
        #eol
 
 %build
index 4da6a5c..9353b58 100644 (file)
@@ -52,7 +52,6 @@ static struct edbus_object edbus_objects[] = {
        { DEVICED_PATH_DISPLAY, DEVICED_INTERFACE_DISPLAY, NULL, NULL },
        { DEVICED_PATH_POWER  , DEVICED_INTERFACE_POWER  , NULL, NULL },
        { DEVICED_PATH_STORAGE, DEVICED_INTERFACE_STORAGE, NULL, NULL },
-       { DEVICED_PATH_HAPTIC , DEVICED_INTERFACE_HAPTIC , NULL, NULL },
        { DEVICED_PATH_MMC    , DEVICED_INTERFACE_MMC    , NULL, NULL },
        { DEVICED_PATH_PROCESS, DEVICED_INTERFACE_PROCESS, NULL, NULL },
        { DEVICED_PATH_KEY    , DEVICED_INTERFACE_KEY    , NULL, NULL },
index 46dfe5d..2482f59 100644 (file)
@@ -70,7 +70,7 @@ error:
                dlopen_handle = NULL;
        }
 
-       _I("Do not support external haptic device");
+       _E("Do not support external haptic device");
        return false;
 }
 
index 2884ac9..61ccc91 100644 (file)
@@ -660,13 +660,20 @@ static const struct edbus_method edbus_methods[] = {
        /* Add methods here */
 };
 
+static int haptic_probe(void *data)
+{
+       /**
+        * load haptic module.
+        * if there is no haptic module,
+        * deviced does not activate a haptic interface.
+        */
+       return haptic_module_load();
+}
+
 static void haptic_init(void *data)
 {
        int r;
 
-       /* Load haptic module */
-       haptic_module_load();
-
        /* get haptic data from configuration file */
        r = config_parse(HAPTIC_CONF_PATH, haptic_load_config, &haptic_conf);
        if (r < 0) {
@@ -675,9 +682,11 @@ static void haptic_init(void *data)
        }
 
        /* init dbus interface */
-       r = register_edbus_method(DEVICED_PATH_HAPTIC, edbus_methods, ARRAY_SIZE(edbus_methods));
+       r = register_edbus_interface_and_method(DEVICED_PATH_HAPTIC,
+                       DEVICED_INTERFACE_HAPTIC,
+                       edbus_methods, ARRAY_SIZE(edbus_methods));
        if (r < 0)
-               _E("fail to init edbus method(%d)", r);
+               _E("fail to init edbus interface and method(%d)", r);
 
        /* register notifier for below each event */
        register_notifier(DEVICE_NOTIFIER_TOUCH_HARDKEY, haptic_hardkey_changed_cb);
@@ -736,6 +745,7 @@ static int haptic_stop(void)
 
 static const struct device_ops haptic_device_ops = {
        .name     = "haptic",
+       .probe    = haptic_probe,
        .init     = haptic_init,
        .exit     = haptic_exit,
 };
index ed43488..d6c7ad0 100644 (file)
@@ -499,7 +499,7 @@ static bool is_valid(void)
 
        ret = ff_find_device();
        if (ret < 0) {
-               _I("Do not support standard haptic device");
+               _E("Do not support standard haptic device");
                return false;
        }