Remove unused circle driver 69/247669/3
authorYunmi Ha <yunmi.ha@samsung.com>
Fri, 13 Nov 2020 08:34:50 +0000 (17:34 +0900)
committerYunmi Ha <yunmi.ha@samsung.com>
Mon, 16 Nov 2020 03:13:17 +0000 (12:13 +0900)
Change-Id: I05d45ab0f959f86035892371edb9b15805b383cf
Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
CMakeLists.txt
packaging/feedbackd.spec
src/haptic/circle.c [deleted file]

index 621d2bf6c1854525632ebc864ae559ede427aca6..fb4d6226a55c45ccd7d1c11213fe818bbb0fb5a2 100644 (file)
@@ -24,8 +24,6 @@ ELSEIF(DRIVER STREQUAL gpio)
        SET(SRCS ${SRCS} src/haptic/gpio_haptic.c)
 ELSEIF(DRIVER STREQUAL standard)
        SET(SRCS ${SRCS} src/haptic/standard.c)
-ELSEIF(DRIVER STREQUAL circle)
-       SET(SRCS ${SRCS} src/haptic/circle.c)
 ENDIF()
 
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
index 191777182761cb8094a83407809ae9d5af6ec145..75cbd8ff7e5047b058e258e571964736be6c1bf2 100644 (file)
@@ -44,33 +44,30 @@ Group:      main
 feedback daemon.
 
 # if driver = external or undefined
-%package driver-external 
+%package driver-external
 Summary:       Feedbackd binaries targeting external plugin
 Provides:      %{name}-compat = %{version}-%{release}
 Conflicts:     %{name}-driver-emulator
 Conflicts:     %{name}-driver-gpio
 Conflicts:     %{name}-driver-standard
-Conflicts:     %{name}-driver-circle
 %description driver-external
 Feedbackd binaries with external plugin. Required by main feedbackd package
 # if driver = emulator or undefined
-%package driver-emulator 
+%package driver-emulator
 Summary:       Feedbackd binaries targeting emulator plugin
 Provides:      %{name}-compat = %{version}-%{release}
 Conflicts:     %{name}-driver-external
 Conflicts:     %{name}-driver-gpio
 Conflicts:     %{name}-driver-standard
-Conflicts:     %{name}-driver-circle
 %description driver-emulator
 Feedbackd binaries with emulator plugin. Required by main feedbackd package
 # if driver = gpio or undefined
-%package driver-gpio 
+%package driver-gpio
 Summary:       Feedbackd binaries targeting gpio plugin
 Provides:      %{name}-compat = %{version}-%{release}
 Conflicts:     %{name}-driver-external
 Conflicts:     %{name}-driver-emulator
 Conflicts:     %{name}-driver-standard
-Conflicts:     %{name}-driver-circle
 %description driver-gpio
 Feedbackd binaries with gpio plugin. Required by main feedbackd package
 # if driver = standard or undefined
@@ -80,19 +77,8 @@ Provides:    %{name}-compat = %{version}-%{release}
 Conflicts:     %{name}-driver-external
 Conflicts:     %{name}-driver-emulator
 Conflicts:     %{name}-driver-gpio
-Conflicts:     %{name}-driver-circle
 %description driver-standard
 Feedbackd binaries with standard plugin. Required by main feedbackd package
-# if driver = circle or undefined
-%package driver-circle
-Summary:       Feedbackd binaries targeting circle plugin
-Provides:      %{name}-compat = %{version}-%{release}
-Conflicts:     %{name}-driver-external
-Conflicts:     %{name}-driver-emulator
-Conflicts:     %{name}-driver-gpio
-Conflicts:     %{name}-driver-standard
-%description driver-circle
-Feedbackd binaries with circle plugin. Required by main feedbackd package
 
 %package conf-level3
 Summary:       Feedbackd level configuration file
@@ -118,7 +104,7 @@ This package can be installed optional for auto dbus test.
 %prep
 %setup -q
 
-# Build per driver 
+# Build per driver
 # if driver = external or undefined
 mkdir -p build_external
 pushd build_external
@@ -155,19 +141,10 @@ pushd build_standard
        #eol
 popd
 
-# if driver = circle or undefined
-mkdir -p build_circle
-pushd build_circle
-%cmake .. \
-       -DCMAKE_INSTALL_PREFIX=%{_prefix} \
-       -DDRIVER=circle \
-       #eol
-popd
-
 %build
 cp %{SOURCE1} .
 
-# Build per driver 
+# Build per driver
 # if driver = external or undefined
 pushd build_external
 make %{?jobs:-j%jobs}
@@ -188,11 +165,6 @@ pushd build_standard
 make %{?jobs:-j%jobs}
 popd
 
-# if driver = circle or undefined
-pushd build_circle
-make %{?jobs:-j%jobs}
-popd
-
 %install
 rm -rf %{buildroot}
 # Build per driver
@@ -216,10 +188,6 @@ pushd build_standard
 mv %{buildroot}%{_bindir}/feedbackd %{buildroot}%{_bindir}/feedbackd.standard
 popd
 
-pushd build_circle
-%make_install
-mv %{buildroot}%{_bindir}/feedbackd %{buildroot}%{_bindir}/feedbackd.circle
-popd
 
 %install_service delayed.target.wants feedbackd.service
 
@@ -269,16 +237,6 @@ if [ "$1" == "0" ]; then
     systemctl stop feedbackd.service
 fi
 
-%post driver-circle
-mv %{_bindir}/feedbackd.circle %{_bindir}/feedbackd
-
-%preun driver-circle
-mv %{_bindir}/feedbackd %{_bindir}/feedbackd.circle
-
-if [ "$1" == "0" ]; then
-    systemctl stop feedbackd.service
-fi
-
 %post conf-level3
 mv %{_sysconfdir}/feedbackd/haptic-level3.conf %{_sysconfdir}/feedbackd/haptic.conf
 
@@ -313,11 +271,6 @@ mv %{_sysconfdir}/feedbackd/haptic-level6.conf %{_sysconfdir}/feedbackd/haptic.c
 %manifest %{name}.manifest
 %{_bindir}/feedbackd.standard
 
-%files driver-circle
-%license LICENSE.Apache-2.0
-%manifest %{name}.manifest
-%{_bindir}/feedbackd.circle
-
 %files conf-level3
 %license LICENSE.Apache-2.0
 %manifest %{name}.manifest
diff --git a/src/haptic/circle.c b/src/haptic/circle.c
deleted file mode 100644 (file)
index 42fa1f7..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * feedbackd
- *
- * Copyright (c) 2016 - 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <stdio.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <sys/types.h>
-
-#include "core/log.h"
-#include "core/list.h"
-#include "haptic.h"
-
-#define CIRCLE_ON_PATH             "/sys/class/sec/motor/motor_on"
-#define CIRCLE_OFF_PATH            "/sys/class/sec/motor/motor_off"
-
-#define BUF_SIZE                  8
-
-static int fd_play = -1, fd_stop = -1;
-static dd_list *handle_list;
-static guint stop_timer;
-static int unique_number;
-static bool state = false;
-
-static int stop_device(int device_handle);
-static bool find_from_list(int handle)
-{
-       dd_list *elem;
-
-       elem = DD_LIST_FIND(handle_list, (gpointer)(long)handle);
-       if (elem)
-               return true;
-
-       return false;
-}
-
-static gboolean timer_cb(void *data)
-{
-       int device_handle = (int)(long)data;
-       int ret;
-       char buf[BUF_SIZE];
-       bool found;
-
-       _I("Stop vibration by timer.");
-
-       found = find_from_list(device_handle);
-       if (!found)
-               return G_SOURCE_REMOVE;
-
-       /* stop previous vibration */
-       if (fd_stop < 0) {
-               fd_stop = open(CIRCLE_OFF_PATH, O_RDONLY);
-               if (fd_stop < 0)
-                       return G_SOURCE_REMOVE;
-       }
-       ret = read(fd_stop, buf, BUF_SIZE);
-       if (ret < 0) {
-               _E("Failed to stop.");
-               return G_SOURCE_REMOVE;
-       }
-       stop_timer = 0;
-
-       return G_SOURCE_REMOVE;
-}
-
-static int get_device_count(int *count)
-{
-       /* suppose there is just one haptic device */
-       if (count)
-               *count = 1;
-
-       return 0;
-}
-
-static int open_device(int device_index, int *device_handle)
-{
-       int n;
-       bool found = false;
-       dd_list *elem;
-
-       if (!device_handle)
-               return -EINVAL;
-
-       /* if it is the first element */
-       n = DD_LIST_LENGTH(handle_list);
-       if (n == 0) {
-               _I("Open.");
-               if (fd_play < 0) {
-                       fd_play = open(CIRCLE_ON_PATH, O_RDONLY);
-                       if (fd_play < 0) {
-                               _E("Failed to open '%s': %d", CIRCLE_ON_PATH, errno);
-                               return -errno;
-                       }
-               }
-               if (fd_stop < 0) {
-                       fd_stop = open(CIRCLE_OFF_PATH, O_RDONLY);
-                       if (fd_stop < 0) {
-                               _E("Failed to open '%s': %d", CIRCLE_OFF_PATH, errno);
-                               return -errno;
-                       }
-               }
-       }
-
-       if (unique_number == INT_MAX)
-               unique_number = 0;
-
-       while (found != true) {
-               ++unique_number;
-               elem = DD_LIST_FIND(handle_list, (gpointer)(long)unique_number);
-               if (!elem)
-                       found = true;
-       }
-
-       /* add info to local list */
-       DD_LIST_APPEND(handle_list, (gpointer)(long)unique_number);
-
-       *device_handle = unique_number;
-       return 0;
-}
-
-static int close_device(int device_handle)
-{
-       int r, n;
-       bool found;
-
-       found = find_from_list(device_handle);
-       if (!found) {
-               _E("Handle(%d) fail to check info.", device_handle);
-               return -EINVAL;
-       }
-
-       if (fd_stop < 0) {
-               fd_stop = open(CIRCLE_OFF_PATH, O_RDONLY);
-               if (fd_stop < 0) {
-                       _E("Handle(%d) fail to check fd.", device_handle);
-                       return -ENODEV;
-               }
-       }
-
-       /* stop vibration */
-       r = stop_device(device_handle);
-       if (r < 0)
-               _I("Handle(%d) already stopped or failed to stop effect: %d", device_handle, r);
-
-       DD_LIST_REMOVE(handle_list, (gpointer)(long)device_handle);
-
-       /* if it is the last element */
-       n = DD_LIST_LENGTH(handle_list);
-       if (n == 0) {
-               _I("Close.");
-               if (fd_play > 0) {
-                       close(fd_play);
-                       fd_play = -1;
-               }
-               if (fd_stop > 0) {
-                       close(fd_stop);
-                       fd_stop = -1;
-               }
-       }
-
-       return 0;
-}
-
-static int vibrate_monotone(int device_handle, int duration, int frequency, int overdrive, int level, int intensity, int priority)
-{
-       int ret;
-       char buf[BUF_SIZE];
-       bool found;
-
-       found = find_from_list(device_handle);
-       if (!found) {
-               _E("Handle(%d) fail to check list.", device_handle);
-               return -EINVAL;
-       }
-
-       if (fd_play < 0) {
-               fd_play = open(CIRCLE_ON_PATH, O_RDONLY);
-               if (fd_play < 0) {
-                       _E("Handle(%d) fail to check handle.", device_handle);
-                       return -ENODEV;
-               }
-       }
-
-       if (duration <= 0) {
-               _E("Handle(%d) skip requested with 0.", device_handle);
-               return -EINVAL;
-       }
-
-       /* Zero(0) is the infinitely vibration value */
-       if (duration == HAPTIC_MODULE_DURATION_UNLIMITED)
-               duration = 0;
-
-       if (stop_timer)
-               stop_device(device_handle);
-
-       /* play vibration */
-       ret = read(fd_play, buf, BUF_SIZE);
-       if (ret < 0) {
-               _E("Handle(%d) failed to play.", device_handle);
-               return -errno;
-       }
-
-       /* register timer */
-       if (duration) {
-               stop_timer = g_timeout_add(duration, timer_cb, (void *)(long)device_handle);
-
-               if (!stop_timer)
-                       _E("Handle(%d) Failed to add timer callback.", device_handle);
-       }
-
-       _D("Device handle(%d) %dms.", device_handle, duration);
-
-       return 0;
-}
-
-static int stop_device(int device_handle)
-{
-       int ret;
-       char buf[BUF_SIZE];
-       bool found;
-
-       found = find_from_list(device_handle);
-       if (!found) {
-               _E("Handle(%d) fail to check info.", device_handle);
-               return -EINVAL;
-       }
-
-       if (cur_h_data.handle > 0 && cur_h_data.handle != device_handle) {
-               _E("Only same handle can stop current vibration.");
-               return -EPERM;
-       }
-
-       if (fd_stop < 0) {
-               fd_stop = open(CIRCLE_OFF_PATH, O_RDONLY);
-               if (fd_stop < 0) {
-                       _E("Handle(%d) fail to check fd.", device_handle);
-                       return -ENODEV;
-               }
-       }
-       ret = read(fd_stop, buf, BUF_SIZE);
-       if (ret < 0) {
-               _E("Failed to stop.");
-               return -errno;
-       }
-       if (stop_timer) {
-               g_source_remove(stop_timer);
-               stop_timer = 0;
-       }
-
-       return 0;
-}
-/* END: Haptic Module APIs */
-
-static const struct haptic_plugin_ops default_plugin = {
-       .get_device_count    = get_device_count,
-       .open_device         = open_device,
-       .close_device        = close_device,
-       .vibrate_monotone    = vibrate_monotone,
-       .stop_device         = stop_device,
-};
-
-static bool is_valid(void)
-{
-       if ((access(CIRCLE_ON_PATH, R_OK) != 0) ||
-               (access(CIRCLE_OFF_PATH, R_OK) != 0)) {
-               _E("Do not support wearable haptic device.");
-               state = false;
-               return false;
-       }
-
-       state = true;
-       _I("Support wearable haptic device.");
-       return true;
-}
-
-static const struct haptic_plugin_ops *load(void)
-{
-       return &default_plugin;
-}
-
-static const struct haptic_ops std_ops = {
-       .type     = HAPTIC_STANDARD,
-       .is_valid = is_valid,
-       .load     = load,
-};
-
-HAPTIC_OPS_REGISTER(&std_ops)