From 8d35f3572c34faefe50fade79e92e55c4acc2377 Mon Sep 17 00:00:00 2001 From: "minjie.yu" Date: Mon, 20 May 2024 09:39:49 +0800 Subject: [PATCH] feat: add hdf core compatible with linux-6.6 Signed-off-by: minjie.yu --- adapter/khdf/linux/model/audio/Makefile | 2 +- adapter/khdf/linux/model/display/Makefile | 2 +- adapter/khdf/linux/model/usb/host/Makefile | 3 +- .../model/usb/host/src/usb_net_adapter.c | 14 ++++++++ adapter/khdf/linux/osal/src/osal_cdev.c | 7 +++- adapter/khdf/linux/osal/src/osal_time.c | 2 +- .../khdf/linux/platform/fwk/platform_trace.c | 17 +++++++++ adapter/khdf/linux/platform/spi/spi_adapter.c | 14 +++++++- .../khdf/linux/platform/uart/uart_adapter.c | 36 +++++++++++++++++++ .../display/driver/panel/ili9881_st_5p5.c | 6 ++++ .../vibrator/driver/src/vibrator_haptic.c | 4 +-- .../platform/src/fwk/platform_device.c | 5 +++ .../virtual/adc_linux_virtual_iio_driver.c | 10 +++++- 13 files changed, 113 insertions(+), 9 deletions(-) diff --git a/adapter/khdf/linux/model/audio/Makefile b/adapter/khdf/linux/model/audio/Makefile index 745c69851..04e5db2ce 100644 --- a/adapter/khdf/linux/model/audio/Makefile +++ b/adapter/khdf/linux/model/audio/Makefile @@ -94,7 +94,7 @@ obj-$(CONFIG_DRIVERS_HDF_AUDIO_IMX8MM) += \ $(KHDF_AUDIO_IMX8MM_DIR)/codec/src/wm8904.o \ $(KHDF_AUDIO_IMX8MM_DIR)/codec/src/wm8904_impl.o -ccflags-$(CONFIG_DRIVERS_HDF_AUDIO) += -lm -lc -lgcc -std=gnu99 -Werror\ +ccflags-$(CONFIG_DRIVERS_HDF_AUDIO) += -std=gnu99 -Werror\ -I$(srctree)/$(KHDF_AUDIO_KHDF_ROOT_DIR)/osal/include \ -I$(srctree)/$(KHDF_FRAMEWORK_ROOT_DIR)/include/core \ -I$(srctree)/$(KHDF_FRAMEWORK_ROOT_DIR)/include/utils \ diff --git a/adapter/khdf/linux/model/display/Makefile b/adapter/khdf/linux/model/display/Makefile index c990ef9da..01c86a379 100644 --- a/adapter/khdf/linux/model/display/Makefile +++ b/adapter/khdf/linux/model/display/Makefile @@ -46,7 +46,7 @@ obj-$(CONFIG_DRIVERS_HDF_LCD_ST7789) += \ obj-$(CONFIG_ARCH_ROCKCHIP) += \ $(DISPLAY_ROOT_DIR)/panel/ili9881_st_5p5.o -ccflags-y += -lm -lc -lgcc \ +ccflags-y += \ -I$(srctree)/drivers/hdf/framework/model/display/driver \ -I$(srctree)/drivers/hdf/framework/model/display/driver/adapter_soc \ -I$(srctree)/drivers/hdf/framework/include/utils \ diff --git a/adapter/khdf/linux/model/usb/host/Makefile b/adapter/khdf/linux/model/usb/host/Makefile index 73bad22c9..6e4a80e30 100644 --- a/adapter/khdf/linux/model/usb/host/Makefile +++ b/adapter/khdf/linux/model/usb/host/Makefile @@ -16,7 +16,8 @@ obj-$(CONFIG_DRIVERS_HDF_USB_PNP_NOTIFY) += \ obj-$(CONFIG_DRIVERS_HDF_USB_NET_ADAPTER) += \ $(USB_PNP_NOTIFY_ROOT_DIR)/src/usb_net_adapter.o -ccflags-y += -lm -lc -lgcc \ +ccflags-y += -Wno-incompatible-pointer-types-discards-qualifiers +ccflags-y += \ -I$(srctree)/drivers/hdf/khdf/model/usb/host/include \ -I$(srctree)/drivers/hdf/framework/include/utils \ -I$(srctree)/drivers/hdf/framework/utils/include \ diff --git a/adapter/khdf/linux/model/usb/host/src/usb_net_adapter.c b/adapter/khdf/linux/model/usb/host/src/usb_net_adapter.c index c8280c890..b8957f550 100755 --- a/adapter/khdf/linux/model/usb/host/src/usb_net_adapter.c +++ b/adapter/khdf/linux/model/usb/host/src/usb_net_adapter.c @@ -26,7 +26,11 @@ #endif #include +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) #include +#else +#include +#endif #include "osal_mem.h" #include "securec.h" @@ -116,8 +120,13 @@ static void RxComplete(WorkStruct *work) stats64->tx_packets, stats64->tx_bytes); flags = u64_stats_update_begin_irqsave(&stats64->syncp); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) stats64->rx_packets++; stats64->rx_bytes += usbNet->rxLen; +#else + u64_stats_inc(&stats64->rx_packets); + u64_stats_add(&stats64->rx_bytes, usbNet->rxLen); +#endif u64_stats_update_end_irqrestore(&stats64->syncp, flags); HARCH_NET_INFO_PRINT("rx_complete stats64->rx_packets = %lu,usbNet stats64->rx_bytes = %lu", @@ -544,8 +553,13 @@ static void TxComplete(WorkStruct *work) stats64->tx_packets, stats64->tx_bytes); flags = u64_stats_update_begin_irqsave(&stats64->syncp); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) stats64->tx_packets++; stats64->tx_bytes += usbNet->txLen; +#else + u64_stats_inc(&stats64->tx_packets); + u64_stats_add(&stats64->tx_bytes, usbNet->txLen); +#endif u64_stats_update_end_irqrestore(&stats64->syncp, flags); HARCH_NET_INFO_PRINT ("tx_complete stats64->rx_packets = %lu,usbNet stats64->rx_bytes = %lu", diff --git a/adapter/khdf/linux/osal/src/osal_cdev.c b/adapter/khdf/linux/osal/src/osal_cdev.c index c1a05b8f3..6e928a64c 100644 --- a/adapter/khdf/linux/osal/src/osal_cdev.c +++ b/adapter/khdf/linux/osal/src/osal_cdev.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "osal_cdev.h" #include "hdf_log.h" #include "osal_file.h" @@ -58,7 +59,11 @@ static const char* StringRfindChar(const char* str, char chr) return NULL; } -static char* hdfDevnode(struct device* dev, umode_t* mode) +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) +static char* hdfDevnode(struct device* dev, unsigned short* mode) +#else +static char* hdfDevnode(const struct device* dev, unsigned short* mode) +#endif { (void)mode; return kasprintf(GFP_KERNEL, "hdf/%s", dev_name(dev)); diff --git a/adapter/khdf/linux/osal/src/osal_time.c b/adapter/khdf/linux/osal/src/osal_time.c index 20d121ecd..42e5cbbe3 100644 --- a/adapter/khdf/linux/osal/src/osal_time.c +++ b/adapter/khdf/linux/osal/src/osal_time.c @@ -98,7 +98,7 @@ void OsalMDelay(uint32_t ms) } EXPORT_SYMBOL(OsalMDelay); -uint64_t OsalGetSysTimeMs() +uint64_t OsalGetSysTimeMs(void) { OsalTimespec time; diff --git a/adapter/khdf/linux/platform/fwk/platform_trace.c b/adapter/khdf/linux/platform/fwk/platform_trace.c index 5436a7ee8..047d97017 100644 --- a/adapter/khdf/linux/platform/fwk/platform_trace.c +++ b/adapter/khdf/linux/platform/fwk/platform_trace.c @@ -17,7 +17,12 @@ #include "osal_file.h" #include "osal_mem.h" #include "securec.h" +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) #include "stdarg.h" +#else +#include +#endif #include #include @@ -112,7 +117,9 @@ static ssize_t TraceFileWrite(OsalFile *file, const char *string, uint32_t lengt { ssize_t ret; loff_t pos; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) mm_segment_t org_fs; +#endif struct file *fp = NULL; if (file == NULL || IS_ERR_OR_NULL(file->realFile) || string == NULL) { @@ -121,11 +128,15 @@ static ssize_t TraceFileWrite(OsalFile *file, const char *string, uint32_t lengt } fp = (struct file *)file->realFile; pos = fp->f_pos; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) org_fs = get_fs(); set_fs(KERNEL_DS); +#endif ret = vfs_write(fp, string, length, &pos); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(org_fs); +#endif if (ret < 0) { HDF_LOGE("TraceFileWrite: write file length %d fail, ret: %d!", length, ret); return HDF_FAILURE; @@ -137,7 +148,9 @@ static ssize_t TraceFileWrite(OsalFile *file, const char *string, uint32_t lengt static ssize_t TraceFileRead(OsalFile *file, char *buf, uint32_t length) { ssize_t ret; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) mm_segment_t org_fs; +#endif loff_t pos; struct file *fp = NULL; @@ -146,12 +159,16 @@ static ssize_t TraceFileRead(OsalFile *file, char *buf, uint32_t length) return HDF_ERR_INVALID_PARAM; } fp = (struct file *)file->realFile; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) org_fs = get_fs(); set_fs(KERNEL_DS); +#endif pos = fp->f_pos; ret = vfs_read(fp, buf, length, &pos); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(org_fs); +#endif if (ret < 0) { HDF_LOGE("TraceFileRead: read file length %d fail, ret: %d!", length, ret); return HDF_FAILURE; diff --git a/adapter/khdf/linux/platform/spi/spi_adapter.c b/adapter/khdf/linux/platform/spi/spi_adapter.c index ba598a5d3..7d8b11bd3 100644 --- a/adapter/khdf/linux/platform/spi/spi_adapter.c +++ b/adapter/khdf/linux/platform/spi/spi_adapter.c @@ -173,7 +173,12 @@ static int32_t SpiAdapterTransferOneMsg(struct SpiCntlr *cntlr, struct SpiMsg *m transfer->len = msg->len; transfer->speed_hz = msg->speed; transfer->cs_change = msg->keepCs; // yes! cs_change will keep the last cs active ... - transfer->delay_usecs = msg->delayUs; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) + transfer->delay_usecs = msg->delayUs; +#else + transfer->delay.value = msg->delayUs; + transfer->delay.unit = SPI_DELAY_UNIT_USECS; +#endif spi_message_add_tail(transfer, &xfer); ret = spi_sync(dev->priv, &xfer); @@ -235,8 +240,15 @@ static int32_t SpiAdapterTransferDifferent(struct SpiCntlr *cntlr, struct SpiMsg transfer[i].speed_hz = msg[i].speed; if (msg[i].keepCs != 0) transfer[i].cs_change = msg[i].keepCs; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) if (msg[i].delayUs != 0) transfer[i].delay_usecs = msg[i].delayUs; +#else + if (msg[i].delayUs != 0) { + transfer[i].delay.value = msg[i].delayUs; + transfer[i].delay.unit = SPI_DELAY_UNIT_USECS; + } +#endif spi_message_add_tail(&transfer[i], &xfer); } diff --git a/adapter/khdf/linux/platform/uart/uart_adapter.c b/adapter/khdf/linux/platform/uart/uart_adapter.c index e8bac7820..89af4e0aa 100644 --- a/adapter/khdf/linux/platform/uart/uart_adapter.c +++ b/adapter/khdf/linux/platform/uart/uart_adapter.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "device_resource_if.h" #include "hdf_base.h" #include "hdf_log.h" @@ -40,7 +41,9 @@ static int32_t UartAdapterInit(struct UartHost *host) { char name[UART_PATHNAME_LEN] = {0}; struct file *fp = NULL; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) mm_segment_t oldfs; +#endif if (host == NULL) { HDF_LOGE("UartAdapterInit: host is null!"); @@ -49,15 +52,21 @@ static int32_t UartAdapterInit(struct UartHost *host) if (sprintf_s(name, UART_PATHNAME_LEN - 1, "/dev/%s%d", g_driverName, host->num) < 0) { return HDF_FAILURE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) oldfs = get_fs(); set_fs(KERNEL_DS); +#endif fp = filp_open(name, O_RDWR | O_NOCTTY | O_NDELAY, 0600); /* 0600 : file mode */ if (IS_ERR(fp)) { HDF_LOGE("UartAdapterInit: filp_open %s fail!", name); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(oldfs); +#endif return HDF_FAILURE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(oldfs); +#endif host->priv = fp; return HDF_SUCCESS; } @@ -65,19 +74,26 @@ static int32_t UartAdapterInit(struct UartHost *host) static int32_t UartAdapterDeInit(struct UartHost *host) { struct file *fp = NULL; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) mm_segment_t oldfs; +#endif if (host == NULL) { HDF_LOGE("UartAdapterDeInit: host is null!"); return HDF_ERR_INVALID_OBJECT; } + fp = (struct file *)host->priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) oldfs = get_fs(); set_fs(KERNEL_DS); +#endif if (!IS_ERR(fp) && fp) { filp_close(fp, NULL); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(oldfs); +#endif host->priv = NULL; return HDF_SUCCESS; } @@ -88,7 +104,9 @@ static int32_t UartAdapterRead(struct UartHost *host, uint8_t *data, uint32_t si int ret; struct file *fp = NULL; char *p = (char *)data; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) mm_segment_t oldfs; +#endif uint32_t tmp = 0; if (host == NULL || host->priv == NULL || data == NULL || size == 0) { @@ -97,8 +115,10 @@ static int32_t UartAdapterRead(struct UartHost *host, uint8_t *data, uint32_t si } fp = (struct file *)host->priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) oldfs = get_fs(); set_fs(KERNEL_DS); +#endif while (size >= tmp) { ret = vfs_read(fp, p + tmp, 1, &pos); if (ret < 0) { @@ -107,7 +127,9 @@ static int32_t UartAdapterRead(struct UartHost *host, uint8_t *data, uint32_t si } tmp++; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(oldfs); +#endif return tmp; } @@ -117,7 +139,9 @@ static int32_t UartAdapterWrite(struct UartHost *host, uint8_t *data, uint32_t s int ret; struct file *fp = NULL; char *p = (char *)data; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) mm_segment_t oldfs; +#endif if (host == NULL || host->priv == NULL || data == NULL || size == 0) { HDF_LOGE("UartAdapterWrite: invalid parameters!"); @@ -125,33 +149,45 @@ static int32_t UartAdapterWrite(struct UartHost *host, uint8_t *data, uint32_t s } fp = (struct file *)host->priv; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) oldfs = get_fs(); set_fs(KERNEL_DS); +#endif ret = vfs_write(fp, p, size, &pos); if (ret < 0) { HDF_LOGE("UartAdapterWrite: vfs_write fail, ret: %d!", ret); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(oldfs); +#endif return HDF_FAILURE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(oldfs); +#endif return HDF_SUCCESS; } static int UartAdapterIoctlInner(struct file *fp, unsigned cmd, unsigned long arg) { int ret = HDF_FAILURE; +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) mm_segment_t oldfs; +#endif if (fp == NULL) { HDF_LOGE("UartAdapterIoctlInner: fp is null!"); return HDF_FAILURE; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) oldfs = get_fs(); set_fs(KERNEL_DS); +#endif if (fp->f_op->unlocked_ioctl != NULL) { ret = fp->f_op->unlocked_ioctl(fp, cmd, arg); } +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) set_fs(oldfs); +#endif return ret; } diff --git a/framework/model/display/driver/panel/ili9881_st_5p5.c b/framework/model/display/driver/panel/ili9881_st_5p5.c index 6ca69a7fa..6308670d3 100755 --- a/framework/model/display/driver/panel/ili9881_st_5p5.c +++ b/framework/model/display/driver/panel/ili9881_st_5p5.c @@ -6,6 +6,7 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include #include "ili9881_st_5p5.h" #include "gpio_if.h" #include "hdf_bl.h" @@ -566,6 +567,11 @@ static int32_t PanelInit(struct PanelData *panel) #define MIN_LEVEL 0 #define MAX_LEVEL 255 #define DEFAULT_LEVEL 127 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) +#ifndef MIPI_DSI_MODE_EOT_PACKET +#define MIPI_DSI_MODE_EOT_PACKET MIPI_DSI_MODE_NO_EOT_PACKET +#endif +#endif static struct PanelInfo g_panelInfo = { .width = 720, /* width */ diff --git a/framework/model/misc/vibrator/driver/src/vibrator_haptic.c b/framework/model/misc/vibrator/driver/src/vibrator_haptic.c index 6a486a6ad..9caff32ee 100644 --- a/framework/model/misc/vibrator/driver/src/vibrator_haptic.c +++ b/framework/model/misc/vibrator/driver/src/vibrator_haptic.c @@ -324,7 +324,7 @@ int32_t StartHaptic(struct VibratorEffectCfg *effectCfg) return HDF_SUCCESS; } -int32_t StopHaptic() +int32_t StopHaptic(void) { int32_t ret; struct VibratorHapticData *hapticData = GetHapticData(); @@ -398,7 +398,7 @@ static void FreeHapticConfig(void) (void)OsalMutexUnlock(&hapticData->mutex); } -int32_t DestroyVibratorHaptic() +int32_t DestroyVibratorHaptic(void) { struct VibratorHapticData *hapticData = GetHapticData(); CHECK_VIBRATOR_NULL_PTR_RETURN_VALUE(hapticData, HDF_FAILURE); diff --git a/framework/support/platform/src/fwk/platform_device.c b/framework/support/platform/src/fwk/platform_device.c index 83641be59..f28f2e80c 100644 --- a/framework/support/platform/src/fwk/platform_device.c +++ b/framework/support/platform/src/fwk/platform_device.c @@ -6,12 +6,17 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include #include "platform_device.h" #include "hdf_log.h" #include "osal_mem.h" #include "platform_core.h" #include "securec.h" +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 1, 0) #include "stdarg.h" +#else +#include "linux/stdarg.h" +#endif #define PLATFORM_DEV_NAME_DEFAULT "platform_device" diff --git a/framework/test/unittest/platform/virtual/adc_linux_virtual_iio_driver.c b/framework/test/unittest/platform/virtual/adc_linux_virtual_iio_driver.c index 6b14e56ae..2c8e3d7b9 100644 --- a/framework/test/unittest/platform/virtual/adc_linux_virtual_iio_driver.c +++ b/framework/test/unittest/platform/virtual/adc_linux_virtual_iio_driver.c @@ -14,6 +14,7 @@ #include #include #include +#include #include "hdf_log.h" #include "hdf_base.h" @@ -144,6 +145,9 @@ static struct platform_device g_virtualAdcPlatformDevice = { static int VirtualAdcPlatformProbe(struct platform_device *pdev) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0) + static const unsigned long scanMasks[] = { SCAN_MASKS, 0x00 }; +#endif struct VirtualAdcDev *adcInfo = NULL; struct iio_dev *indioDev = NULL; int ret; @@ -156,11 +160,15 @@ static int VirtualAdcPlatformProbe(struct platform_device *pdev) adcInfo = iio_priv(indioDev); adcInfo->name = "virtual-adc-3516"; adcInfo->busNum = BUS_NUM; - + indioDev->name = KBUILD_MODNAME; indioDev->channels = AdcChannels; indioDev->num_channels = ARRAY_SIZE(AdcChannels); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0) indioDev->available_scan_masks = SCAN_MASKS; +#else + indioDev->available_scan_masks = scanMasks; +#endif indioDev->info = &AdcIioInfo; indioDev->modes = INDIO_DIRECT_MODE; -- Gitee