From 7dce7615b7188e93f6ab7812bdffcfd9b6f35dc3 Mon Sep 17 00:00:00 2001 From: wangdp11 Date: Thu, 26 Jan 2023 17:32:47 +0800 Subject: [PATCH] lynkco: Add TOF kernel driver 1.Modify the Kbuild and Makefile to solve compile error 2.Add VL53L3 kernel driver Change-Id: Id1170fef31016c1657c98bb49452afd40892cf71 Signed-off-by: wangdp11 Reviewed-on: https://gerrit.mot.com/2495537 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Zhenxin Xi Submit-Approved: Jira Key --- drivers/input/misc/vl53L1/Kbuild | 6 ++++-- drivers/input/misc/vl53L1/Makefile | 14 +++++++++----- drivers/input/misc/vl53L1/stmvl53l1.h | 8 ++++++++ drivers/input/misc/vl53L1/stmvl53l1_module-i2c.c | 4 ++++ drivers/input/misc/vl53L1/stmvl53l1_module.c | 5 +++++ 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/drivers/input/misc/vl53L1/Kbuild b/drivers/input/misc/vl53L1/Kbuild index 1e1bdd162299..eedf64205a53 100644 --- a/drivers/input/misc/vl53L1/Kbuild +++ b/drivers/input/misc/vl53L1/Kbuild @@ -3,8 +3,10 @@ # EXTRA_CFLAGS += -Wall -EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/include -EXTRA_CFLAGS += -I$(TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1/inc -I$(TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1/ipp -I$(TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1 +EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/include +EXTRA_CFLAGS += -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1/inc \ + -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1/ipp \ + -I$(ANDROID_BUILD_TOP)/motorola/kernel/modules/drivers/input/misc/vl53L1 # define this environment variable if you want to compile driver for an old # kernel diff --git a/drivers/input/misc/vl53L1/Makefile b/drivers/input/misc/vl53L1/Makefile index 4191dea22679..bfbdc14740ef 100644 --- a/drivers/input/misc/vl53L1/Makefile +++ b/drivers/input/misc/vl53L1/Makefile @@ -1,10 +1,14 @@ -KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build +all: modules -all: - $(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules $(KBUILD_OPTIONS) +modules: + $(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS) modules_install: - $(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install + $(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(M) modules_install + +%: + $(MAKE) -C $(KERNEL_SRC) M=$(M) $@ $(KBUILD_OPTIONS) clean: - $(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean + rm -f *.o *.ko *.mod.c *.mod.o *~ .*.cmd Module.symvers + rm -rf .tmp_versions diff --git a/drivers/input/misc/vl53L1/stmvl53l1.h b/drivers/input/misc/vl53L1/stmvl53l1.h index 84e27cba41b9..11cd38cb5fb5 100644 --- a/drivers/input/misc/vl53L1/stmvl53l1.h +++ b/drivers/input/misc/vl53L1/stmvl53l1.h @@ -39,6 +39,7 @@ #include #include #include +#include #include "vl53l1_api.h" @@ -160,6 +161,13 @@ extern int stmvl53l1_enable_debug; */ #define IPP_LOG_TIMING 1 +#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 5, 0) +struct timeval { + time64_t tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; +#endif + struct ipp_data_t { struct ipp_work_t work; struct ipp_work_t work_out; diff --git a/drivers/input/misc/vl53L1/stmvl53l1_module-i2c.c b/drivers/input/misc/vl53L1/stmvl53l1_module-i2c.c index 1c4a2a8ec88b..a20b1ad55045 100644 --- a/drivers/input/misc/vl53L1/stmvl53l1_module-i2c.c +++ b/drivers/input/misc/vl53L1/stmvl53l1_module-i2c.c @@ -180,7 +180,11 @@ static int insert_device(void) ret = -EINVAL; goto done; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 0) stm_test_i2c_client = i2c_new_device(adapter, &info); +#else + stm_test_i2c_client = i2c_new_client_device(adapter, &info); +#endif if (!stm_test_i2c_client) ret = -EINVAL; diff --git a/drivers/input/misc/vl53L1/stmvl53l1_module.c b/drivers/input/misc/vl53L1/stmvl53l1_module.c index a5fb8e8342f9..4fc2d2889228 100644 --- a/drivers/input/misc/vl53L1/stmvl53l1_module.c +++ b/drivers/input/misc/vl53L1/stmvl53l1_module.c @@ -53,6 +53,7 @@ #include #include #include +#include /* * API includes @@ -4182,7 +4183,11 @@ static void stmvl53l1_input_push_data_multiobject(struct stmvl53l1_data *data) //ABS_HAT0X - Time in Sec(32) input_report_abs(input, ABS_HAT0X, tv.tv_sec); +#if LINUX_VERSION_CODE > KERNEL_VERSION(5, 5, 0) + vl53l1_dbgmsg("ABS_HAT0X : %lld, %zu\n", tv.tv_sec, sizeof(tv.tv_sec)); +#else vl53l1_dbgmsg("ABS_HAT0X : %ld, %zu\n", tv.tv_sec, sizeof(tv.tv_sec)); +#endif //ABS_HAT0Y - Time in uSec(32) //REVISIT : The following code may cause loss of data due to //8 bytes to 32 bits conversion