diff --git a/Kconfig b/Kconfig index 33643ad792b202963efc547f38d2472cf5962f21..d732edaec4f16599d7086307a63474fef70b4069 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 fe2bec03f7903ad34f124a35de25ace551cf07f1..7a7c12e10d0e09b0d52cbf92c92cf184440780af 100644 --- a/Makefile +++ b/Makefile @@ -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 7060d581ce5711e33ae0b4a7b5203392604b3a99..88cdc5069b067bd1ef7f2dce716aaa9ddc77d4c1 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 6a5ef430f4227b46706478223679f174ddc2bffa..3b72994a52fe02345ff6f39b11d099f59e591ad0 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 0000000000000000000000000000000000000000..5871521a974fbc361542aba62e16f1e46da63dcb --- /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 0000000000000000000000000000000000000000..c800c1b565eb77ba37f260206487bf73e91c2754 --- /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 0000000000000000000000000000000000000000..62045f15e7ad6327239173255ae8deeb9ccf76a5 --- /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 0000000000000000000000000000000000000000..b6b0a8b93863529977f3ee86a7820894e64bd60f --- /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