From d551c5bfc93f6289f2d021cca086f2795c63240b Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 22 Jun 2021 12:25:56 +0800 Subject: [PATCH 1/2] add vibrator driver Signed-off-by: kevin Change-Id: I6de041178842ba377a9d3f4a39dfd17b83344b02 --- Kconfig | 1 + Makefile | 3 +- hcs/device_info/device_info.hcs | 25 +++++++++++++++ hcs/hdf.hcs | 2 ++ hcs/vibrator/linear_vibrator_config.hcs | 14 +++++++++ hcs/vibrator/vibrator_config.hcs | 16 ++++++++++ model/misc/vibrator/Kconfig | 25 +++++++++++++++ model/misc/vibrator/Makefile | 42 +++++++++++++++++++++++++ 8 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 hcs/vibrator/linear_vibrator_config.hcs create mode 100644 hcs/vibrator/vibrator_config.hcs create mode 100644 model/misc/vibrator/Kconfig create mode 100644 model/misc/vibrator/Makefile diff --git a/Kconfig b/Kconfig index 33643ad..d732eda 100644 --- a/Kconfig +++ b/Kconfig @@ -21,3 +21,4 @@ source "drivers/hdf/khdf/model/network/wifi/Kconfig" source "drivers/hdf/khdf/model/network/bluetooth/Kconfig" source "drivers/hdf/khdf/model/sensor/Kconfig" source "drivers/hdf/khdf/model/storage/Kconfig" +source "drivers/hdf/khdf/model/misc/vibrator/Kconfig" diff --git a/Makefile b/Makefile index fe2bec0..23af81a 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ else obj-$(CONFIG_DRIVERS_HDF) += hcs/ endif endif - +$(info CONFIG_DRIVERS_HDF_VIBRATOR = $(CONFIG_DRIVERS_HDF_VIBRATOR)) obj-$(CONFIG_DRIVERS_HDF) += manager/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM) += platform/ obj-$(CONFIG_DRIVERS_HDF_DISP) += model/display/ @@ -44,3 +44,4 @@ obj-$(CONFIG_DRIVERS_HDF_WIFI) += model/network/wifi/ obj-$(CONFIG_DRIVERS_HDF_SENSOR) += model/sensor/ obj-$(CONFIG_DRIVERS_HDF_STORAGE) += model/storage/ obj-$(CONFIG_DRIVERS_HDF_BT) += model/network/bluetooth/ +obj-$(CONFIG_DRIVERS_HDF_VIBRATOR) += model/misc/vibrator/ diff --git a/hcs/device_info/device_info.hcs b/hcs/device_info/device_info.hcs index 7060d58..88cdc50 100644 --- a/hcs/device_info/device_info.hcs +++ b/hcs/device_info/device_info.hcs @@ -308,5 +308,30 @@ } } } + vibrator :: host { + hostName = "vibrator_host"; + device_vibrator :: device { + device0 :: deviceNode { + policy = 2; + priority = 100; + preload = 0; + permission = 0664; + moduleName = "HDF_VIBRATOR"; + serviceName = "hdf_misc_vibrator"; + deviceMatchAttr = "hdf_vibrator_driver"; + } + } + device_linear_vibrator :: device { + device0 :: deviceNode { + policy = 1; + priority = 105; + preload = 0; + permission = 0664; + moduleName = "HDF_LINEAR_VIBRATOR"; + serviceName = "hdf_misc_linear_vibrator"; + deviceMatchAttr = "hdf_linear_vibrator_driver"; + } + } + } } } diff --git a/hcs/hdf.hcs b/hcs/hdf.hcs index 6a5ef43..3b72994 100644 --- a/hcs/hdf.hcs +++ b/hcs/hdf.hcs @@ -10,6 +10,8 @@ #include "wifi/wlan_platform.hcs" #include "wifi/wlan_chip_hi3881.hcs" #include "sensor/sensor_config.hcs" +#include "vibrator/vibrator_config.hcs" +#include "vibrator/linear_vibrator_config.hcs" root { module = "hisilicon,hi35xx_chip"; diff --git a/hcs/vibrator/linear_vibrator_config.hcs b/hcs/vibrator/linear_vibrator_config.hcs new file mode 100644 index 0000000..5871521 --- /dev/null +++ b/hcs/vibrator/linear_vibrator_config.hcs @@ -0,0 +1,14 @@ +root { + linearVibratorConfig { + boardConfig { + match_attr = "hdf_linear_vibrator_driver"; + vibratorChipConfig { + busType = 1; // 0:i2c 1:gpio + gpioNum = 31; + startReg = 0; + stopReg = 0; + startMask = 0; + } + } + } +} \ No newline at end of file diff --git a/hcs/vibrator/vibrator_config.hcs b/hcs/vibrator/vibrator_config.hcs new file mode 100644 index 0000000..c800c1b --- /dev/null +++ b/hcs/vibrator/vibrator_config.hcs @@ -0,0 +1,16 @@ +root { + vibratorConfig { + boardConfig { + match_attr = "hdf_vibrator_driver"; + vibratorAttr { + /* 0:rotor 1:linear */ + deviceType = 1; + supportPreset = 1; + } + vibratorHapticConfig { + vibrator_haptic_default_time = [1, 0, 600, 800, 600, 1100, 0]; // time seq + vibrator_haptic_default_effect = [0, 0, 3, 800, 1]; // build-in effect + } + } + } +} \ No newline at end of file diff --git a/model/misc/vibrator/Kconfig b/model/misc/vibrator/Kconfig new file mode 100644 index 0000000..62045f1 --- /dev/null +++ b/model/misc/vibrator/Kconfig @@ -0,0 +1,25 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# +# This software is licensed under the terms of the GNU General Public +# License version 2, as published by the Free Software Foundation, and +# may be copied, distributed, and modified under those terms. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +config DRIVERS_HDF_VIBRATOR + bool "Enable HDF vibrator driver" + default n + depends on DRIVERS_HDF + help + Answer Y to enable HDF vibrator driver. + +config DRIVERS_HDF_VIBRATOR_LINEAR + bool "Enable HDF linear vibrator driver" + default n + depends on DRIVERS_HDF_VIBRATOR + help + Answer Y to enable HDF linear vibrator driver. + diff --git a/model/misc/vibrator/Makefile b/model/misc/vibrator/Makefile new file mode 100644 index 0000000..b6b0a8b --- /dev/null +++ b/model/misc/vibrator/Makefile @@ -0,0 +1,42 @@ +# +# Copyright (c) 2021 Huawei Device Co., Ltd. +# +# This software is licensed under the terms of the GNU General Public +# License version 2, as published by the Free Software Foundation, and +# may be copied, distributed, and modified under those terms. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# + +SEC_LIB_SOURCES = memcpy_s.c memmove_s.c memset_s.c securecutil.c secureinput_a.c secureprintoutput_a.c snprintf_s.c sprintf_s.c strcat_s.c strcpy_s.c strncat_s.c strncpy_s.c strtok_s.c vsnprintf_s.c vsprintf_s.c + +PWD:=$(shell pwd) +SEC_OBJECTS:=$(patsubst %.c,%.o,$(SEC_LIB_SOURCES)) + +VIBRATOR_ROOT_DIR = ../../../../../../framework/model/misc/vibrator/driver + +obj-$(CONFIG_DRIVERS_HDF_VIBRATOR) += \ + $(VIBRATOR_ROOT_DIR)/src/vibrator_driver.o \ + $(VIBRATOR_ROOT_DIR)/src/vibrator_haptic.o +obj-$(CONFIG_DRIVERS_HDF_VIBRATOR_LINEAR) += \ + $(VIBRATOR_ROOT_DIR)/chipset/vibrator_linear_driver.o + + +ccflags-y += -Iinclude/../drivers/hdf/framework/model/misc/vibrator/driver/include \ + -Iinclude/../drivers/hdf/framework/model/misc/vibrator/driver/chipset \ + -Iinclude/../drivers/hdf/framework/include/core \ + -Iinclude/../drivers/hdf/framework/core/common/include/host \ + -Iinclude/../drivers/hdf/framework/include/utils \ + -Iinclude/../drivers/hdf/framework/include/osal \ + -Iinclude/../drivers/hdf/framework/ability/sbuf/include \ + -Iinclude/../drivers/hdf/framework/include/platform \ + -Iinclude/../drivers/hdf/framework/include/config \ + -Iinclude/../drivers/hdf/framework/core/host/include \ + -Iinclude/../drivers/hdf/framework/core/shared/include \ + -Iinclude/../drivers/hdf/framework/utils/include \ + -Iinclude/../drivers/hdf/khdf/osal/include \ + -I$(PROJECT_ROOT)/third_party/bounds_checking_function/include -- Gitee From 208474129e18d83d5b353a96d577837653693f33 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 22 Jun 2021 05:17:29 +0000 Subject: [PATCH 2/2] update Makefile. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 23af81a..7a7c12e 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ else obj-$(CONFIG_DRIVERS_HDF) += hcs/ endif endif -$(info CONFIG_DRIVERS_HDF_VIBRATOR = $(CONFIG_DRIVERS_HDF_VIBRATOR)) + obj-$(CONFIG_DRIVERS_HDF) += manager/ obj-$(CONFIG_DRIVERS_HDF_PLATFORM) += platform/ obj-$(CONFIG_DRIVERS_HDF_DISP) += model/display/ -- Gitee