diff --git a/Android.mk b/Android.mk new file mode 100644 index 000000000..e92327b47 --- /dev/null +++ b/Android.mk @@ -0,0 +1,41 @@ +ifeq ($(call is-board-platform-in-list, $(TARGET_BOARD_PLATFORM)),true) + +# Make target to specify building the camera.ko from within Android build system. +LOCAL_PATH := $(call my-dir) +# Path to DLKM make scripts +DLKM_DIR := $(TOP)/device/qcom/common/dlkm + +# Kbuild options +KBUILD_OPTIONS := CAMERA_KERNEL_ROOT=$(shell pwd)/$(LOCAL_PATH) +KBUILD_OPTIONS += KERNEL_ROOT=$(shell pwd)/kernel/msm-$(TARGET_KERNEL_VERSION)/ +KBUILD_OPTIONS += MODNAME=camera +KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM) + +# Clear shell environment variables from previous android module during build +include $(CLEAR_VARS) +# For incremental compilation support. +LOCAL_SRC_FILES := \ + $(shell find $(LOCAL_PATH)/config -L -type f) \ + $(shell find $(LOCAL_PATH)/drivers -L -type f) \ + $(shell find $(LOCAL_PATH)/dt-bindings -L -type f) \ + $(shell find $(LOCAL_PATH)/include -L -type f) \ + $(LOCAL_PATH)/Android.mk \ + $(LOCAL_PATH)/board.mk \ + $(LOCAL_PATH)/product.mk \ + $(LOCAL_PATH)/Kbuild +LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT) +LOCAL_MODULE := camera.ko +LOCAL_MODULE_TAGS := optional +#LOCAL_MODULE_KBUILD_NAME := camera.ko +#LOCAL_MODULE_DEBUG_ENABLE := true + +ifeq ($(TARGET_BOARD_PLATFORM), lahaina) +# Include Kernel DLKM Android.mk target to place generated .ko file in image +include $(DLKM_DIR)/AndroidKernelModule.mk +# Include Camera UAPI Android.mk target to copy headers +include $(LOCAL_PATH)/include/uapi/Android.mk +else +include $(DLKM_DIR)/Build_external_kernelmodule.mk +endif + +endif # End of check for board platform diff --git a/Kbuild b/Kbuild new file mode 100644 index 000000000..d854dec44 --- /dev/null +++ b/Kbuild @@ -0,0 +1,234 @@ +# SPDX-License-Identifier: GPL-2.0-only + +ifeq ($(CONFIG_QCOM_CAMERA_DEBUG), y) +$(info "CAMERA_KERNEL_ROOT is: $(CAMERA_KERNEL_ROOT)") +$(info "KERNEL_ROOT is: $(KERNEL_ROOT)") +endif + +# Include Architecture configurations +ifeq ($(CONFIG_ARCH_WAIPIO), y) +include $(CAMERA_KERNEL_ROOT)/config/waipio.mk +endif + +ifeq ($(CONFIG_ARCH_LAHAINA), y) +include $(CAMERA_KERNEL_ROOT)/config/lahaina.mk +endif + +ifeq ($(CONFIG_ARCH_KONA), y) +include $(CAMERA_KERNEL_ROOT)/config/kona.mk +endif + +ifeq ($(CONFIG_ARCH_BENGAL), y) +include $(CAMERA_KERNEL_ROOT)/config/holi.mk +endif + +ifeq ($(CONFIG_ARCH_KHAJE), y) +include $(CAMERA_KERNEL_ROOT)/config/holi.mk +endif + +ifeq ($(CONFIG_ARCH_HOLI), y) +include $(CAMERA_KERNEL_ROOT)/config/holi.mk +endif + +ifeq ($(CONFIG_ARCH_LITO), y) +include $(CAMERA_KERNEL_ROOT)/config/lito.mk +endif + +ifeq ($(CONFIG_ARCH_SHIMA), y) +include $(CAMERA_KERNEL_ROOT)/config/shima.mk +endif + +# List of all camera-kernel headers +cam_include_dirs := $(shell dirname `find $(CAMERA_KERNEL_ROOT) -name '*.h'` | uniq) + +# Include UAPI headers +USERINCLUDE += \ + -I$(CAMERA_KERNEL_ROOT)/include/uapi/ +# Include Kernel headers +LINUXINCLUDE += \ + -I$(KERNEL_ROOT) \ + $(addprefix -I,$(cam_include_dirs)) \ + -I$(CAMERA_KERNEL_ROOT)/include/uapi/camera \ + -I$(CAMERA_KERNEL_ROOT)/ +# Optional include directories +ccflags-$(CONFIG_MSM_GLOBAL_SYNX) += -I$(KERNEL_ROOT)/drivers/media/platform/msm/synx + +# After creating lists, add content of 'ccflags-m' variable to 'ccflags-y' one. +ccflags-y += ${ccflags-m} + +camera-y := \ + drivers/cam_req_mgr/cam_req_mgr_core.o \ + drivers/cam_req_mgr/cam_req_mgr_dev.o \ + drivers/cam_req_mgr/cam_req_mgr_util.o \ + drivers/cam_req_mgr/cam_mem_mgr.o \ + drivers/cam_req_mgr/cam_req_mgr_workq.o \ + drivers/cam_req_mgr/cam_req_mgr_timer.o \ + drivers/cam_req_mgr/cam_req_mgr_debug.o \ + drivers/cam_utils/cam_soc_util.o \ + drivers/cam_utils/cam_io_util.o \ + drivers/cam_utils/cam_packet_util.o \ + drivers/cam_utils/cam_debug_util.o \ + drivers/cam_utils/cam_trace.o \ + drivers/cam_utils/cam_common_util.o \ + drivers/cam_utils/cam_compat.o \ + drivers/cam_core/cam_context.o \ + drivers/cam_core/cam_context_utils.o \ + drivers/cam_core/cam_node.o \ + drivers/cam_core/cam_subdev.o \ + drivers/cam_smmu/cam_smmu_api.o \ + drivers/cam_sync/cam_sync.o \ + drivers/cam_sync/cam_sync_util.o \ + drivers/cam_cpas/cpas_top/cam_cpastop_hw.o \ + drivers/cam_cpas/camss_top/cam_camsstop_hw.o \ + drivers/cam_cpas/cam_cpas_soc.o \ + drivers/cam_cpas/cam_cpas_intf.o \ + drivers/cam_cpas/cam_cpas_hw.o \ + drivers/cam_cdm/cam_cdm_soc.o \ + drivers/cam_cdm/cam_cdm_util.o \ + drivers/cam_cdm/cam_cdm_intf.o \ + drivers/cam_cdm/cam_cdm_core_common.o \ + drivers/cam_cdm/cam_cdm_virtual_core.o \ + drivers/cam_cdm/cam_cdm_hw_core.o + +camera-$(CONFIG_QCOM_CX_IPEAK) += drivers/cam_utils/cam_cx_ipeak.o +camera-$(CONFIG_QCOM_BUS_SCALING) += drivers/cam_utils/cam_soc_bus.o +camera-$(CONFIG_INTERCONNECT_QCOM) += drivers/cam_utils/cam_soc_icc.o + +camera-$(CONFIG_SPECTRA_ISP) += \ + drivers/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.o \ + drivers/cam_isp/isp_hw_mgr/hw_utils/cam_isp_packet_parser.o \ + drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_dev.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_soc.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_core.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.o \ + drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.o \ + drivers/cam_isp/cam_isp_dev.o \ + drivers/cam_isp/cam_isp_context.o + +camera-$(CONFIG_SPECTRA_SFE) += \ + drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/cam_sfe_soc.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/cam_sfe_dev.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/cam_sfe_core.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_top/cam_sfe_top.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_bus/cam_sfe_bus.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_bus/cam_sfe_bus_rd.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_bus/cam_sfe_bus_wr.o \ + +camera-$(CONFIG_SPECTRA_ICP) += \ + drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.o \ + drivers/cam_icp/icp_hw/ipe_hw/ipe_dev.o \ + drivers/cam_icp/icp_hw/ipe_hw/ipe_core.o \ + drivers/cam_icp/icp_hw/ipe_hw/ipe_soc.o \ + drivers/cam_icp/icp_hw/a5_hw/a5_dev.o \ + drivers/cam_icp/icp_hw/a5_hw/a5_core.o \ + drivers/cam_icp/icp_hw/a5_hw/a5_soc.o \ + drivers/cam_icp/icp_hw/bps_hw/bps_dev.o \ + drivers/cam_icp/icp_hw/bps_hw/bps_core.o \ + drivers/cam_icp/icp_hw/bps_hw/bps_soc.o \ + drivers/cam_icp/cam_icp_subdev.o \ + drivers/cam_icp/cam_icp_context.o \ + drivers/cam_icp/hfi.o + +camera-$(CONFIG_SPECTRA_JPEG) += \ + drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.o \ + drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.o \ + drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_soc.o \ + drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.o \ + drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.o \ + drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_soc.o \ + drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.o \ + drivers/cam_jpeg/cam_jpeg_dev.o \ + drivers/cam_jpeg/cam_jpeg_context.o + +camera-$(CONFIG_SPECTRA_FD) += \ + drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.o \ + drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_core.o \ + drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_soc.o \ + drivers/cam_fd/fd_hw_mgr/cam_fd_hw_mgr.o \ + drivers/cam_fd/cam_fd_dev.o \ + drivers/cam_fd/cam_fd_context.o + +camera-$(CONFIG_SPECTRA_LRME) += \ + drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_dev.o \ + drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_core.o \ + drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_soc.o \ + drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.o \ + drivers/cam_lrme/cam_lrme_dev.o \ + drivers/cam_lrme/cam_lrme_context.o + +camera-$(CONFIG_SPECTRA_SENSOR) += \ + drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.o \ + drivers/cam_sensor_module/cam_actuator/cam_actuator_core.o \ + drivers/cam_sensor_module/cam_actuator/cam_actuator_soc.o \ + drivers/cam_sensor_module/cam_cci/cam_cci_dev.o \ + drivers/cam_sensor_module/cam_cci/cam_cci_core.o \ + drivers/cam_sensor_module/cam_cci/cam_cci_soc.o \ + drivers/cam_sensor_module/cam_csiphy/cam_csiphy_soc.o \ + drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.o \ + drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.o \ + drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.o \ + drivers/cam_sensor_module/cam_eeprom/cam_eeprom_core.o \ + drivers/cam_sensor_module/cam_eeprom/cam_eeprom_soc.o \ + drivers/cam_sensor_module/cam_ois/cam_ois_dev.o \ + drivers/cam_sensor_module/cam_ois/cam_ois_core.o \ + drivers/cam_sensor_module/cam_ois/cam_ois_soc.o \ + drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.o \ + drivers/cam_sensor_module/cam_sensor/cam_sensor_core.o \ + drivers/cam_sensor_module/cam_sensor/cam_sensor_soc.o \ + drivers/cam_sensor_module/cam_sensor_io/cam_sensor_io.o \ + drivers/cam_sensor_module/cam_sensor_io/cam_sensor_cci_i2c.o \ + drivers/cam_sensor_module/cam_sensor_io/cam_sensor_qup_i2c.o \ + drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.o \ + drivers/cam_sensor_module/cam_sensor_utils/cam_sensor_util.o \ + drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.o + +camera-$(CONFIG_LEDS_QPNP_FLASH_V2) += \ + drivers/cam_sensor_module/cam_flash/cam_flash_dev.o \ + drivers/cam_sensor_module/cam_flash/cam_flash_core.o \ + drivers/cam_sensor_module/cam_flash/cam_flash_soc.o + +camera-$(CONFIG_LEDS_QTI_FLASH) += \ + drivers/cam_sensor_module/cam_flash/cam_flash_dev.o \ + drivers/cam_sensor_module/cam_flash/cam_flash_core.o \ + drivers/cam_sensor_module/cam_flash/cam_flash_soc.o + +camera-$(CONFIG_SPECTRA_CUSTOM) += \ + drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_soc.o \ + drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.o \ + drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_core.o \ + drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.o \ + drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.o \ + drivers/cam_cust/cam_custom_dev.o \ + drivers/cam_cust/cam_custom_context.o + +camera-$(CONFIG_SPECTRA_OPE) += \ + drivers/cam_ope/cam_ope_subdev.o \ + drivers/cam_ope/cam_ope_context.o \ + drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.o \ + drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev.o \ + drivers/cam_ope/ope_hw_mgr/ope_hw/ope_soc.o \ + drivers/cam_ope/ope_hw_mgr/ope_hw/ope_core.o \ + drivers/cam_ope/ope_hw_mgr/ope_hw/top/ope_top.o \ + drivers/cam_ope/ope_hw_mgr/ope_hw/bus_rd/ope_bus_rd.o\ + drivers/cam_ope/ope_hw_mgr/ope_hw/bus_wr/ope_bus_wr.o + +camera-$(CONFIG_SPECTRA_TFE) += \ + drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi_core.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi_dev.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_soc.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_dev.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_bus.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_dev.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_soc.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.o \ + drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.o \ + drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.o + +camera-y += drivers/camera_main.o + +obj-m += camera.o +BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/camera.ko diff --git a/Makefile b/Makefile index c32d9b5b8..1b53edbfa 100644 --- a/Makefile +++ b/Makefile @@ -1,53 +1,16 @@ -# SPDX-License-Identifier: GPL-2.0-only +# Makefile for use with Android's kernel/build system -# auto-detect subdirs -ifeq ($(CONFIG_ARCH_KONA), y) -include $(srctree)/techpack/camera/config/konacamera.conf -endif +KBUILD_OPTIONS += CAMERA_KERNEL_ROOT=$(shell pwd) +KBUILD_OPTIONS += KERNEL_ROOT=$(ROOT_DIR)/$(KERNEL_DIR) +KBUILD_OPTIONS += MODNAME=camera -ifeq ($(CONFIG_ARCH_LITO), y) -include $(srctree)/techpack/camera/config/litocamera.conf -endif +all: modules -ifeq ($(CONFIG_ARCH_BENGAL), y) -include $(srctree)/techpack/camera/config/bengalcamera.conf -endif +modules dtbs: + $(MAKE) -C $(KERNEL_SRC) M=$(M) modules $(KBUILD_OPTIONS) -ifeq ($(CONFIG_ARCH_KHAJE), y) -include $(srctree)/techpack/camera/config/khajecamera.conf -endif +modules_install: + $(MAKE) M=$(M) -C $(KERNEL_SRC) modules_install -ifeq ($(CONFIG_ARCH_KONA), y) -LINUXINCLUDE += \ - -include $(srctree)/techpack/camera/config/konacameraconf.h -endif - -ifeq ($(CONFIG_ARCH_LITO), y) -LINUXINCLUDE += \ - -include $(srctree)/techpack/camera/config/litocameraconf.h -endif - -ifeq ($(CONFIG_ARCH_BENGAL), y) -LINUXINCLUDE += \ - -include $(srctree)/techpack/camera/config/bengalcameraconf.h -endif - -ifeq ($(CONFIG_ARCH_KHAJE), y) -LINUXINCLUDE += \ - -include $(srctree)/techpack/camera/config/khajecameraconf.h -endif - -ifdef CONFIG_SPECTRA_CAMERA -# Use USERINCLUDE when you must reference the UAPI directories only. -USERINCLUDE += \ - -I$(srctree)/techpack/camera/include/uapi - -# Use LINUXINCLUDE when you must reference the include/ directory. -# Needed to be compatible with the O= option -LINUXINCLUDE += \ - -I$(srctree)/techpack/camera/include/uapi \ - -I$(srctree)/techpack/camera/include -obj-y += drivers/ -else -$(info Target not found) -endif +clean: + $(MAKE) -C $(KERNEL_SRC) M=$(M) clean diff --git a/board.mk b/board.mk new file mode 100644 index 000000000..715f1d580 --- /dev/null +++ b/board.mk @@ -0,0 +1,6 @@ +# Build camera kernel driver +ifneq ($(TARGET_BOARD_AUTO),true) +ifeq ($(call is-board-platform-in-list,$(TARGET_BOARD_PLATFORM)),true) +BOARD_VENDOR_KERNEL_MODULES += $(KERNEL_MODULES_OUT)/camera.ko +endif +endif \ No newline at end of file diff --git a/config/bengalcamera.conf b/config/bengalcamera.conf deleted file mode 100644 index 167e76fba..000000000 --- a/config/bengalcamera.conf +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (c) 2019, The Linux Foundation. All rights reserved. - -export CONFIG_SPECTRA_CAMERA=y -export CONFIG_SPECTRA_CAMERA_OPE=y -export CONFIG_SPECTRA_CAMERA_TFE=y diff --git a/config/bengalcameraconf.h b/config/bengalcameraconf.h deleted file mode 100644 index b4478b598..000000000 --- a/config/bengalcameraconf.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. - */ - -#define CONFIG_SPECTRA_CAMERA 1 -#define CONFIG_SPECTRA_CAMERA_OPE 1 -#define CONFIG_SPECTRA_CAMERA_TFE 1 diff --git a/config/holi.mk b/config/holi.mk new file mode 100644 index 000000000..0ffdaaca4 --- /dev/null +++ b/config/holi.mk @@ -0,0 +1,13 @@ +# Settings for compiling holi camera architecture + +# Localized KCONFIG settings +CONFIG_SPECTRA_ISP := y +CONFIG_SPECTRA_OPE := y +CONFIG_SPECTRA_TFE := y +CONFIG_SPECTRA_SENSOR := y + +# Flags to pass into C preprocessor +ccflags-y += -DCONFIG_SPECTRA_ISP=1 +ccflags-y += -DCONFIG_SPECTRA_OPE=1 +ccflags-y += -DCONFIG_SPECTRA_TFE=1 +ccflags-y += -DCONFIG_SPECTRA_SENSOR=1 diff --git a/config/khajecamera.conf b/config/khajecamera.conf deleted file mode 100644 index d84667d27..000000000 --- a/config/khajecamera.conf +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (c) 2021, The Linux Foundation. All rights reserved. - -export CONFIG_SPECTRA_CAMERA_OPE=y -export CONFIG_SPECTRA_CAMERA_TFE=y -export CONFIG_SPECTRA_CAMERA_SENSOR=y diff --git a/config/khajecameraconf.h b/config/khajecameraconf.h deleted file mode 100644 index 583e5ec8b..000000000 --- a/config/khajecameraconf.h +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2021, The Linux Foundation. All rights reserved. - */ - -#define CONFIG_SPECTRA_CAMERA 1 -#define CONFIG_SPECTRA_CAMERA_OPE 1 -#define CONFIG_SPECTRA_CAMERA_TFE 1 diff --git a/config/kona.mk b/config/kona.mk new file mode 100644 index 000000000..94ee92a9b --- /dev/null +++ b/config/kona.mk @@ -0,0 +1,15 @@ +# Settings for compiling kona camera architecture + +# Localized KCONFIG settings +CONFIG_SPECTRA_FD := y +CONFIG_SPECTRA_ISP := y +CONFIG_SPECTRA_ICP := y +CONFIG_SPECTRA_JPEG := y +CONFIG_SPECTRA_SENSOR := y + +# Flags to pass into C preprocessor +ccflags-y += -DCONFIG_SPECTRA_FD=1 +ccflags-y += -DCONFIG_SPECTRA_ISP=1 +ccflags-y += -DCONFIG_SPECTRA_ICP=1 +ccflags-y += -DCONFIG_SPECTRA_JPEG=1 +ccflags-y += -DCONFIG_SPECTRA_SENSOR=1 diff --git a/config/konacamera.conf b/config/konacamera.conf deleted file mode 100644 index a50077b2e..000000000 --- a/config/konacamera.conf +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (c) 2019, The Linux Foundation. All rights reserved. - -export CONFIG_SPECTRA_CAMERA=y -export CONFIG_SPECTRA_CAMERA_CUST=y -export CONFIG_SPECTRA_CAMERA_FD=y -export CONFIG_SPECTRA_CAMERA_ICP=y -export CONFIG_SPECTRA_CAMERA_JPEG=y -export CONFIG_SPECTRA_CAMERA_IFE=y -export CONFIG_SPECTRA_CAMERA_LRME=y diff --git a/config/konacameraconf.h b/config/konacameraconf.h deleted file mode 100644 index 412dfa5d8..000000000 --- a/config/konacameraconf.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. - */ - -#define CONFIG_SPECTRA_CAMERA 1 -#define CONFIG_SPECTRA_CAMERA_CUST 1 -#define CONFIG_SPECTRA_CAMERA_FD 1 -#define CONFIG_SPECTRA_CAMERA_ICP 1 -#define CONFIG_SPECTRA_CAMERA_JPEG 1 -#define CONFIG_SPECTRA_CAMERA_IFE 1 -#define CONFIG_SPECTRA_CAMERA_LRME 1 diff --git a/config/lahaina.mk b/config/lahaina.mk new file mode 100644 index 000000000..2962ea0fc --- /dev/null +++ b/config/lahaina.mk @@ -0,0 +1,15 @@ +# Settings for compiling lahaina camera architecture + +# Localized KCONFIG settings +CONFIG_SPECTRA_ISP := y +CONFIG_SPECTRA_ICP := y +CONFIG_SPECTRA_JPEG := y +CONFIG_SPECTRA_CUSTOM := y +CONFIG_SPECTRA_SENSOR := y + +# Flags to pass into C preprocessor +ccflags-y += -DCONFIG_SPECTRA_ISP=1 +ccflags-y += -DCONFIG_SPECTRA_ICP=1 +ccflags-y += -DCONFIG_SPECTRA_JPEG=1 +ccflags-y += -DCONFIG_SPECTRA_CUSTOM=1 +ccflags-y += -DCONFIG_SPECTRA_SENSOR=1 diff --git a/config/lito.mk b/config/lito.mk new file mode 100644 index 000000000..6ea113125 --- /dev/null +++ b/config/lito.mk @@ -0,0 +1,17 @@ +# Settings for compiling lito camera architecture + +# Localized KCONFIG settings +CONFIG_SPECTRA_FD := y +CONFIG_SPECTRA_ISP := y +CONFIG_SPECTRA_ICP := y +CONFIG_SPECTRA_JPEG := y +CONFIG_SPECTRA_LRME := y +CONFIG_SPECTRA_SENSOR := y + +# Flags to pass into C preprocessor +ccflags-y += -DCONFIG_SPECTRA_FD=1 +ccflags-y += -DCONFIG_SPECTRA_ISP=1 +ccflags-y += -DCONFIG_SPECTRA_ICP=1 +ccflags-y += -DCONFIG_SPECTRA_JPEG=1 +ccflags-y += -DCONFIG_SPECTRA_LRME=1 +ccflags-y += -DCONFIG_SPECTRA_SENSOR=1 diff --git a/config/litocamera.conf b/config/litocamera.conf deleted file mode 100644 index dc68ff8bb..000000000 --- a/config/litocamera.conf +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (c) 2019, The Linux Foundation. All rights reserved. - -export CONFIG_SPECTRA_CAMERA=y -export CONFIG_SPECTRA_CAMERA_FD=y -export CONFIG_SPECTRA_CAMERA_ICP=y -export CONFIG_SPECTRA_CAMERA_JPEG=y -export CONFIG_SPECTRA_CAMERA_IFE=y -export CONFIG_SPECTRA_CAMERA_LRME=y diff --git a/config/litocameraconf.h b/config/litocameraconf.h deleted file mode 100644 index 412ff0161..000000000 --- a/config/litocameraconf.h +++ /dev/null @@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Copyright (c) 2020, The Linux Foundation. All rights reserved. - */ - -#define CONFIG_SPECTRA_CAMERA 1 -#define CONFIG_SPECTRA_CAMERA_FD 1 -#define CONFIG_SPECTRA_CAMERA_ICP 1 -#define CONFIG_SPECTRA_CAMERA_JPEG 1 -#define CONFIG_SPECTRA_CAMERA_IFE 1 -#define CONFIG_SPECTRA_CAMERA_LRME 1 diff --git a/config/shima.mk b/config/shima.mk new file mode 100644 index 000000000..c86bb3134 --- /dev/null +++ b/config/shima.mk @@ -0,0 +1,13 @@ +# Settings for compiling shima camera architecture + +# Localized KCONFIG settings +CONFIG_SPECTRA_ISP := y +CONFIG_SPECTRA_ICP := y +CONFIG_SPECTRA_JPEG := y +CONFIG_SPECTRA_SENSOR := y + +# Flags to pass into C preprocessor +ccflags-y += -DCONFIG_SPECTRA_ISP=1 +ccflags-y += -DCONFIG_SPECTRA_ICP=1 +ccflags-y += -DCONFIG_SPECTRA_JPEG=1 +ccflags-y += -DCONFIG_SPECTRA_SENSOR=1 diff --git a/config/waipio.mk b/config/waipio.mk new file mode 100644 index 000000000..923dbaa59 --- /dev/null +++ b/config/waipio.mk @@ -0,0 +1,17 @@ +# Settings for compiling waipio camera architecture + +# Localized KCONFIG settings +CONFIG_SPECTRA_ISP := y +CONFIG_SPECTRA_ICP := y +CONFIG_SPECTRA_SFE := y +CONFIG_SPECTRA_JPEG := y +CONFIG_SPECTRA_CUSTOM := y +CONFIG_SPECTRA_SENSOR := y + +# Flags to pass into C preprocessor +ccflags-y += -DCONFIG_SPECTRA_ISP=1 +ccflags-y += -DCONFIG_SPECTRA_ICP=1 +ccflags-y += -DCONFIG_SPECTRA_SFE=1 +ccflags-y += -DCONFIG_SPECTRA_JPEG=1 +ccflags-y += -DCONFIG_SPECTRA_CUSTOM=1 +ccflags-y += -DCONFIG_SPECTRA_SENSOR=1 diff --git a/config/yupik.mk b/config/yupik.mk new file mode 100644 index 000000000..8c08e40cf --- /dev/null +++ b/config/yupik.mk @@ -0,0 +1,15 @@ +# Settings for compiling yupik camera architecture + +# Localized KCONFIG settings +CONFIG_SPECTRA_ISP := y +CONFIG_SPECTRA_ICP := y +CONFIG_SPECTRA_JPEG := y +CONFIG_SPECTRA_LRME := y +CONFIG_SPECTRA_SENSOR := y + +# Flags to pass into C preprocessor +ccflags-y += -DCONFIG_SPECTRA_ISP=1 +ccflags-y += -DCONFIG_SPECTRA_ICP=1 +ccflags-y += -DCONFIG_SPECTRA_JPEG=1 +ccflags-y += -DCONFIG_SPECTRA_LRME=1 +ccflags-y += -DCONFIG_SPECTRA_SENSOR=1 diff --git a/drivers/Makefile b/drivers/Makefile deleted file mode 100644 index 0004fce1e..000000000 --- a/drivers/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_req_mgr/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_utils/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_core/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sync/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_smmu/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cpas/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cdm/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_isp/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_module/ -obj-$(CONFIG_SPECTRA_CAMERA_ICP) += cam_icp/ -obj-$(CONFIG_SPECTRA_CAMERA_JPEG) += cam_jpeg/ -obj-$(CONFIG_SPECTRA_CAMERA_FD) += cam_fd/ -obj-$(CONFIG_SPECTRA_CAMERA_LRME) += cam_lrme/ -obj-$(CONFIG_SPECTRA_CAMERA_CUST) += cam_cust/ -obj-$(CONFIG_SPECTRA_CAMERA_OPE) += cam_ope/ \ No newline at end of file diff --git a/drivers/cam_cdm/Makefile b/drivers/cam_cdm/Makefile deleted file mode 100644 index 323a52301..000000000 --- a/drivers/cam_cdm/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cdm_soc.o cam_cdm_util.o cam_cdm_intf.o\ - cam_cdm_core_common.o cam_cdm_virtual_core.o \ - cam_cdm_hw_core.o diff --git a/drivers/cam_cdm/cam_cdm_hw_core.c b/drivers/cam_cdm/cam_cdm_hw_core.c index cf8d6e422..4d1cccb99 100644 --- a/drivers/cam_cdm/cam_cdm_hw_core.c +++ b/drivers/cam_cdm/cam_cdm_hw_core.c @@ -2381,17 +2381,15 @@ static struct platform_driver cam_hw_cdm_driver = { }, }; -static int __init cam_hw_cdm_init_module(void) +int cam_hw_cdm_init_module(void) { return platform_driver_register(&cam_hw_cdm_driver); } -static void __exit cam_hw_cdm_exit_module(void) +void cam_hw_cdm_exit_module(void) { platform_driver_unregister(&cam_hw_cdm_driver); } -module_init(cam_hw_cdm_init_module); -module_exit(cam_hw_cdm_exit_module); MODULE_DESCRIPTION("MSM Camera HW CDM driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_cdm/cam_cdm_intf.c b/drivers/cam_cdm/cam_cdm_intf.c index 4beeb71d2..0aaaff137 100644 --- a/drivers/cam_cdm/cam_cdm_intf.c +++ b/drivers/cam_cdm/cam_cdm_intf.c @@ -710,17 +710,15 @@ static struct platform_driver cam_cdm_intf_driver = { }, }; -static int __init cam_cdm_intf_init_module(void) +int cam_cdm_intf_init_module(void) { return platform_driver_register(&cam_cdm_intf_driver); } -static void __exit cam_cdm_intf_exit_module(void) +void cam_cdm_intf_exit_module(void) { platform_driver_unregister(&cam_cdm_intf_driver); } -module_init(cam_cdm_intf_init_module); -module_exit(cam_cdm_intf_exit_module); MODULE_DESCRIPTION("MSM Camera CDM Intf driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_cdm/cam_cdm_intf_api.h b/drivers/cam_cdm/cam_cdm_intf_api.h index 1e9cc3455..384a8995c 100644 --- a/drivers/cam_cdm/cam_cdm_intf_api.h +++ b/drivers/cam_cdm/cam_cdm_intf_api.h @@ -305,4 +305,26 @@ int cam_cdm_detect_hang_error(uint32_t handle); * @return 0 on success */ int cam_cdm_dump_debug_registers(uint32_t handle); + +/** + * @brief : API to register CDM hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_hw_cdm_init_module(void); + +/** + * @brief : API to register CDM interface to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_cdm_intf_init_module(void); + +/** + * @brief : API to remove CDM interface from platform framework. + */ +void cam_cdm_intf_exit_module(void); + +/** + * @brief : API to remove CDM hw from platform framework. + */ +void cam_hw_cdm_exit_module(void); #endif /* _CAM_CDM_API_H_ */ diff --git a/drivers/cam_core/Makefile b/drivers/cam_core/Makefile deleted file mode 100644 index e117039fc..000000000 --- a/drivers/cam_core/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(src) - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_context.o cam_context_utils.o cam_node.o cam_subdev.o diff --git a/drivers/cam_core/cam_context.h b/drivers/cam_core/cam_context.h index 770451faa..8858b149f 100644 --- a/drivers/cam_core/cam_context.h +++ b/drivers/cam_core/cam_context.h @@ -1,13 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, 2021, The Linux Foundation. All rights reserved. */ #ifndef _CAM_CONTEXT_H_ #define _CAM_CONTEXT_H_ #include -#include +#include #include #include "cam_req_mgr_interface.h" #include "cam_hw_mgr_intf.h" diff --git a/drivers/cam_core/cam_hw_mgr_intf.h b/drivers/cam_core/cam_hw_mgr_intf.h index 1e2c1f7a7..f71b0e050 100644 --- a/drivers/cam_core/cam_hw_mgr_intf.h +++ b/drivers/cam_core/cam_hw_mgr_intf.h @@ -6,7 +6,7 @@ #ifndef _CAM_HW_MGR_INTF_H_ #define _CAM_HW_MGR_INTF_H_ -#include +#include #include #include /* @@ -89,7 +89,7 @@ struct cam_hw_fence_map_entry { struct cam_hw_done_event_data { uint32_t num_handles; uint32_t resource_handle[CAM_NUM_OUT_PER_COMP_IRQ_MAX]; - struct timeval timestamp; + struct timespec64 timestamp; uint64_t request_id; }; diff --git a/drivers/cam_cpas/Makefile b/drivers/cam_cpas/Makefile deleted file mode 100644 index 6fc8f9830..000000000 --- a/drivers/cam_cpas/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -#ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/cpas_top -#ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/camss_top -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree) - -obj-$(CONFIG_SPECTRA_CAMERA) += cpas_top/ -obj-$(CONFIG_SPECTRA_CAMERA) += camss_top/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cpas_soc.o cam_cpas_intf.o cam_cpas_hw.o \ No newline at end of file diff --git a/drivers/cam_cpas/cam_cpas_hw.c b/drivers/cam_cpas/cam_cpas_hw.c index c2c7f07f0..468fe9525 100644 --- a/drivers/cam_cpas/cam_cpas_hw.c +++ b/drivers/cam_cpas/cam_cpas_hw.c @@ -1,12 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include #include #include -#include #include #include #include @@ -14,6 +13,7 @@ #include "cam_cpas_hw.h" #include "cam_cpas_hw_intf.h" #include "cam_cpas_soc.h" +#include "cam_compat.h" static uint cam_min_camnoc_ib_bw; module_param(cam_min_camnoc_ib_bw, uint, 0644); @@ -56,75 +56,54 @@ int cam_cpas_util_reg_update(struct cam_hw_info *cpas_hw, static int cam_cpas_util_vote_bus_client_level( struct cam_cpas_bus_client *bus_client, unsigned int level) { - if (!bus_client->valid || (bus_client->dyn_vote == true)) { - CAM_ERR(CAM_CPAS, "Invalid params %d %d", bus_client->valid, - bus_client->dyn_vote); - return -EINVAL; - } + int rc = 0; - if (level >= CAM_MAX_VOTE) { - CAM_ERR(CAM_CPAS, - "Invalid votelevel=%d,usecases=%d,Bus client=[%d][%s]", - level, bus_client->num_usecases, - bus_client->client_id, bus_client->name); - return -EINVAL; + if (!bus_client->valid) { + CAM_ERR(CAM_CPAS, "bus client not valid"); + rc = -EINVAL; + goto end; } if (level == bus_client->curr_vote_level) - return 0; + goto end; - CAM_DBG(CAM_CPAS, "Bus client=[%d][%s] index[%d]", - bus_client->client_id, bus_client->name, level); - msm_bus_scale_client_update_request(bus_client->client_id, level); + rc = cam_soc_bus_client_update_request(bus_client->soc_bus_client, + level); + if (rc) { + CAM_ERR(CAM_CPAS, "Client: %s update request failed rc: %d", + bus_client->common_data.name, rc); + goto end; + } bus_client->curr_vote_level = level; - return 0; +end: + return rc; } static int cam_cpas_util_vote_bus_client_bw( struct cam_cpas_bus_client *bus_client, uint64_t ab, uint64_t ib, bool camnoc_bw, uint64_t *applied_ab, uint64_t *applied_ib) { - struct msm_bus_paths *path; - struct msm_bus_scale_pdata *pdata; - int idx = 0; + int rc = 0; uint64_t min_camnoc_ib_bw = CAM_CPAS_AXI_MIN_CAMNOC_IB_BW; - if (cam_min_camnoc_ib_bw > 0) - min_camnoc_ib_bw = (uint64_t)cam_min_camnoc_ib_bw * 1000000L; - - CAM_DBG(CAM_CPAS, "cam_min_camnoc_ib_bw = %d, min_camnoc_ib_bw=%llu", - cam_min_camnoc_ib_bw, min_camnoc_ib_bw); - if (!bus_client->valid) { - CAM_ERR(CAM_CPAS, "bus client not valid"); - return -EINVAL; - } - - if ((bus_client->num_usecases != 2) || - (bus_client->num_paths != 1) || - (bus_client->dyn_vote != true)) { - CAM_ERR(CAM_CPAS, "dynamic update not allowed %d %d %d", - bus_client->num_usecases, bus_client->num_paths, - bus_client->dyn_vote); - return -EINVAL; + CAM_ERR(CAM_CPAS, "bus client: %s not valid", + bus_client->common_data.name); + rc = -EINVAL; + goto end; } - mutex_lock(&bus_client->lock); - - if (bus_client->curr_vote_level > 1) { - CAM_ERR(CAM_CPAS, "curr_vote_level %d cannot be greater than 1", - bus_client->curr_vote_level); - mutex_unlock(&bus_client->lock); - return -EINVAL; - } + if (cam_min_camnoc_ib_bw > 0) + min_camnoc_ib_bw = (uint64_t)cam_min_camnoc_ib_bw * 1000000L; - idx = bus_client->curr_vote_level; - idx = 1 - idx; - bus_client->curr_vote_level = idx; - mutex_unlock(&bus_client->lock); + CAM_DBG(CAM_CPAS, + "Bus_client: %s, cam_min_camnoc_ib_bw = %d, min_camnoc_ib_bw=%llu", + bus_client->common_data.name, cam_min_camnoc_ib_bw, + min_camnoc_ib_bw); - if (camnoc_bw == true) { + mutex_lock(&bus_client->lock); + if (camnoc_bw) { if ((ab > 0) && (ab < CAM_CPAS_AXI_MIN_CAMNOC_AB_BW)) ab = CAM_CPAS_AXI_MIN_CAMNOC_AB_BW; @@ -138,101 +117,56 @@ static int cam_cpas_util_vote_bus_client_bw( ib = CAM_CPAS_AXI_MIN_MNOC_IB_BW; } - pdata = bus_client->pdata; - path = &(pdata->usecase[idx]); - path->vectors[0].ab = ab; - path->vectors[0].ib = ib; + rc = cam_soc_bus_client_update_bw(bus_client->soc_bus_client, ab, ib); + if (rc) { + CAM_ERR(CAM_CPAS, + "Update bw failed, ab[%llu] ib[%llu]", + ab, ib); + goto unlock_client; + } - CAM_DBG(CAM_CPAS, "Bus client=[%d][%s] :ab[%llu] ib[%llu], index[%d]", - bus_client->client_id, bus_client->name, ab, ib, idx); - msm_bus_scale_client_update_request(bus_client->client_id, idx); if (applied_ab) *applied_ab = ab; if (applied_ib) *applied_ib = ib; - return 0; +unlock_client: + mutex_unlock(&bus_client->lock); +end: + return rc; } static int cam_cpas_util_register_bus_client( struct cam_hw_soc_info *soc_info, struct device_node *dev_node, struct cam_cpas_bus_client *bus_client) { - struct msm_bus_scale_pdata *pdata = NULL; - uint32_t client_id; - int rc; - - pdata = msm_bus_pdata_from_node(soc_info->pdev, - dev_node); - if (!pdata) { - CAM_ERR(CAM_CPAS, "failed get_pdata"); - return -EINVAL; - } - - if ((pdata->num_usecases == 0) || - (pdata->usecase[0].num_paths == 0)) { - CAM_ERR(CAM_CPAS, "usecase=%d", pdata->num_usecases); - rc = -EINVAL; - goto error; - } - - client_id = msm_bus_scale_register_client(pdata); - if (!client_id) { - CAM_ERR(CAM_CPAS, "failed in register ahb bus client"); - rc = -EINVAL; - goto error; - } - - bus_client->dyn_vote = of_property_read_bool(dev_node, - "qcom,msm-bus-vector-dyn-vote"); + int rc = 0; - if (bus_client->dyn_vote && (pdata->num_usecases != 2)) { - CAM_ERR(CAM_CPAS, "Excess or less vectors %d", - pdata->num_usecases); - rc = -EINVAL; - goto fail_unregister_client; + rc = cam_soc_bus_client_register(soc_info->pdev, dev_node, + &bus_client->soc_bus_client, &bus_client->common_data); + if (rc) { + CAM_ERR(CAM_CPAS, "Bus client: %s registertion failed ,rc: %d", + bus_client->common_data.name, rc); + return rc; } - - msm_bus_scale_client_update_request(client_id, 0); - - bus_client->src = pdata->usecase[0].vectors[0].src; - bus_client->dst = pdata->usecase[0].vectors[0].dst; - bus_client->pdata = pdata; - bus_client->client_id = client_id; - bus_client->num_usecases = pdata->num_usecases; - bus_client->num_paths = pdata->usecase[0].num_paths; bus_client->curr_vote_level = 0; bus_client->valid = true; - bus_client->name = pdata->name; mutex_init(&bus_client->lock); - CAM_DBG(CAM_CPAS, "Bus Client=[%d][%s] : src=%d, dst=%d", - bus_client->client_id, bus_client->name, - bus_client->src, bus_client->dst); - return 0; -fail_unregister_client: - msm_bus_scale_unregister_client(bus_client->client_id); -error: - return rc; - } static int cam_cpas_util_unregister_bus_client( struct cam_cpas_bus_client *bus_client) { - if (!bus_client->valid) + if (!bus_client->valid) { + CAM_ERR(CAM_CPAS, "bus client not valid"); return -EINVAL; + } - if (bus_client->dyn_vote) - cam_cpas_util_vote_bus_client_bw(bus_client, 0, 0, false, - NULL, NULL); - else - cam_cpas_util_vote_bus_client_level(bus_client, 0); - - msm_bus_scale_unregister_client(bus_client->client_id); + cam_soc_bus_client_unregister(&bus_client->soc_bus_client); + bus_client->curr_vote_level = 0; bus_client->valid = false; - mutex_destroy(&bus_client->lock); return 0; @@ -898,7 +832,8 @@ static int cam_cpas_util_apply_client_axi_vote( continue; CAM_DBG(CAM_PERF, "Port[%s] : ab=%lld ib=%lld additional=%lld", - mnoc_axi_port->axi_port_name, mnoc_axi_port->ab_bw, + mnoc_axi_port->bus_client.common_data.name, + mnoc_axi_port->ab_bw, mnoc_axi_port->ib_bw, mnoc_axi_port->additional_bw); if (mnoc_axi_port->ab_bw) @@ -1034,7 +969,7 @@ static int cam_cpas_hw_update_axi_vote(struct cam_hw_info *cpas_hw, cpas_core->cpas_client[client_indx], axi_vote); unlock_client: - kzfree(axi_vote); + cam_free_clear((void *)axi_vote); axi_vote = NULL; mutex_unlock(&cpas_core->client_mutex[client_indx]); mutex_unlock(&cpas_hw->hw_mutex); @@ -1110,9 +1045,9 @@ static int cam_cpas_util_apply_client_ahb_vote(struct cam_hw_info *cpas_hw, mutex_lock(&ahb_bus_client->lock); cpas_client->ahb_level = required_level; - CAM_DBG(CAM_CPAS, "Client=[%d][%s] required level[%d], curr_level[%d]", - ahb_bus_client->client_id, ahb_bus_client->name, - required_level, ahb_bus_client->curr_vote_level); + CAM_DBG(CAM_CPAS, "Client[%s] required level[%d], curr_level[%d]", + ahb_bus_client->common_data.name, required_level, + ahb_bus_client->curr_vote_level); if (required_level == ahb_bus_client->curr_vote_level) goto unlock_bus_client; @@ -1365,26 +1300,6 @@ static int cam_cpas_hw_start(void *hw_priv, void *start_args, if (rc) goto remove_ahb_vote; - if ((soc_private->cx_ipeak_gpu_limit) && - (!cpas_core->streamon_clients)) { - soc_private->gpu_pwr_limit = - kgsl_pwr_limits_add(KGSL_DEVICE_3D0); - if (soc_private->gpu_pwr_limit) { - rc = kgsl_pwr_limits_set_gpu_fmax( - soc_private->gpu_pwr_limit, - soc_private->cx_ipeak_gpu_limit); - if (rc) { - kgsl_pwr_limits_del( - soc_private->gpu_pwr_limit); - soc_private->gpu_pwr_limit = NULL; - CAM_ERR(CAM_CPAS, - "set cx_ipeak_gpu_limit failed, rc %d", - rc); - goto remove_axi_vote; - } - } - } - if (cpas_core->streamon_clients == 0) { rc = cam_cpas_util_apply_default_axi_vote(cpas_hw, true); if (rc) @@ -1551,14 +1466,6 @@ static int cam_cpas_hw_stop(void *hw_priv, void *stop_args, CAM_DBG(CAM_CPAS, "Disabled all the resources: irq_count=%d\n", atomic_read(&cpas_core->irq_count)); cpas_hw->hw_state = CAM_HW_STATE_POWER_DOWN; - - if (soc_private->cx_ipeak_gpu_limit && - soc_private->gpu_pwr_limit) { - kgsl_pwr_limits_set_default( - soc_private->gpu_pwr_limit); - kgsl_pwr_limits_del(soc_private->gpu_pwr_limit); - soc_private->gpu_pwr_limit = NULL; - } } ahb_vote.type = CAM_VOTE_ABSOLUTE; @@ -1973,30 +1880,23 @@ static int cam_cpas_util_get_internal_ops(struct platform_device *pdev, return rc; } -static int cam_cpas_util_create_debugfs( - struct cam_cpas *cpas_core) +static int cam_cpas_util_create_debugfs(struct cam_cpas *cpas_core) { int rc = 0; + struct dentry *dbgfileptr = NULL; - cpas_core->dentry = debugfs_create_dir("camera_cpas", NULL); - if (!cpas_core->dentry) - return -ENOMEM; - - if (!debugfs_create_bool("ahb_bus_scaling_disable", - 0644, - cpas_core->dentry, - &cpas_core->ahb_bus_scaling_disable)) { - CAM_ERR(CAM_CPAS, - "failed to create ahb_bus_scaling_disable entry"); - rc = -ENOMEM; - goto err; + dbgfileptr = debugfs_create_dir("camera_cpas", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_CPAS,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + cpas_core->dentry = dbgfileptr; - return 0; - -err: - debugfs_remove_recursive(cpas_core->dentry); - cpas_core->dentry = NULL; + debugfs_create_bool("ahb_bus_scaling_disable", 0644, + cpas_core->dentry, &cpas_core->ahb_bus_scaling_disable); +end: return rc; } @@ -2143,9 +2043,7 @@ int cam_cpas_hw_probe(struct platform_device *pdev, if (rc) goto axi_cleanup; - rc = cam_cpas_util_create_debugfs(cpas_core); - if (rc) - CAM_WARN(CAM_CPAS, "Failed to create dentry"); + rc = cam_cpas_util_create_debugfs(cpas_core); *hw_intf = cpas_hw_intf; return 0; diff --git a/drivers/cam_cpas/cam_cpas_hw.h b/drivers/cam_cpas/cam_cpas_hw.h index acad4ba44..29d6e5230 100644 --- a/drivers/cam_cpas/cam_cpas_hw.h +++ b/drivers/cam_cpas/cam_cpas_hw.h @@ -1,15 +1,18 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_CPAS_HW_H_ #define _CAM_CPAS_HW_H_ -#include +#include + #include "cam_cpas_api.h" #include "cam_cpas_hw_intf.h" #include "cam_common_util.h" +#include "cam_soc_bus.h" #define CAM_CPAS_INFLIGHT_WORKS 5 #define CAM_CPAS_MAX_CLIENTS 40 @@ -117,31 +120,19 @@ struct cam_cpas_client { /** * struct cam_cpas_bus_client : Bus client information * - * @src: Bus master/src id - * @dst: Bus slave/dst id - * @pdata: Bus pdata information - * @client_id: Bus client id - * @num_usecases: Number of use cases for this client - * @num_paths: Number of paths for this client - * @curr_vote_level: current voted index - * @dyn_vote: Whether dynamic voting enabled - * @lock: Mutex lock used while voting on this client * @valid: Whether bus client is valid * @name: Name of the bus client - * + * @lock: Mutex lock used while voting on this client + * @curr_vote_level: current voted index + * @common_data: Common data fields for bus client + * @soc_bus_client: Bus client private information */ struct cam_cpas_bus_client { - int src; - int dst; - struct msm_bus_scale_pdata *pdata; - uint32_t client_id; - int num_usecases; - int num_paths; - unsigned int curr_vote_level; - bool dyn_vote; - struct mutex lock; bool valid; - const char *name; + struct mutex lock; + unsigned int curr_vote_level; + struct cam_soc_bus_client_common_data common_data; + void *soc_bus_client; }; /** diff --git a/drivers/cam_cpas/cam_cpas_hw_intf.h b/drivers/cam_cpas/cam_cpas_hw_intf.h index 3f6443630..3e6ac167f 100644 --- a/drivers/cam_cpas/cam_cpas_hw_intf.h +++ b/drivers/cam_cpas/cam_cpas_hw_intf.h @@ -126,4 +126,14 @@ int cam_cpas_hw_probe(struct platform_device *pdev, struct cam_hw_intf **hw_intf); int cam_cpas_hw_remove(struct cam_hw_intf *cpas_hw_intf); +/** + * @brief : API to register CPAS hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_cpas_dev_init_module(void); + +/** + * @brief : API to remove CPAS interface from platform framework. + */ +void cam_cpas_dev_exit_module(void); #endif /* _CAM_CPAS_HW_INTF_H_ */ diff --git a/drivers/cam_cpas/cam_cpas_intf.c b/drivers/cam_cpas/cam_cpas_intf.c index ce649c06b..4013fcb16 100644 --- a/drivers/cam_cpas/cam_cpas_intf.c +++ b/drivers/cam_cpas/cam_cpas_intf.c @@ -7,12 +7,14 @@ #include #include #include + #include #include #include #include #include -#include + +#include #include "cam_subdev.h" #include "cam_cpas_hw_intf.h" @@ -781,17 +783,15 @@ static struct platform_driver cam_cpas_driver = { }, }; -static int __init cam_cpas_dev_init_module(void) +int cam_cpas_dev_init_module(void) { return platform_driver_register(&cam_cpas_driver); } -static void __exit cam_cpas_dev_exit_module(void) +void cam_cpas_dev_exit_module(void) { platform_driver_unregister(&cam_cpas_driver); } -module_init(cam_cpas_dev_init_module); -module_exit(cam_cpas_dev_exit_module); MODULE_DESCRIPTION("MSM CPAS driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_cpas/cam_cpas_soc.c b/drivers/cam_cpas/cam_cpas_soc.c index 2694c5eba..5d6ef7835 100644 --- a/drivers/cam_cpas/cam_cpas_soc.c +++ b/drivers/cam_cpas/cam_cpas_soc.c @@ -10,6 +10,8 @@ #include #include +#include + #include "cam_cpas_api.h" #include "cam_cpas_hw_intf.h" #include "cam_cpas_hw.h" @@ -204,7 +206,7 @@ static int cam_cpas_parse_node_tree(struct cam_cpas *cpas_core, rc = of_property_read_u32(level_node, "level-index", &level_idx); if (rc) { - CAM_ERR(CAM_CPAS, "Error raeding level idx rc: %d", rc); + CAM_ERR(CAM_CPAS, "Error reading level idx rc: %d", rc); return rc; } if (level_idx >= CAM_CPAS_MAX_TREE_LEVELS) { @@ -270,19 +272,82 @@ static int cam_cpas_parse_node_tree(struct cam_cpas *cpas_core, cpas_core->axi_port[mnoc_idx].axi_port_node = mnoc_node; - rc = of_property_read_string( - curr_node, "qcom,axi-port-name", - &cpas_core->axi_port[mnoc_idx] - .axi_port_name); - if (rc) { - CAM_ERR(CAM_CPAS, - "failed to read mnoc-port-name rc=%d", - rc); - return rc; + if (soc_private->bus_icc_based) { + struct of_phandle_args src_args = {0}, + dst_args = {0}; + + rc = of_property_read_string(mnoc_node, + "interconnect-names", + &cpas_core->axi_port[mnoc_idx] + .bus_client.common_data.name); + if (rc) { + CAM_ERR(CAM_CPAS, + "failed to read interconnect-names rc=%d", + rc); + return rc; + } + + rc = of_parse_phandle_with_args( + mnoc_node, "interconnects", + "#interconnect-cells", 0, + &src_args); + if (rc) { + CAM_ERR(CAM_CPAS, + "failed to read axi bus src info rc=%d", + rc); + return -EINVAL; + } + + of_node_put(src_args.np); + if (src_args.args_count != 1) { + CAM_ERR(CAM_CPAS, + "Invalid number of axi src args: %d", + src_args.args_count); + return -EINVAL; + } + + cpas_core->axi_port[mnoc_idx].bus_client + .common_data.src_id = src_args.args[0]; + + rc = of_parse_phandle_with_args( + mnoc_node, "interconnects", + "#interconnect-cells", 1, + &dst_args); + if (rc) { + CAM_ERR(CAM_CPAS, + "failed to read axi bus dst info rc=%d", + rc); + return -EINVAL; + } + + of_node_put(dst_args.np); + if (dst_args.args_count != 1) { + CAM_ERR(CAM_CPAS, + "Invalid number of axi dst args: %d", + dst_args.args_count); + return -EINVAL; + } + + cpas_core->axi_port[mnoc_idx].bus_client + .common_data.dst_id = dst_args.args[0]; + cpas_core->axi_port[mnoc_idx].bus_client + .common_data.num_usecases = 2; + } else { + rc = of_property_read_string( + curr_node, "qcom,axi-port-name", + &cpas_core->axi_port[mnoc_idx] + .bus_client.common_data.name); + if (rc) { + CAM_ERR(CAM_CPAS, + "failed to read mnoc-port-name rc=%d", + rc); + return rc; + } } + cpas_core->axi_port [mnoc_idx].ib_bw_voting_needed - = of_property_read_bool(curr_node, + = of_property_read_bool(curr_node, "ib-bw-voting-needed"); curr_node_ptr->axi_port_idx = mnoc_idx; mnoc_idx++; @@ -497,7 +562,8 @@ int cam_cpas_get_custom_dt_info(struct cam_hw_info *cpas_hw, struct platform_device *pdev, struct cam_cpas_private_soc *soc_private) { struct device_node *of_node; - int count = 0, i = 0, rc = 0; + struct of_phandle_args src_args = {0}, dst_args = {0}; + int count = 0, i = 0, rc = 0, num_bw_values = 0, num_levels = 0; struct cam_cpas *cpas_core = (struct cam_cpas *) cpas_hw->core_info; if (!soc_private || !pdev) { @@ -545,6 +611,123 @@ int cam_cpas_get_custom_dt_info(struct cam_hw_info *cpas_hw, soc_private->client_id_based = of_property_read_bool(of_node, "client-id-based"); + soc_private->bus_icc_based = of_property_read_bool(of_node, + "interconnects"); + + if (soc_private->bus_icc_based) { + rc = of_property_read_string(of_node, "interconnect-names", + &cpas_core->ahb_bus_client.common_data.name); + if (rc) { + CAM_ERR(CAM_CPAS, + "device %s failed to read interconnect-names", + pdev->name); + return rc; + } + + rc = of_parse_phandle_with_args(of_node, "interconnects", + "#interconnect-cells", 0, &src_args); + if (rc) { + CAM_ERR(CAM_CPAS, + "device %s failed to read ahb bus src info", + pdev->name); + return rc; + } + + of_node_put(src_args.np); + if (src_args.args_count != 1) { + CAM_ERR(CAM_CPAS, + "Invalid number of ahb src args: %d", + src_args.args_count); + return -EINVAL; + } + + cpas_core->ahb_bus_client.common_data.src_id = src_args.args[0]; + + rc = of_parse_phandle_with_args(of_node, "interconnects", + "#interconnect-cells", 1, &dst_args); + if (rc) { + CAM_ERR(CAM_CPAS, + "device %s failed to read ahb bus dst info", + pdev->name); + return rc; + } + + of_node_put(dst_args.np); + if (dst_args.args_count != 1) { + CAM_ERR(CAM_CPAS, + "Invalid number of ahb dst args: %d", + dst_args.args_count); + return -EINVAL; + } + + cpas_core->ahb_bus_client.common_data.dst_id = dst_args.args[0]; + + rc = of_property_read_u32(of_node, "cam-ahb-num-cases", + &cpas_core->ahb_bus_client.common_data.num_usecases); + if (rc) { + CAM_ERR(CAM_CPAS, + "device %s failed to read ahb num usecases", + pdev->name); + return rc; + } + + if (cpas_core->ahb_bus_client.common_data.num_usecases > + CAM_SOC_BUS_MAX_NUM_USECASES) { + CAM_ERR(CAM_UTIL, "Invalid number of usecases: %d", + cpas_core->ahb_bus_client.common_data + .num_usecases); + return -EINVAL; + } + + num_bw_values = of_property_count_u32_elems(of_node, + "cam-ahb-bw-KBps"); + if (num_bw_values <= 0) { + CAM_ERR(CAM_UTIL, "Error counting ahb bw values"); + return -EINVAL; + } + + CAM_DBG(CAM_CPAS, "AHB: num bw values %d", num_bw_values); + num_levels = (num_bw_values / 2); + + if (num_levels != + cpas_core->ahb_bus_client.common_data.num_usecases) { + CAM_ERR(CAM_UTIL, "Invalid number of levels: %d", + num_bw_values/2); + return -EINVAL; + } + + for (i = 0; i < num_levels; i++) { + rc = of_property_read_u32_index(of_node, + "cam-ahb-bw-KBps", + (i * 2), + (uint32_t *) &cpas_core->ahb_bus_client + .common_data.bw_pair[i].ab); + if (rc) { + CAM_ERR(CAM_UTIL, + "Error reading ab bw value, rc=%d", + rc); + return rc; + } + + rc = of_property_read_u32_index(of_node, + "cam-ahb-bw-KBps", + ((i * 2) + 1), + (uint32_t *) &cpas_core->ahb_bus_client + .common_data.bw_pair[i].ib); + if (rc) { + CAM_ERR(CAM_UTIL, + "Error reading ib bw value, rc=%d", + rc); + return rc; + } + + CAM_DBG(CAM_CPAS, + "AHB: Level: %d, ab_value %llu, ib_value: %llu", + i, cpas_core->ahb_bus_client.common_data + .bw_pair[i].ab, cpas_core->ahb_bus_client + .common_data.bw_pair[i].ib); + } + } count = of_property_count_strings(of_node, "client-names"); if (count <= 0) { @@ -661,9 +844,6 @@ int cam_cpas_get_custom_dt_info(struct cam_hw_info *cpas_hw, goto cleanup_tree; } - of_property_read_u32(of_node, "qcom,cx-ipeak-gpu-limit", - &soc_private->cx_ipeak_gpu_limit); - return 0; cleanup_tree: diff --git a/drivers/cam_cpas/cam_cpas_soc.h b/drivers/cam_cpas/cam_cpas_soc.h index c1e65803a..e7f0628d8 100644 --- a/drivers/cam_cpas/cam_cpas_soc.h +++ b/drivers/cam_cpas/cam_cpas_soc.h @@ -6,7 +6,6 @@ #ifndef _CAM_CPAS_SOC_H_ #define _CAM_CPAS_SOC_H_ -#include #include "cam_soc_util.h" #include "cam_cpas_hw.h" @@ -92,6 +91,7 @@ struct cam_cpas_feature_info { * * @arch_compat: ARCH compatible string * @client_id_based: Whether clients are id based + * @bus_icc_based: Interconnect based bus interaction * @num_clients: Number of clients supported * @client_name: Client names * @tree_node: Array of pointers to all tree nodes required to calculate @@ -107,8 +107,6 @@ struct cam_cpas_feature_info { * @camnoc_axi_min_ib_bw: Min camnoc BW which varies based on target * @num_feature_entries: number of feature entries * @feature_info: fuse based feature info for hw supported features - * @cx_ipeak_gpu_limit: Flag for Cx Ipeak GPU mitigation - * @gpu_pwr_limit: Handle for Cx Ipeak GPU Mitigation * @custom_id: Custom id to differentiate between target if * cpas version is same * @@ -116,6 +114,7 @@ struct cam_cpas_feature_info { struct cam_cpas_private_soc { const char *arch_compat; bool client_id_based; + bool bus_icc_based; uint32_t num_clients; const char *client_name[CAM_CPAS_MAX_CLIENTS]; struct cam_cpas_tree_node *tree_node[CAM_CPAS_MAX_TREE_NODES]; @@ -129,8 +128,6 @@ struct cam_cpas_private_soc { uint64_t camnoc_axi_min_ib_bw; uint32_t num_feature_entries; struct cam_cpas_feature_info feature_info[CAM_CPAS_MAX_FUSE_FEATURE]; - uint32_t cx_ipeak_gpu_limit; - struct kgsl_pwr_limit *gpu_pwr_limit; uint32_t custom_id; }; diff --git a/drivers/cam_cpas/camss_top/Makefile b/drivers/cam_cpas/camss_top/Makefile deleted file mode 100644 index de11b7136..000000000 --- a/drivers/cam_cpas/camss_top/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_camsstop_hw.o diff --git a/drivers/cam_cpas/cpas_top/Makefile b/drivers/cam_cpas/cpas_top/Makefile deleted file mode 100644 index 6cce35859..000000000 --- a/drivers/cam_cpas/cpas_top/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cpastop_hw.o diff --git a/drivers/cam_cpas/cpas_top/cam_cpastop_hw.c b/drivers/cam_cpas/cpas_top/cam_cpastop_hw.c index c8d96bd36..402494005 100644 --- a/drivers/cam_cpas/cpas_top/cam_cpastop_hw.c +++ b/drivers/cam_cpas/cpas_top/cam_cpastop_hw.c @@ -7,8 +7,7 @@ #include #include -#include - +#include "cam_compat.h" #include "cam_cpas_hw_intf.h" #include "cam_cpas_hw.h" #include "cam_cpastop_hw.h" @@ -538,7 +537,7 @@ static irqreturn_t cam_cpastop_handle_irq(int irq_num, void *data) static int cam_cpastop_poweron(struct cam_hw_info *cpas_hw) { - int i, reg_val; + int i; struct cam_cpas_hw_errata_wa_list *errata_wa_list = camnoc_info->errata_wa_list; struct cam_cpas_hw_errata_wa *errata_wa; @@ -565,11 +564,8 @@ static int cam_cpastop_poweron(struct cam_hw_info *cpas_hw) if (errata_wa_list) { errata_wa = &errata_wa_list->tcsr_camera_hf_sf_ares_glitch; - if (errata_wa->enable) { - reg_val = scm_io_read(errata_wa->data.reg_info.offset); - reg_val |= errata_wa->data.reg_info.value; - scm_io_write(errata_wa->data.reg_info.offset, reg_val); - } + if (errata_wa->enable) + cam_cpastop_scm_write(errata_wa); } return 0; diff --git a/drivers/cam_cust/Makefile b/drivers/cam_cust/Makefile deleted file mode 100644 index 732b9593c..000000000 --- a/drivers/cam_cust/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_custom_hw_mgr/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_custom_dev.o cam_custom_context.o diff --git a/drivers/cam_cust/cam_custom_context.h b/drivers/cam_cust/cam_custom_context.h index 27268b20c..e2812ad38 100644 --- a/drivers/cam_cust/cam_custom_context.h +++ b/drivers/cam_cust/cam_custom_context.h @@ -6,9 +6,10 @@ #ifndef _CAM_CUSTOM_CONTEXT_H_ #define _CAM_CUSTOM_CONTEXT_H_ -#include -#include -#include +#include + +#include +#include #include "cam_context.h" #include "cam_custom_hw_mgr_intf.h" diff --git a/drivers/cam_cust/cam_custom_dev.c b/drivers/cam_cust/cam_custom_dev.c index 76d4a7d0e..f36e5ad27 100644 --- a/drivers/cam_cust/cam_custom_dev.c +++ b/drivers/cam_cust/cam_custom_dev.c @@ -12,7 +12,8 @@ #include #include -#include +#include + #include "cam_custom_dev.h" #include "cam_hw_mgr_intf.h" #include "cam_custom_hw_mgr_intf.h" @@ -182,17 +183,15 @@ static struct platform_driver custom_driver = { }, }; -static int __init cam_custom_dev_init_module(void) +int cam_custom_dev_init_module(void) { return platform_driver_register(&custom_driver); } -static void __exit cam_custom_dev_exit_module(void) +void cam_custom_dev_exit_module(void) { platform_driver_unregister(&custom_driver); } -module_init(cam_custom_dev_init_module); -module_exit(cam_custom_dev_exit_module); MODULE_DESCRIPTION("MSM CUSTOM driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_cust/cam_custom_dev.h b/drivers/cam_cust/cam_custom_dev.h index 77ea6badf..7f8fa9800 100644 --- a/drivers/cam_cust/cam_custom_dev.h +++ b/drivers/cam_cust/cam_custom_dev.h @@ -31,4 +31,14 @@ struct cam_custom_dev { int32_t open_cnt; }; +/** + * @brief : API to register Custom hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_custom_dev_init_module(void); + +/** + * @brief : API to remove Custom hw interface from platform framework. + */ +void cam_custom_dev_exit_module(void); #endif /* _CAM_CUSTOM_DEV_H_ */ diff --git a/drivers/cam_cust/cam_custom_hw_mgr/Makefile b/drivers/cam_cust/cam_custom_hw_mgr/Makefile deleted file mode 100644 index 1e0917637..000000000 --- a/drivers/cam_cust/cam_custom_hw_mgr/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_custom_hw1/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_custom_hw1/ cam_custom_csid/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_custom_hw_mgr.o - diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/Makefile b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/Makefile deleted file mode 100644 index ab36c8862..000000000 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_custom_csid_dev.o diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.c b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.c index be472372a..ca592a60f 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.c +++ b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.c @@ -152,7 +152,7 @@ static struct platform_driver cam_custom_csid_driver = { .remove = cam_custom_csid_remove, }; -static int __init cam_custom_csid_driver_init(void) +int cam_custom_csid_driver_init(void) { int32_t rc = 0; @@ -179,12 +179,10 @@ int cam_custom_csid_hw_init(struct cam_hw_intf **custom_csid_hw, return rc; } -static void __exit cam_custom_csid_driver_exit(void) +void cam_custom_csid_driver_exit(void) { platform_driver_unregister(&cam_custom_csid_driver); } -module_init(cam_custom_csid_driver_init); -module_exit(cam_custom_csid_driver_exit); MODULE_DESCRIPTION("cam_custom_csid_driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.h b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.h index f0c086cca..506469f76 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.h +++ b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_csid/cam_custom_csid_dev.h @@ -3,10 +3,21 @@ * Copyright (c) 2019, The Linux Foundation. All rights reserved. */ -#ifndef _CAM_IFE_CSID_DEV_H_ -#define _CAM_IFE_CSID_DEV_H_ +#ifndef _CAM_CUSTOM_CSID_DEV_H_ +#define _CAM_CUSTOM_CSID_DEV_H_ #include "cam_debug_util.h" #include "cam_custom_hw_mgr_intf.h" -#endif /*_CAM_IFE_CSID_DEV_H_ */ +/** + * @brief : API to register Custom CSID hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_custom_csid_driver_init(void); + +/** + * @brief : API to remove Custom CSID hw interface from platform framework. + */ +void cam_custom_csid_driver_exit(void); + +#endif /*_CAM_CUSTOM_CSID_DEV_H_ */ diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/Makefile b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/Makefile deleted file mode 100644 index 4895219ff..000000000 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1 - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_custom_sub_mod_soc.o cam_custom_sub_mod_dev.o cam_custom_sub_mod_core.o diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.c b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.c index bd7d65913..2a13e4979 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.c +++ b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.c @@ -146,17 +146,15 @@ static struct platform_driver cam_custom_hw_sub_mod_driver = { }, }; -static int __init cam_custom_hw_sub_module_init(void) +int cam_custom_hw_sub_module_init(void) { return platform_driver_register(&cam_custom_hw_sub_mod_driver); } -static void __exit cam_custom_hw_sub_module_exit(void) +void cam_custom_hw_sub_module_exit(void) { platform_driver_unregister(&cam_custom_hw_sub_mod_driver); } -module_init(cam_custom_hw_sub_module_init); -module_exit(cam_custom_hw_sub_module_exit); MODULE_DESCRIPTION("CAM CUSTOM HW SUB MODULE driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.h b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.h index 1da630ed5..4b9af3656 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.h +++ b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw1/cam_custom_sub_mod_dev.h @@ -12,4 +12,14 @@ #define CAM_CUSTOM_SUB_MOD_MAX_INSTANCES 2 +/** + * @brief : API to register Custom submodule to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_custom_hw_sub_module_init(void); + +/** + * @brief : API to remove Custom submodule interface from platform framework. + */ +void cam_custom_hw_sub_module_exit(void); #endif /* _CAM_CUSTOM_SUB_MOD_DEV_H_ */ diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c index 2fed429ad..7587e41aa 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c +++ b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.c @@ -7,9 +7,11 @@ #include #include #include -#include -#include + +#include #include + +#include "cam_compat.h" #include "cam_sync_api.h" #include "cam_smmu_api.h" #include "cam_req_mgr_workq.h" diff --git a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.h b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.h index 64f455552..4a9b27be7 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.h +++ b/drivers/cam_cust/cam_custom_hw_mgr/cam_custom_hw_mgr.h @@ -12,8 +12,9 @@ #include "cam_ife_csid_hw_intf.h" #include "cam_isp_hw.h" #include "cam_custom_hw.h" -#include -#include + +#include +#include enum cam_custom_hw_mgr_res_type { CAM_CUSTOM_HW_SUB_MODULE, diff --git a/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw.h b/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw.h index 0fd557c14..c1d6a258c 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw.h +++ b/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw.h @@ -9,7 +9,8 @@ #include #include #include -#include + +#include enum cam_custom_hw_resource_state { CAM_CUSTOM_HW_RESOURCE_STATE_UNAVAILABLE = 0, diff --git a/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw_mgr_intf.h b/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw_mgr_intf.h index b1fb1cb42..0577cd6ef 100644 --- a/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw_mgr_intf.h +++ b/drivers/cam_cust/cam_custom_hw_mgr/include/cam_custom_hw_mgr_intf.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "cam_hw.h" #include "cam_hw_mgr_intf.h" #include "cam_hw_intf.h" diff --git a/drivers/cam_fd/Makefile b/drivers/cam_fd/Makefile deleted file mode 100644 index 92356a35d..000000000 --- a/drivers/cam_fd/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd/fd_hw_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd/fd_hw_mgr/fd_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += fd_hw_mgr/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd_dev.o cam_fd_context.o diff --git a/drivers/cam_fd/cam_fd_dev.c b/drivers/cam_fd/cam_fd_dev.c index f492696ae..9709f88d0 100644 --- a/drivers/cam_fd/cam_fd_dev.c +++ b/drivers/cam_fd/cam_fd_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -196,17 +196,15 @@ static struct platform_driver cam_fd_driver = { }, }; -static int __init cam_fd_dev_init_module(void) +int cam_fd_dev_init_module(void) { return platform_driver_register(&cam_fd_driver); } -static void __exit cam_fd_dev_exit_module(void) +void cam_fd_dev_exit_module(void) { platform_driver_unregister(&cam_fd_driver); } -module_init(cam_fd_dev_init_module); -module_exit(cam_fd_dev_exit_module); MODULE_DESCRIPTION("MSM FD driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_fd/cam_fd_dev.h b/drivers/cam_fd/cam_fd_dev.h new file mode 100644 index 000000000..74db41b8d --- /dev/null +++ b/drivers/cam_fd/cam_fd_dev.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#ifndef _CAM_FD_DEV_H_ +#define _CAM_FD_DEV_H_ + +/** + * @brief : API to register FD Dev to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_fd_dev_init_module(void); + +/** + * @brief : API to remove FD Dev interface from platform framework. + */ +void cam_fd_dev_exit_module(void); + +#endif /* _CAM_FD_DEV_H_ */ diff --git a/drivers/cam_fd/fd_hw_mgr/Makefile b/drivers/cam_fd/fd_hw_mgr/Makefile deleted file mode 100644 index 8db809767..000000000 --- a/drivers/cam_fd/fd_hw_mgr/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd/fd_hw_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd/fd_hw_mgr/fd_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += fd_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd_hw_mgr.o diff --git a/drivers/cam_fd/fd_hw_mgr/fd_hw/Makefile b/drivers/cam_fd/fd_hw_mgr/fd_hw/Makefile deleted file mode 100644 index 6a53cc67f..000000000 --- a/drivers/cam_fd/fd_hw_mgr/fd_hw/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd/fd_hw_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_fd/fd_hw_mgr/fd_hw -ccflags-y += -I$(srctree)/techpack/camera -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_fd_hw_dev.o cam_fd_hw_core.o cam_fd_hw_soc.o diff --git a/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.c b/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.c index 7a4237951..37db17e5a 100644 --- a/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.c +++ b/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_dev.c @@ -220,17 +220,15 @@ static struct platform_driver cam_fd_hw_driver = { }, }; -static int __init cam_fd_hw_init_module(void) +int cam_fd_hw_init_module(void) { return platform_driver_register(&cam_fd_hw_driver); } -static void __exit cam_fd_hw_exit_module(void) +void cam_fd_hw_exit_module(void) { platform_driver_unregister(&cam_fd_hw_driver); } -module_init(cam_fd_hw_init_module); -module_exit(cam_fd_hw_exit_module); MODULE_DESCRIPTION("CAM FD HW driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_intf.h b/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_intf.h index 85ec6fa39..7d318b2e2 100644 --- a/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_intf.h +++ b/drivers/cam_fd/fd_hw_mgr/fd_hw/cam_fd_hw_intf.h @@ -313,4 +313,15 @@ struct cam_fd_hw_dump_header { uint32_t word_size; }; +/** + * @brief : API to register FD Hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_fd_hw_init_module(void); + +/** + * @brief : API to remove FD Hw interface from platform framework. + */ +void cam_fd_hw_exit_module(void); + #endif /* _CAM_FD_HW_INTF_H_ */ diff --git a/drivers/cam_icp/Makefile b/drivers/cam_icp/Makefile deleted file mode 100644 index aec65fc06..000000000 --- a/drivers/cam_icp/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/fw_inc -ccflags-y += -I$(srctree)/techpack/camera -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ - -obj-$(CONFIG_SPECTRA_CAMERA) += icp_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_icp_subdev.o cam_icp_context.o hfi.o diff --git a/drivers/cam_icp/cam_icp_subdev.c b/drivers/cam_icp/cam_icp_subdev.c index 128b171f8..8c7eacb02 100644 --- a/drivers/cam_icp/cam_icp_subdev.c +++ b/drivers/cam_icp/cam_icp_subdev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -263,16 +263,15 @@ static struct platform_driver cam_icp_driver = { }, }; -static int __init cam_icp_init_module(void) +int cam_icp_init_module(void) { return platform_driver_register(&cam_icp_driver); } -static void __exit cam_icp_exit_module(void) +void cam_icp_exit_module(void) { platform_driver_unregister(&cam_icp_driver); } -module_init(cam_icp_init_module); -module_exit(cam_icp_exit_module); + MODULE_DESCRIPTION("MSM ICP driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_icp/cam_icp_subdev.h b/drivers/cam_icp/cam_icp_subdev.h new file mode 100644 index 000000000..af38e26a2 --- /dev/null +++ b/drivers/cam_icp/cam_icp_subdev.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#ifndef _CAM_ICP_SUBDEV_H_ +#define _CAM_ICP_SUBDEV_H_ + +/** + * @brief : API to register ICP subdev to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_icp_init_module(void); + +/** + * @brief : API to remove ICP subdev from platform framework. + */ +void cam_icp_exit_module(void); + +#endif /* _CAM_ICP_SUBDEV_H_ */ diff --git a/drivers/cam_icp/hfi.c b/drivers/cam_icp/hfi.c index 89a95aca6..ea08cc24f 100644 --- a/drivers/cam_icp/hfi.c +++ b/drivers/cam_icp/hfi.c @@ -19,6 +19,7 @@ #include "hfi_intf.h" #include "cam_icp_hw_mgr_intf.h" #include "cam_debug_util.h" +#include "cam_compat.h" #define HFI_VERSION_INFO_MAJOR_VAL 1 #define HFI_VERSION_INFO_MINOR_VAL 1 @@ -947,7 +948,7 @@ void cam_hfi_deinit(void __iomem *icp_base) g_hfi->cmd_q_state = false; g_hfi->msg_q_state = false; - kzfree(g_hfi); + cam_free_clear((void *)g_hfi); g_hfi = NULL; err: diff --git a/drivers/cam_icp/icp_hw/Makefile b/drivers/cam_icp/icp_hw/Makefile deleted file mode 100644 index 68b36f706..000000000 --- a/drivers/cam_icp/icp_hw/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += icp_hw_mgr/ a5_hw/ ipe_hw/ bps_hw/ diff --git a/drivers/cam_icp/icp_hw/a5_hw/Makefile b/drivers/cam_icp/icp_hw/a5_hw/Makefile deleted file mode 100644 index 9c3aac09a..000000000 --- a/drivers/cam_icp/icp_hw/a5_hw/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/a5_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/fw_inc -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += a5_dev.o a5_core.o a5_soc.o diff --git a/drivers/cam_icp/icp_hw/a5_hw/a5_core.h b/drivers/cam_icp/icp_hw/a5_hw/a5_core.h index 6c46b3ac8..f6edebbc3 100644 --- a/drivers/cam_icp/icp_hw/a5_hw/a5_core.h +++ b/drivers/cam_icp/icp_hw/a5_hw/a5_core.h @@ -80,4 +80,15 @@ int cam_a5_process_cmd(void *device_priv, uint32_t cmd_type, void *cmd_args, uint32_t arg_size); irqreturn_t cam_a5_irq(int irq_num, void *data); + +/** + * @brief : API to register a5 hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_a5_init_module(void); + +/** + * @brief : API to remove a5 hw from platform framework. + */ +void cam_a5_exit_module(void); #endif /* CAM_A5_CORE_H */ diff --git a/drivers/cam_icp/icp_hw/a5_hw/a5_dev.c b/drivers/cam_icp/icp_hw/a5_hw/a5_dev.c index b4f33d3e4..ea1a8bb91 100644 --- a/drivers/cam_icp/icp_hw/a5_hw/a5_dev.c +++ b/drivers/cam_icp/icp_hw/a5_hw/a5_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -212,17 +212,15 @@ static struct platform_driver cam_a5_driver = { }, }; -static int __init cam_a5_init_module(void) +int cam_a5_init_module(void) { return platform_driver_register(&cam_a5_driver); } -static void __exit cam_a5_exit_module(void) +void cam_a5_exit_module(void) { platform_driver_unregister(&cam_a5_driver); } -module_init(cam_a5_init_module); -module_exit(cam_a5_exit_module); MODULE_DESCRIPTION("CAM A5 driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_icp/icp_hw/bps_hw/Makefile b/drivers/cam_icp/icp_hw/bps_hw/Makefile deleted file mode 100644 index 491e6a164..000000000 --- a/drivers/cam_icp/icp_hw/bps_hw/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/bps_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/fw_inc -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += bps_dev.o bps_core.o bps_soc.o diff --git a/drivers/cam_icp/icp_hw/bps_hw/bps_core.h b/drivers/cam_icp/icp_hw/bps_hw/bps_core.h index 162c5e655..f7577c36d 100644 --- a/drivers/cam_icp/icp_hw/bps_hw/bps_core.h +++ b/drivers/cam_icp/icp_hw/bps_hw/bps_core.h @@ -36,4 +36,15 @@ int cam_bps_process_cmd(void *device_priv, uint32_t cmd_type, void *cmd_args, uint32_t arg_size); irqreturn_t cam_bps_irq(int irq_num, void *data); + +/** + * @brief : API to register BPS hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_bps_init_module(void); + +/** + * @brief : API to remove BPS Hw from platform framework. + */ +void cam_bps_exit_module(void); #endif /* CAM_BPS_CORE_H */ diff --git a/drivers/cam_icp/icp_hw/bps_hw/bps_dev.c b/drivers/cam_icp/icp_hw/bps_hw/bps_dev.c index a80c27325..e2ebd76b5 100644 --- a/drivers/cam_icp/icp_hw/bps_hw/bps_dev.c +++ b/drivers/cam_icp/icp_hw/bps_hw/bps_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -24,7 +24,6 @@ static struct cam_bps_device_hw_info cam_bps_hw_info = { .pwr_status = 0x58, .reserved = 0, }; -EXPORT_SYMBOL(cam_bps_hw_info); static char bps_dev_name[8]; @@ -191,17 +190,15 @@ static struct platform_driver cam_bps_driver = { }, }; -static int __init cam_bps_init_module(void) +int cam_bps_init_module(void) { return platform_driver_register(&cam_bps_driver); } -static void __exit cam_bps_exit_module(void) +void cam_bps_exit_module(void) { platform_driver_unregister(&cam_bps_driver); } -module_init(cam_bps_init_module); -module_exit(cam_bps_exit_module); MODULE_DESCRIPTION("CAM BPS driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_icp/icp_hw/icp_hw_mgr/Makefile b/drivers/cam_icp/icp_hw/icp_hw_mgr/Makefile deleted file mode 100644 index b87d5dba8..000000000 --- a/drivers/cam_icp/icp_hw/icp_hw_mgr/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/isp/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/isp/isp_hw/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/isp/isp_hw/isp_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/fw_inc/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/include/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/a5_hw/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_icp_hw_mgr.o diff --git a/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c b/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c index f0bf17855..8bd370557 100644 --- a/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c +++ b/drivers/cam_icp/icp_hw/icp_hw_mgr/cam_icp_hw_mgr.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -1823,80 +1823,41 @@ DEFINE_SIMPLE_ATTRIBUTE(cam_icp_debug_fw_dump, cam_icp_get_a5_fw_dump_lvl, static int cam_icp_hw_mgr_create_debugfs_entry(void) { int rc = 0; + struct dentry *dbgfileptr = NULL; - icp_hw_mgr.dentry = debugfs_create_dir("camera_icp", NULL); - if (!icp_hw_mgr.dentry) - return -ENOMEM; - - if (!debugfs_create_bool("icp_pc", - 0644, - icp_hw_mgr.dentry, - &icp_hw_mgr.icp_pc_flag)) { - CAM_ERR(CAM_ICP, "failed to create icp_pc entry"); - rc = -ENOMEM; - goto err; + dbgfileptr = debugfs_create_dir("camera_icp", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_ICP,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + icp_hw_mgr.dentry = dbgfileptr; - if (!debugfs_create_bool("ipe_bps_pc", - 0644, - icp_hw_mgr.dentry, - &icp_hw_mgr.ipe_bps_pc_flag)) { - CAM_ERR(CAM_ICP, "failed to create ipe_bps_pc entry"); - rc = -ENOMEM; - goto err; - } + debugfs_create_bool("icp_pc", 0644, icp_hw_mgr.dentry, + &icp_hw_mgr.icp_pc_flag); - if (!debugfs_create_file("icp_debug_clk", - 0644, - icp_hw_mgr.dentry, NULL, - &cam_icp_debug_default_clk)) { - CAM_ERR(CAM_ICP, "failed to create icp_debug_clk entry"); - rc = -ENOMEM; - goto err; - } + debugfs_create_bool("ipe_bps_pc", 0644, icp_hw_mgr.dentry, + &icp_hw_mgr.ipe_bps_pc_flag); - if (!debugfs_create_bool("a5_jtag_debug", - 0644, - icp_hw_mgr.dentry, - &icp_hw_mgr.a5_jtag_debug)) { - rc = -ENOMEM; - goto err; - } + debugfs_create_file("icp_debug_clk", 0644, + icp_hw_mgr.dentry, NULL, &cam_icp_debug_default_clk); - if (!debugfs_create_file("a5_debug_type", - 0644, - icp_hw_mgr.dentry, - NULL, &cam_icp_debug_type_fs)) { - CAM_ERR(CAM_ICP, "failed to create a5_debug_type"); - rc = -ENOMEM; - goto err; - } + debugfs_create_bool("a5_jtag_debug", 0644, + icp_hw_mgr.dentry, &icp_hw_mgr.a5_jtag_debug); - if (!debugfs_create_file("a5_debug_lvl", - 0644, - icp_hw_mgr.dentry, - NULL, &cam_icp_debug_fs)) { - CAM_ERR(CAM_ICP, "failed to create a5_dbg_lvl"); - rc = -ENOMEM; - goto err; - } + debugfs_create_file("a5_debug_type", 0644, + icp_hw_mgr.dentry, NULL, &cam_icp_debug_type_fs); - if (!debugfs_create_file("a5_fw_dump_lvl", - 0644, - icp_hw_mgr.dentry, - NULL, &cam_icp_debug_fw_dump)) { - CAM_ERR(CAM_ICP, "failed to create a5_fw_dump_lvl"); - rc = -ENOMEM; - goto err; - } + debugfs_create_file("a5_debug_lvl", 0644, + icp_hw_mgr.dentry, NULL, &cam_icp_debug_fs); + debugfs_create_file("a5_fw_dump_lvl", 0644, + icp_hw_mgr.dentry, NULL, &cam_icp_debug_fw_dump); +end: /* Set default hang dump lvl */ icp_hw_mgr.a5_fw_dump_lvl = HFI_FW_DUMP_ON_FAILURE; return rc; -err: - debugfs_remove_recursive(icp_hw_mgr.dentry); - icp_hw_mgr.dentry = NULL; - return rc; } static int cam_icp_mgr_process_cmd(void *priv, void *data) diff --git a/drivers/cam_icp/icp_hw/ipe_hw/Makefile b/drivers/cam_icp/icp_hw/ipe_hw/Makefile deleted file mode 100644 index d57373c33..000000000 --- a/drivers/cam_icp/icp_hw/ipe_hw/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/icp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/icp_hw/ipe_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_icp/fw_inc -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += ipe_dev.o ipe_core.o ipe_soc.o diff --git a/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.h b/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.h index 1a15e9233..c02ad58e3 100644 --- a/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.h +++ b/drivers/cam_icp/icp_hw/ipe_hw/ipe_core.h @@ -36,4 +36,14 @@ int cam_ipe_process_cmd(void *device_priv, uint32_t cmd_type, void *cmd_args, uint32_t arg_size); irqreturn_t cam_ipe_irq(int irq_num, void *data); +/** + * @brief : API to register IPE hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_ipe_init_module(void); + +/** + * @brief : API to remove IPE Hw from platform framework. + */ +void cam_ipe_exit_module(void); #endif /* CAM_IPE_CORE_H */ diff --git a/drivers/cam_icp/icp_hw/ipe_hw/ipe_dev.c b/drivers/cam_icp/icp_hw/ipe_hw/ipe_dev.c index 0390488d9..c6c34f27c 100644 --- a/drivers/cam_icp/icp_hw/ipe_hw/ipe_dev.c +++ b/drivers/cam_icp/icp_hw/ipe_hw/ipe_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -32,7 +32,6 @@ static struct cam_ipe_device_hw_info cam_ipe_hw_info[] = { .reserved = 0, }, }; -EXPORT_SYMBOL(cam_ipe_hw_info); static char ipe_dev_name[8]; @@ -183,17 +182,15 @@ static struct platform_driver cam_ipe_driver = { }, }; -static int __init cam_ipe_init_module(void) +int cam_ipe_init_module(void) { return platform_driver_register(&cam_ipe_driver); } -static void __exit cam_ipe_exit_module(void) +void cam_ipe_exit_module(void) { platform_driver_unregister(&cam_ipe_driver); } -module_init(cam_ipe_init_module); -module_exit(cam_ipe_exit_module); MODULE_DESCRIPTION("CAM IPE driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/Makefile b/drivers/cam_isp/Makefile deleted file mode 100644 index 86ad96d61..000000000 --- a/drivers/cam_isp/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm/ - -obj-$(CONFIG_SPECTRA_CAMERA) += isp_hw_mgr/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_isp_dev.o cam_isp_context.o diff --git a/drivers/cam_isp/cam_isp_context.c b/drivers/cam_isp/cam_isp_context.c index f3da6ad1c..87cb3e794 100644 --- a/drivers/cam_isp/cam_isp_context.c +++ b/drivers/cam_isp/cam_isp_context.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -3221,7 +3222,7 @@ static int __cam_isp_ctx_rdi_only_sof_in_bubble_state( static int __cam_isp_ctx_rdi_only_reg_upd_in_bubble_applied_state( struct cam_isp_context *ctx_isp, void *evt_data) { - struct cam_ctx_request *req; + struct cam_ctx_request *req = NULL; struct cam_context *ctx = ctx_isp->base; struct cam_isp_ctx_req *req_isp; struct cam_req_mgr_trigger_notify notify; @@ -4985,34 +4986,32 @@ static int cam_isp_context_dump_active_request(void *data, unsigned long iova, static int cam_isp_context_debug_register(void) { - isp_ctx_debug.dentry = debugfs_create_dir("camera_isp_ctx", - NULL); + int rc = 0; + struct dentry *dbgfileptr = NULL; - if (!isp_ctx_debug.dentry) { - CAM_ERR(CAM_ISP, "failed to create dentry"); - return -ENOMEM; + dbgfileptr = debugfs_create_dir("camera_isp_ctx", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_ICP,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + isp_ctx_debug.dentry = dbgfileptr; - if (!debugfs_create_u32("enable_state_monitor_dump", - 0644, - isp_ctx_debug.dentry, - &isp_ctx_debug.enable_state_monitor_dump)) { - CAM_ERR(CAM_ISP, "failed to create enable_state_monitor_dump"); - goto err; - } + debugfs_create_u32("enable_state_monitor_dump", 0644, + isp_ctx_debug.dentry, &isp_ctx_debug.enable_state_monitor_dump); - if (!debugfs_create_u32("enable_cdm_cmd_buffer_dump", - 0644, - isp_ctx_debug.dentry, - &isp_ctx_debug.enable_cdm_cmd_buff_dump)) { - CAM_ERR(CAM_ISP, "failed to create enable_cdm_cmd_buffer_dump"); - goto err; - } + debugfs_create_u8("enable_cdm_cmd_buffer_dump", 0644, + isp_ctx_debug.dentry, &isp_ctx_debug.enable_cdm_cmd_buff_dump); - return 0; -err: - debugfs_remove_recursive(isp_ctx_debug.dentry); - return -ENOMEM; + if (IS_ERR(dbgfileptr)) { + if (PTR_ERR(dbgfileptr) == -ENODEV) + CAM_WARN(CAM_ICP, "DebugFS not enabled in kernel!"); + else + rc = PTR_ERR(dbgfileptr); + } +end: + return rc; } int cam_isp_context_init(struct cam_isp_context *ctx, diff --git a/drivers/cam_isp/cam_isp_context.h b/drivers/cam_isp/cam_isp_context.h index 72d35cb7e..0541fd54c 100644 --- a/drivers/cam_isp/cam_isp_context.h +++ b/drivers/cam_isp/cam_isp_context.h @@ -1,13 +1,14 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_ISP_CONTEXT_H_ #define _CAM_ISP_CONTEXT_H_ -#include +#include #include #include #include @@ -118,7 +119,7 @@ enum cam_isp_state_change_trigger { struct cam_isp_ctx_debug { struct dentry *dentry; uint32_t enable_state_monitor_dump; - uint32_t enable_cdm_cmd_buff_dump; + uint8_t enable_cdm_cmd_buff_dump; }; /** diff --git a/drivers/cam_isp/cam_isp_dev.c b/drivers/cam_isp/cam_isp_dev.c index b08956ef9..12b8fff8f 100644 --- a/drivers/cam_isp/cam_isp_dev.c +++ b/drivers/cam_isp/cam_isp_dev.c @@ -236,17 +236,15 @@ static struct platform_driver isp_driver = { }, }; -static int __init cam_isp_dev_init_module(void) +int cam_isp_dev_init_module(void) { return platform_driver_register(&isp_driver); } -static void __exit cam_isp_dev_exit_module(void) +void cam_isp_dev_exit_module(void) { platform_driver_unregister(&isp_driver); } -module_init(cam_isp_dev_init_module); -module_exit(cam_isp_dev_exit_module); MODULE_DESCRIPTION("MSM ISP driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/cam_isp_dev.h b/drivers/cam_isp/cam_isp_dev.h index 5ba338f77..53d126c31 100644 --- a/drivers/cam_isp/cam_isp_dev.h +++ b/drivers/cam_isp/cam_isp_dev.h @@ -32,4 +32,14 @@ struct cam_isp_dev { int32_t max_context; }; +/** + * @brief : API to register ISP Dev to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_isp_dev_init_module(void); + +/** + * @brief : API to remove ISP Dev from platform framework. + */ +void cam_isp_dev_exit_module(void); #endif /* __CAM_ISP_DEV_H__ */ diff --git a/drivers/cam_isp/isp_hw_mgr/Makefile b/drivers/cam_isp/isp_hw_mgr/Makefile deleted file mode 100644 index 52ec0dbe2..000000000 --- a/drivers/cam_isp/isp_hw_mgr/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(src) - -obj-$(CONFIG_SPECTRA_CAMERA) += hw_utils/ isp_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_isp_hw_mgr.o - -ifdef CONFIG_SPECTRA_CAMERA_TFE -obj-$(CONFIG_SPECTRA_CAMERA) += cam_tfe_hw_mgr.o -endif - -ifdef CONFIG_SPECTRA_CAMERA_IFE -obj-$(CONFIG_SPECTRA_CAMERA) += cam_ife_hw_mgr.o -endif diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c index c822b22a7..5596f1636 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c @@ -7,8 +7,10 @@ #include #include #include -#include -#include + +#include + +#include "cam_compat.h" #include "cam_smmu_api.h" #include "cam_req_mgr_workq.h" #include "cam_isp_hw_mgr_intf.h" @@ -26,8 +28,6 @@ #define CAM_IFE_HW_ENTRIES_MAX 20 -#define TZ_SVC_SMMU_PROGRAM 0x15 -#define TZ_SAFE_SYSCALL_ID 0x3 #define CAM_IFE_SAFE_DISABLE 0 #define CAM_IFE_SAFE_ENABLE 1 #define SMMU_SE_IFE 0 @@ -174,38 +174,6 @@ static int cam_ife_mgr_handle_reg_dump(struct cam_ife_hw_mgr_ctx *ctx, return rc; } -static int cam_ife_notify_safe_lut_scm(bool safe_trigger) -{ - uint32_t camera_hw_version, rc = 0; - struct scm_desc desc = {0}; - - rc = cam_cpas_get_cpas_hw_version(&camera_hw_version); - if (!rc) { - switch (camera_hw_version) { - case CAM_CPAS_TITAN_170_V100: - case CAM_CPAS_TITAN_170_V110: - case CAM_CPAS_TITAN_175_V100: - - desc.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL); - desc.args[0] = SMMU_SE_IFE; - desc.args[1] = safe_trigger; - - CAM_DBG(CAM_ISP, "Safe scm call %d", safe_trigger); - if (scm_call2(SCM_SIP_FNID(TZ_SVC_SMMU_PROGRAM, - TZ_SAFE_SYSCALL_ID), &desc)) { - CAM_ERR(CAM_ISP, - "scm call to Enable Safe failed"); - rc = -EINVAL; - } - break; - default: - break; - } - } - - return rc; -} - static int cam_ife_mgr_get_hw_caps(void *hw_mgr_priv, void *hw_caps_args) { @@ -2825,7 +2793,7 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args) acquire_args->valid_acquired_hw = acquire_hw_info->num_inputs; - getnstimeofday64(&ife_ctx->ts); + ktime_get_real_ts64(&ife_ctx->ts); CAM_INFO(CAM_ISP, "Acquire HW success with total_pix: %u total_rdi: %u is_dual: %u in ctx: %u", total_pix_port, total_rdi_port, @@ -6903,69 +6871,36 @@ DEFINE_SIMPLE_ATTRIBUTE(cam_ife_camif_debug, static int cam_ife_hw_mgr_debug_register(void) { - g_ife_hw_mgr.debug_cfg.dentry = debugfs_create_dir("camera_ife", - NULL); - - if (!g_ife_hw_mgr.debug_cfg.dentry) { - CAM_ERR(CAM_ISP, "failed to create dentry"); - return -ENOMEM; - } - - if (!debugfs_create_file("ife_csid_debug", - 0644, - g_ife_hw_mgr.debug_cfg.dentry, NULL, - &cam_ife_csid_debug)) { - CAM_ERR(CAM_ISP, "failed to create cam_ife_csid_debug"); - goto err; - } + int rc = 0; + struct dentry *dbgfileptr = NULL; - if (!debugfs_create_u32("enable_recovery", - 0644, - g_ife_hw_mgr.debug_cfg.dentry, - &g_ife_hw_mgr.debug_cfg.enable_recovery)) { - CAM_ERR(CAM_ISP, "failed to create enable_recovery"); - goto err; + dbgfileptr = debugfs_create_dir("camera_ife", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_ISP,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + g_ife_hw_mgr.debug_cfg.dentry = dbgfileptr; - if (!debugfs_create_u32("enable_csid_recovery", - 0644, + debugfs_create_file("ife_csid_debug", 0644, + g_ife_hw_mgr.debug_cfg.dentry, NULL, &cam_ife_csid_debug); + debugfs_create_u32("enable_recovery", 0644, g_ife_hw_mgr.debug_cfg.dentry, + &g_ife_hw_mgr.debug_cfg.enable_recovery); + debugfs_create_u32("enable_csid_recovery", 0644, g_ife_hw_mgr.debug_cfg.dentry, - &g_ife_hw_mgr.debug_cfg.enable_csid_recovery)) { - CAM_ERR(CAM_ISP, "failed to create enable_csid_recovery"); - goto err; - } - - if (!debugfs_create_bool("enable_req_dump", - 0644, + &g_ife_hw_mgr.debug_cfg.enable_csid_recovery); + debugfs_create_bool("enable_req_dump", 0644, g_ife_hw_mgr.debug_cfg.dentry, - &g_ife_hw_mgr.debug_cfg.enable_req_dump)) { - CAM_ERR(CAM_ISP, "failed to create enable_req_dump"); - goto err; - } - - if (!debugfs_create_file("ife_camif_debug", - 0644, - g_ife_hw_mgr.debug_cfg.dentry, NULL, - &cam_ife_camif_debug)) { - CAM_ERR(CAM_ISP, "failed to create cam_ife_camif_debug"); - goto err; - } - - if (!debugfs_create_bool("per_req_reg_dump", - 0644, + &g_ife_hw_mgr.debug_cfg.enable_req_dump); + debugfs_create_file("ife_camif_debug", 0644, + g_ife_hw_mgr.debug_cfg.dentry, NULL, &cam_ife_camif_debug); + debugfs_create_bool("per_req_reg_dump", 0644, g_ife_hw_mgr.debug_cfg.dentry, - &g_ife_hw_mgr.debug_cfg.per_req_reg_dump)) { - CAM_ERR(CAM_ISP, "failed to create per_req_reg_dump entry"); - goto err; - } - + &g_ife_hw_mgr.debug_cfg.per_req_reg_dump); +end: g_ife_hw_mgr.debug_cfg.enable_recovery = 0; - - return 0; - -err: - debugfs_remove_recursive(g_ife_hw_mgr.debug_cfg.dentry); - return -ENOMEM; + return rc; } int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl) @@ -6976,8 +6911,6 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl) struct cam_ife_hw_mgr_ctx *ctx_pool; struct cam_isp_hw_mgr_res *res_list_ife_out; - CAM_DBG(CAM_ISP, "Enter"); - memset(&g_ife_hw_mgr, 0, sizeof(g_ife_hw_mgr)); mutex_init(&g_ife_hw_mgr.ctx_mutex); diff --git a/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h b/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h index 99f665de8..a765c21a2 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h +++ b/drivers/cam_isp/isp_hw_mgr/cam_isp_hw_mgr.h @@ -1,12 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_ISP_HW_MGR_H_ #define _CAM_ISP_HW_MGR_H_ -#include +#include #include "cam_isp_hw_mgr_intf.h" #include "cam_tasklet_util.h" #include "cam_isp_hw.h" diff --git a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c index 8a783915e..4cfdb6063 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c @@ -1,14 +1,15 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include #include #include -#include #include + #include "cam_smmu_api.h" #include "cam_req_mgr_workq.h" #include "cam_isp_hw_mgr_intf.h" @@ -25,6 +26,7 @@ #include "cam_common_util.h" #include "cam_req_mgr_debug.h" #include "cam_trace.h" +#include "cam_compat.h" #define CAM_TFE_HW_ENTRIES_MAX 20 #define CAM_TFE_HW_CONFIG_TIMEOUT 60 @@ -2376,7 +2378,7 @@ static int cam_isp_tfe_blob_bw_update( } end: - kzfree(bw_upd_args); + cam_free_clear((void *)bw_upd_args); bw_upd_args = NULL; return rc; } @@ -5459,82 +5461,59 @@ DEFINE_DEBUGFS_ATTRIBUTE(cam_tfe_camif_debug, cam_tfe_get_camif_debug, cam_tfe_set_camif_debug, "%16llu"); +#if IS_ENABLED(CONFIG_DEBUG_FS) static int cam_tfe_hw_mgr_debug_register(void) { - g_tfe_hw_mgr.debug_cfg.set_tpg_pattern = CAM_TOP_TPG_DEFAULT_PATTERN; - g_tfe_hw_mgr.debug_cfg.dentry = debugfs_create_dir("camera_tfe", - NULL); - - if (!g_tfe_hw_mgr.debug_cfg.dentry) { - CAM_ERR(CAM_ISP, "failed to create dentry"); - return -ENOMEM; - } + int rc = 0; + struct dentry *dbgfileptr = NULL; - if (!debugfs_create_file("tfe_csid_debug", - 0644, - g_tfe_hw_mgr.debug_cfg.dentry, NULL, - &cam_tfe_csid_debug)) { - CAM_ERR(CAM_ISP, "failed to create cam_tfe_csid_debug"); - goto err; + dbgfileptr = debugfs_create_dir("camera_tfe", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_ISP,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + g_tfe_hw_mgr.debug_cfg.dentry = dbgfileptr; + g_tfe_hw_mgr.debug_cfg.set_tpg_pattern = CAM_TOP_TPG_DEFAULT_PATTERN; - if (!debugfs_create_u32("enable_recovery", - 0644, + dbgfileptr = debugfs_create_file("tfe_csid_debug", 0644, + g_tfe_hw_mgr.debug_cfg.dentry, NULL, &cam_tfe_csid_debug); + debugfs_create_u32("enable_recovery", 0644, g_tfe_hw_mgr.debug_cfg.dentry, - &g_tfe_hw_mgr.debug_cfg.enable_recovery)) { - CAM_ERR(CAM_ISP, "failed to create enable_recovery"); - goto err; - } - - if (!debugfs_create_u32("enable_csid_recovery", - 0644, + &g_tfe_hw_mgr.debug_cfg.enable_recovery); + debugfs_create_u32("enable_csid_recovery", 0644, g_tfe_hw_mgr.debug_cfg.dentry, - &g_tfe_hw_mgr.debug_cfg.enable_csid_recovery)) { - CAM_ERR(CAM_ISP, "failed to create enable_csid_recovery"); - goto err; - } - - if (!debugfs_create_u32("set_tpg_pattern", - 0644, + &g_tfe_hw_mgr.debug_cfg.enable_csid_recovery); + debugfs_create_u32("set_tpg_pattern" ,0644, g_tfe_hw_mgr.debug_cfg.dentry, - &g_tfe_hw_mgr.debug_cfg.set_tpg_pattern)) { - CAM_ERR(CAM_ISP, "failed to create set_tpg_pattern"); - goto err; - } - - if (!debugfs_create_u32("enable_reg_dump", - 0644, + &g_tfe_hw_mgr.debug_cfg.set_tpg_pattern); + debugfs_create_u32("enable_reg_dump", 0644, g_tfe_hw_mgr.debug_cfg.dentry, - &g_tfe_hw_mgr.debug_cfg.enable_reg_dump)) { - CAM_ERR(CAM_ISP, "failed to create enable_reg_dump"); - goto err; - } - - if (!debugfs_create_file("tfe_camif_debug", - 0644, - g_tfe_hw_mgr.debug_cfg.dentry, NULL, - &cam_tfe_camif_debug)) { - CAM_ERR(CAM_ISP, "failed to create cam_tfe_camif_debug"); - goto err; - } - - if (!debugfs_create_u32("per_req_reg_dump", - 0644, + &g_tfe_hw_mgr.debug_cfg.enable_reg_dump); + dbgfileptr = debugfs_create_file("tfe_camif_debug", 0644, + g_tfe_hw_mgr.debug_cfg.dentry, NULL, &cam_tfe_camif_debug); + debugfs_create_u32("per_req_reg_dump", 0644, g_tfe_hw_mgr.debug_cfg.dentry, - &g_tfe_hw_mgr.debug_cfg.per_req_reg_dump)) { - CAM_ERR(CAM_ISP, "failed to create per_req_reg_dump entry"); - goto err; + &g_tfe_hw_mgr.debug_cfg.per_req_reg_dump); + if (IS_ERR(dbgfileptr)) { + if (PTR_ERR(dbgfileptr) == -ENODEV) + CAM_WARN(CAM_ISP, "DebugFS not enabled in kernel!"); + else + rc = PTR_ERR(dbgfileptr); } - - +end: g_tfe_hw_mgr.debug_cfg.enable_recovery = 0; - + return rc; +} +#else +static inline int cam_tfe_hw_mgr_debug_register(void) +{ + g_tfe_hw_mgr.debug_cfg.enable_recovery = 0; + CAM_WARN(CAM_ISP, "DebugFS not enabled in kernel"); return 0; - -err: - debugfs_remove_recursive(g_tfe_hw_mgr.debug_cfg.dentry); - return -ENOMEM; } +#endif int cam_tfe_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl) { diff --git a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h index f66ea4052..8f210ea51 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h +++ b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_TFE_HW_MGR_H_ @@ -204,9 +205,9 @@ struct cam_tfe_hw_event_recovery_data { * @iommu_hdl: Iommu handle to be returned * */ +#ifdef CONFIG_SPECTRA_TFE int cam_tfe_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl); - -#ifndef CONFIG_SPECTRA_CAMERA_TFE +#else int cam_tfe_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl) { return 0; diff --git a/drivers/cam_isp/isp_hw_mgr/hw_utils/Makefile b/drivers/cam_isp/isp_hw_mgr/hw_utils/Makefile deleted file mode 100644 index ccdfc05f1..000000000 --- a/drivers/cam_isp/isp_hw_mgr/hw_utils/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_tasklet_util.o cam_isp_packet_parser.o -obj-$(CONFIG_SPECTRA_CAMERA) += irq_controller/ diff --git a/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c b/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c index 356c9a0a8..e7cae5aa5 100644 --- a/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c +++ b/drivers/cam_isp/isp_hw_mgr/hw_utils/cam_tasklet_util.c @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. */ #include -#include +#include #include #include #include diff --git a/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/Makefile b/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/Makefile deleted file mode 100644 index fb595fe8f..000000000 --- a/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_irq_controller.o \ No newline at end of file diff --git a/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c b/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c index 5763939fd..d30067439 100644 --- a/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c +++ b/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller/cam_irq_controller.c @@ -4,7 +4,7 @@ */ #include -#include +#include #include #include diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/Makefile b/drivers/cam_isp/isp_hw_mgr/isp_hw/Makefile deleted file mode 100644 index e5158b69f..000000000 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -obj-$(CONFIG_SPECTRA_CAMERA) += top_tpg/ - -ifdef CONFIG_SPECTRA_CAMERA_TFE -obj-$(CONFIG_SPECTRA_CAMERA) += ppi_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += tfe_csid_hw/ tfe_hw/ -endif - -ifdef CONFIG_SPECTRA_CAMERA_IFE -obj-$(CONFIG_SPECTRA_CAMERA) += ife_csid_hw/ vfe_hw/ -endif diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/Makefile b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/Makefile deleted file mode 100644 index 8ccd9f0b3..000000000 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_ife_csid_dev.o cam_ife_csid_soc.o cam_ife_csid_core.o -obj-$(CONFIG_SPECTRA_CAMERA) += cam_ife_csid17x.o cam_ife_csid_lite17x.o diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid17x.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid17x.c index d88347caa..8e34447f3 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid17x.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid17x.c @@ -70,17 +70,15 @@ static struct platform_driver cam_ife_csid17x_driver = { }, }; -static int __init cam_ife_csid17x_init_module(void) +int cam_ife_csid17x_init_module(void) { return platform_driver_register(&cam_ife_csid17x_driver); } -static void __exit cam_ife_csid17x_exit_module(void) +void cam_ife_csid17x_exit_module(void) { platform_driver_unregister(&cam_ife_csid17x_driver); } -module_init(cam_ife_csid17x_init_module); -module_exit(cam_ife_csid17x_exit_module); MODULE_DESCRIPTION("CAM IFE_CSID17X driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c index 0da6d5117..a472dbcf1 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c @@ -5,8 +5,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -3007,7 +3007,7 @@ static int cam_ife_csid_get_time_stamp( CAM_IFE_CSID_QTIMER_DIV_FACTOR); if (!csid_hw->prev_boot_timestamp) { - get_monotonic_boottime64(&ts); + ktime_get_boottime_ts64(&ts); time_stamp->boot_timestamp = (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.h index 1f8e4d05b..61bd875c1 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_dev.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #ifndef _CAM_IFE_CSID_DEV_H_ @@ -13,4 +13,26 @@ irqreturn_t cam_ife_csid_irq(int irq_num, void *data); int cam_ife_csid_probe(struct platform_device *pdev); int cam_ife_csid_remove(struct platform_device *pdev); +/** + * @brief : API to register CSID hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_ife_csid17x_init_module(void); + +/** + * @brief : API to register CSID Lite hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_ife_csid_lite_init_module(void); + +/** + * @brief : API to remove CSID Hw from platform framework. + */ +void cam_ife_csid17x_exit_module(void); + +/** + * @brief : API to remove CSID Lite Hw from platform framework. + */ +void cam_ife_csid_lite_exit_module(void); + #endif /*_CAM_IFE_CSID_DEV_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite17x.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite17x.c index 07d555b17..2bc6e8ce6 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite17x.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_lite17x.c @@ -47,17 +47,15 @@ static struct platform_driver cam_ife_csid_lite_driver = { }, }; -static int __init cam_ife_csid_lite_init_module(void) +int cam_ife_csid_lite_init_module(void) { return platform_driver_register(&cam_ife_csid_lite_driver); } -static void __exit cam_ife_csid_lite_exit_module(void) +void cam_ife_csid_lite_exit_module(void) { platform_driver_unregister(&cam_ife_csid_lite_driver); } -module_init(cam_ife_csid_lite_init_module); -module_exit(cam_ife_csid_lite_exit_module); MODULE_DESCRIPTION("CAM IFE_CSID_LITE driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h index 4603b20b6..46d8dff63 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h @@ -23,8 +23,8 @@ * @ticks: Qtimer ticks */ struct cam_isp_timestamp { - struct timeval mono_time; - struct timeval vt_time; + struct timespec64 mono_time; + struct timespec64 vt_time; uint64_t ticks; }; diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.c index 7b2f449f2..e41b57bff 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -35,16 +36,15 @@ static struct platform_driver cam_csid_ppi100_driver = { }, }; -static int __init cam_csid_ppi100_init_module(void) +int cam_csid_ppi100_init_module(void) { return platform_driver_register(&cam_csid_ppi100_driver); } -static void __exit cam_csid_ppi100_exit_module(void) +void cam_csid_ppi100_exit_module(void) { platform_driver_unregister(&cam_csid_ppi100_driver); } -module_init(cam_csid_ppi100_init_module); MODULE_DESCRIPTION("CAM CSID_PPI100 driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.h index 8aee24c13..63c7a41e3 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/ppi_hw/cam_csid_ppi100.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2019, 2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_CSID_PPI_100_H_ @@ -22,4 +23,15 @@ static struct cam_csid_ppi_reg_offset cam_csid_ppi_100_reg_offset = { .ppi_spare_addr = 0x1fc, }; +/** + * @brief : API to register PPI Dev to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_csid_ppi100_init_module(void); + +/** + * @brief : API to remove PPI Dev from platform framework. + */ +void cam_csid_ppi100_exit_module(void); + #endif /*_CAM_CSID_PPI_100_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.c index 488431771..0474a6975 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ @@ -37,17 +38,15 @@ static struct platform_driver cam_tfe_csid530_driver = { }, }; -static int __init cam_tfe_csid530_init_module(void) +int cam_tfe_csid530_init_module(void) { return platform_driver_register(&cam_tfe_csid530_driver); } -static void __exit cam_tfe_csid530_exit_module(void) +void cam_tfe_csid530_exit_module(void) { platform_driver_unregister(&cam_tfe_csid530_driver); } -module_init(cam_tfe_csid530_init_module); -module_exit(cam_tfe_csid530_exit_module); MODULE_DESCRIPTION("CAM TFE_CSID530 driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.h index 634c35917..9f15d15ac 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid530.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_TFE_CSID_530_H_ @@ -220,4 +221,7 @@ static struct cam_tfe_csid_reg_offset cam_tfe_csid_530_reg_offset = { }, }; +int cam_tfe_csid530_init_module(void); +void cam_tfe_csid530_exit_module(void); + #endif /*_CAM_TFE_CSID_530_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.c index 510ba0f38..23e77b18b 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_csid_hw/cam_tfe_csid_core.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -17,7 +18,7 @@ #include "cam_debug_util.h" #include "cam_cpas_api.h" #include "cam_isp_hw_mgr_intf.h" -#include +#include #include "cam_subdev.h" #include "cam_tasklet_util.h" @@ -1703,7 +1704,7 @@ static int cam_tfe_csid_get_time_stamp( CAM_TFE_CSID_QTIMER_DIV_FACTOR); if (!csid_hw->prev_boot_timestamp) { - get_monotonic_boottime64(&ts); + ktime_get_boottime_ts64(&ts); time_stamp->boot_timestamp = (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); @@ -3140,7 +3141,7 @@ int cam_tfe_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf, tfe_csid_hw->device_enabled = 0; tfe_csid_hw->hw_info->hw_state = CAM_HW_STATE_POWER_DOWN; - if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_FUSE_ID, + if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_FUSE, csid_idx)) { CAM_INFO(CAM_ISP, "TFE:%d is not supported", csid_idx); @@ -3151,7 +3152,7 @@ int cam_tfe_csid_hw_probe_init(struct cam_hw_intf *csid_hw_intf, CAM_DBG(CAM_ISP, "type %d index %d supported", tfe_csid_hw->hw_intf->hw_type, csid_idx); - if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_PIX_FUSE_ID, + if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_PIX_FUSE, csid_idx)) { pixel_pipe_supported = false; CAM_INFO(CAM_ISP, "TFE:%d PIX path is not supported", diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe.c index 4bafa35e9..c7c9347d0 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -28,17 +29,15 @@ static struct platform_driver cam_tfe_driver = { }, }; -static int __init cam_tfe_init_module(void) +int cam_tfe_init_module(void) { return platform_driver_register(&cam_tfe_driver); } -static void __exit cam_tfe_exit_module(void) +void cam_tfe_exit_module(void) { platform_driver_unregister(&cam_tfe_driver); } -module_init(cam_tfe_init_module); -module_exit(cam_tfe_exit_module); MODULE_DESCRIPTION("CAM TFE driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c index 5618d1ec6..a0464ac78 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -9,6 +10,7 @@ #include #include #include + #include "cam_cdm_util.h" #include "cam_tasklet_util.h" #include "cam_isp_hw_mgr_intf.h" @@ -17,7 +19,8 @@ #include "cam_tfe_bus.h" #include "cam_debug_util.h" #include "cam_cpas_api.h" -#include +#include +#include "cam_compat.h" static const char drv_name[] = "tfe"; @@ -49,10 +52,10 @@ struct cam_tfe_top_priv { axi_vote_control[CAM_TFE_TOP_IN_PORT_MAX]; uint32_t irq_prepared_mask[3]; void *tasklet_info; - struct timeval sof_ts; - struct timeval epoch_ts; - struct timeval eof_ts; - struct timeval error_ts; + struct timespec64 sof_ts; + struct timespec64 epoch_ts; + struct timespec64 eof_ts; + struct timespec64 error_ts; }; struct cam_tfe_camif_data { @@ -173,11 +176,11 @@ int cam_tfe_get_hw_caps(void *hw_priv, void *get_hw_cap_args, void cam_tfe_get_timestamp(struct cam_isp_timestamp *time_stamp) { - struct timespec ts; + struct timespec64 ts; - get_monotonic_boottime(&ts); + ktime_get_boottime_ts64(&ts); time_stamp->mono_time.tv_sec = ts.tv_sec; - time_stamp->mono_time.tv_usec = ts.tv_nsec/1000; + time_stamp->mono_time.tv_nsec = ts.tv_nsec; } int cam_tfe_irq_config(void *tfe_core_data, @@ -320,13 +323,13 @@ static void cam_tfe_log_error_irq_status( CAM_INFO(CAM_ISP, "ERROR time %lld:%lld SOF %lld:%lld EPOCH %lld:%lld EOF %lld:%lld", top_priv->error_ts.tv_sec, - top_priv->error_ts.tv_usec, + top_priv->error_ts.tv_nsec/1000, top_priv->sof_ts.tv_sec, - top_priv->sof_ts.tv_usec, + top_priv->sof_ts.tv_nsec/1000, top_priv->epoch_ts.tv_sec, - top_priv->epoch_ts.tv_usec, + top_priv->epoch_ts.tv_nsec/1000, top_priv->eof_ts.tv_sec, - top_priv->eof_ts.tv_usec); + top_priv->eof_ts.tv_nsec/1000); val_0 = cam_io_r(mem_base + top_priv->common_data.common_reg->debug_0); @@ -471,8 +474,8 @@ static int cam_tfe_error_irq_bottom_half( evt_info.err_type = CAM_TFE_IRQ_STATUS_OVERFLOW; top_priv->error_ts.tv_sec = evt_payload->ts.mono_time.tv_sec; - top_priv->error_ts.tv_usec = - evt_payload->ts.mono_time.tv_usec; + top_priv->error_ts.tv_nsec = + evt_payload->ts.mono_time.tv_nsec; cam_tfe_log_error_irq_status(core_info, top_priv, evt_payload); if (event_cb) @@ -508,8 +511,8 @@ static int cam_tfe_rdi_irq_bottom_half( CAM_DBG(CAM_ISP, "Received EOF"); top_priv->eof_ts.tv_sec = evt_payload->ts.mono_time.tv_sec; - top_priv->eof_ts.tv_usec = - evt_payload->ts.mono_time.tv_usec; + top_priv->eof_ts.tv_nsec = + evt_payload->ts.mono_time.tv_nsec; if (rdi_priv->event_cb) rdi_priv->event_cb(rdi_priv->priv, @@ -521,8 +524,8 @@ static int cam_tfe_rdi_irq_bottom_half( CAM_DBG(CAM_ISP, "Received SOF"); top_priv->sof_ts.tv_sec = evt_payload->ts.mono_time.tv_sec; - top_priv->sof_ts.tv_usec = - evt_payload->ts.mono_time.tv_usec; + top_priv->sof_ts.tv_nsec = + evt_payload->ts.mono_time.tv_nsec; if (rdi_priv->event_cb) rdi_priv->event_cb(rdi_priv->priv, @@ -534,8 +537,8 @@ static int cam_tfe_rdi_irq_bottom_half( CAM_DBG(CAM_ISP, "Received EPOCH0"); top_priv->epoch_ts.tv_sec = evt_payload->ts.mono_time.tv_sec; - top_priv->epoch_ts.tv_usec = - evt_payload->ts.mono_time.tv_usec; + top_priv->epoch_ts.tv_nsec = + evt_payload->ts.mono_time.tv_nsec; if (rdi_priv->event_cb) rdi_priv->event_cb(rdi_priv->priv, @@ -568,8 +571,8 @@ static int cam_tfe_camif_irq_bottom_half( top_priv->eof_ts.tv_sec = evt_payload->ts.mono_time.tv_sec; - top_priv->eof_ts.tv_usec = - evt_payload->ts.mono_time.tv_usec; + top_priv->eof_ts.tv_nsec = + evt_payload->ts.mono_time.tv_nsec; if (camif_priv->event_cb) camif_priv->event_cb(camif_priv->priv, @@ -595,8 +598,8 @@ static int cam_tfe_camif_irq_bottom_half( top_priv->sof_ts.tv_sec = evt_payload->ts.mono_time.tv_sec; - top_priv->sof_ts.tv_usec = - evt_payload->ts.mono_time.tv_usec; + top_priv->sof_ts.tv_nsec = + evt_payload->ts.mono_time.tv_nsec; if (camif_priv->event_cb) camif_priv->event_cb(camif_priv->priv, @@ -609,8 +612,8 @@ static int cam_tfe_camif_irq_bottom_half( top_priv->epoch_ts.tv_sec = evt_payload->ts.mono_time.tv_sec; - top_priv->epoch_ts.tv_usec = - evt_payload->ts.mono_time.tv_usec; + top_priv->epoch_ts.tv_nsec = + evt_payload->ts.mono_time.tv_nsec; if (camif_priv->event_cb) camif_priv->event_cb(camif_priv->priv, @@ -1127,7 +1130,7 @@ static int cam_tfe_top_set_axi_bw_vote( } free_mem: - kzfree(agg_vote); + cam_free_clear((void *)agg_vote); agg_vote = NULL; return rc; } @@ -2066,7 +2069,7 @@ int cam_tfe_top_start(struct cam_tfe_hw_core_info *core_info, if (in_res->res_id == CAM_ISP_HW_TFE_IN_CAMIF) { cam_tfe_camif_resource_start(core_info, in_res); - } else if (in_res->res_id >= CAM_ISP_HW_TFE_IN_RDI0 || + } else if (in_res->res_id >= CAM_ISP_HW_TFE_IN_RDI0 && in_res->res_id <= CAM_ISP_HW_TFE_IN_RDI2) { rsrc_rdi_data = (struct cam_tfe_rdi_data *) in_res->res_priv; val = (rsrc_rdi_data->pix_pattern << @@ -2103,13 +2106,13 @@ int cam_tfe_top_start(struct cam_tfe_hw_core_info *core_info, core_info->tfe_hw_info->error_irq_mask, CAM_TFE_TOP_IRQ_REG_NUM, true); top_priv->error_ts.tv_sec = 0; - top_priv->error_ts.tv_usec = 0; + top_priv->error_ts.tv_nsec = 0; top_priv->sof_ts.tv_sec = 0; - top_priv->sof_ts.tv_usec = 0; + top_priv->sof_ts.tv_nsec = 0; top_priv->epoch_ts.tv_sec = 0; - top_priv->epoch_ts.tv_usec = 0; + top_priv->epoch_ts.tv_nsec = 0; top_priv->eof_ts.tv_sec = 0; - top_priv->eof_ts.tv_usec = 0; + top_priv->eof_ts.tv_nsec = 0; } end: @@ -2819,7 +2822,7 @@ int cam_tfe_core_init(struct cam_tfe_hw_core_info *core_info, int rc = -EINVAL; int i; - if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_FUSE_ID, + if (!cam_cpas_is_feature_supported(CAM_CPAS_ISP_FUSE, hw_intf->hw_idx)) { CAM_INFO(CAM_ISP, "TFE:%d is not supported", hw_intf->hw_idx); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.h index 2418831d0..cb74193aa 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_core.h @@ -7,7 +7,7 @@ #ifndef _CAM_TFE_CORE_H_ #define _CAM_TFE_CORE_H_ -#include +#include #include "cam_hw_intf.h" #include "cam_tfe_bus.h" #include "cam_tfe_hw_intf.h" diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_dev.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_dev.h index 41816285a..e8de677c6 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_dev.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/tfe_hw/cam_tfe_dev.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_TFE_DEV_H_ @@ -32,4 +33,6 @@ int cam_tfe_probe(struct platform_device *pdev); */ int cam_tfe_remove(struct platform_device *pdev); +int cam_tfe_init_module(void); +void cam_tfe_exit_module(void); #endif /* _CAM_TFE_DEV_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.c index ce56d38fc..0cf7f7c9b 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ @@ -39,17 +40,15 @@ static struct platform_driver cam_top_tpg_v1_driver = { }, }; -static int __init cam_top_tpg_v1_init_module(void) +int cam_top_tpg_v1_init_module(void) { return platform_driver_register(&cam_top_tpg_v1_driver); } -static void __exit cam_top_tpg_v1_exit_module(void) +void cam_top_tpg_v1_exit_module(void) { platform_driver_unregister(&cam_top_tpg_v1_driver); } -module_init(cam_top_tpg_v1_init_module); -module_exit(cam_top_tpg_v1_exit_module); MODULE_DESCRIPTION("CAM TOP TPG driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.h index aedc666bb..71f3c0c90 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/top_tpg/cam_top_tpg_v1.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_TOP_TPG_V1_H_ @@ -51,4 +52,6 @@ static struct cam_top_tpg_reg_offset cam_top_tpg_v1_reg_offset = { .top_unicolor_bar_shift = 2, }; +int cam_top_tpg_v1_init_module(void); +void cam_top_tpg_v1_exit_module(void); #endif /*_CAM_TOP_TPG_V1_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/Makefile b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/Makefile deleted file mode 100644 index 1609a7a04..000000000 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_vfe_soc.o cam_vfe_dev.o cam_vfe_core.o -obj-$(CONFIG_SPECTRA_CAMERA) += vfe_bus/ vfe_top/ vfe17x/ diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c index 8fdbbd33b..b5c7c0b9f 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.c @@ -379,11 +379,11 @@ int cam_vfe_reset(void *hw_priv, void *reset_core_args, uint32_t arg_size) void cam_isp_hw_get_timestamp(struct cam_isp_timestamp *time_stamp) { - struct timespec ts; + struct timespec64 ts; - get_monotonic_boottime(&ts); + ktime_get_boottime_ts64(&ts); time_stamp->mono_time.tv_sec = ts.tv_sec; - time_stamp->mono_time.tv_usec = ts.tv_nsec/1000; + time_stamp->mono_time.tv_nsec = ts.tv_nsec; } int cam_vfe_reserve(void *hw_priv, void *reserve_args, uint32_t arg_size) diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.h index 43afd0377..0dc295613 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/cam_vfe_core.h @@ -6,7 +6,7 @@ #ifndef _CAM_VFE_CORE_H_ #define _CAM_VFE_CORE_H_ -#include +#include #include "cam_hw_intf.h" #include "cam_vfe_top.h" #include "cam_vfe_bus.h" diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/Makefile b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/Makefile deleted file mode 100644 index e129ea699..000000000 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_vfe.o diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.c index 5336352a4..bb3c2b12d 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.c @@ -58,17 +58,16 @@ static struct platform_driver cam_vfe_driver = { }, }; -static int __init cam_vfe_init_module(void) +int cam_vfe_init_module(void) { return platform_driver_register(&cam_vfe_driver); } -static void __exit cam_vfe_exit_module(void) + +void cam_vfe_exit_module(void) { platform_driver_unregister(&cam_vfe_driver); } -module_init(cam_vfe_init_module); -module_exit(cam_vfe_exit_module); MODULE_DESCRIPTION("CAM VFE driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.h new file mode 100644 index 000000000..5c2d1ef0e --- /dev/null +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe17x/cam_vfe.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#ifndef _CAM_VFE_H_ +#define _CAM_VFE_H_ + +/** + * @brief : API to register VFE hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_vfe_init_module(void); + +/** + * @brief : API to remove VFE Hw from platform framework. + */ +void cam_vfe_exit_module(void); + +#endif /* _CAM_VFE_H_ */ diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/Makefile b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/Makefile deleted file mode 100644 index aa3fb1c74..000000000 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_vfe_bus.o cam_vfe_bus_ver2.o cam_vfe_bus_rd_ver1.o cam_vfe_bus_ver3.o diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_rd_ver1.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_rd_ver1.c index 314ebff70..28e4218a7 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_rd_ver1.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_rd_ver1.c @@ -5,7 +5,9 @@ #include #include -#include + +#include + #include "cam_io_util.h" #include "cam_debug_util.h" #include "cam_cdm_util.h" diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c index 7ad42e848..aac48cc76 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c @@ -6,7 +6,9 @@ #include #include -#include + +#include + #include "cam_io_util.h" #include "cam_debug_util.h" #include "cam_cdm_util.h" diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/include/cam_vfe_bus.h b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/include/cam_vfe_bus.h index 97336a2da..2548c3601 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/include/cam_vfe_bus.h +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/include/cam_vfe_bus.h @@ -6,7 +6,8 @@ #ifndef _CAM_VFE_BUS_H_ #define _CAM_VFE_BUS_H_ -#include +#include + #include "cam_hw_intf.h" #include "cam_isp_hw.h" diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/Makefile b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/Makefile deleted file mode 100644 index 08b95ac27..000000000 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/irq_controller -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/hw_utils/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_vfe_camif_lite_ver2.o cam_vfe_top.o cam_vfe_top_common.o -obj-$(CONFIG_SPECTRA_CAMERA) += cam_vfe_top_ver3.o cam_vfe_top_ver2.o cam_vfe_camif_ver2.o -obj-$(CONFIG_SPECTRA_CAMERA) += cam_vfe_camif_ver3.o cam_vfe_rdi.o cam_vfe_fe_ver1.o cam_vfe_camif_lite_ver3.o diff --git a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c index 98c84ad77..7815da674 100644 --- a/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c +++ b/drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_top/cam_vfe_fe_ver1.c @@ -4,7 +4,9 @@ */ #include -#include + +#include + #include "cam_io_util.h" #include "cam_isp_hw_mgr_intf.h" #include "cam_isp_hw.h" diff --git a/drivers/cam_jpeg/Makefile b/drivers/cam_jpeg/Makefile deleted file mode 100644 index 471f870e4..000000000 --- a/drivers/cam_jpeg/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include/ - -obj-$(CONFIG_SPECTRA_CAMERA) += jpeg_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_jpeg_dev.o cam_jpeg_context.o diff --git a/drivers/cam_jpeg/cam_jpeg_dev.c b/drivers/cam_jpeg/cam_jpeg_dev.c index b123ebe80..4caffb398 100644 --- a/drivers/cam_jpeg/cam_jpeg_dev.c +++ b/drivers/cam_jpeg/cam_jpeg_dev.c @@ -187,17 +187,15 @@ static struct platform_driver jpeg_driver = { }, }; -static int __init cam_jpeg_dev_init_module(void) +int cam_jpeg_dev_init_module(void) { return platform_driver_register(&jpeg_driver); } -static void __exit cam_jpeg_dev_exit_module(void) +void cam_jpeg_dev_exit_module(void) { platform_driver_unregister(&jpeg_driver); } -module_init(cam_jpeg_dev_init_module); -module_exit(cam_jpeg_dev_exit_module); MODULE_DESCRIPTION("MSM JPEG driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_jpeg/cam_jpeg_dev.h b/drivers/cam_jpeg/cam_jpeg_dev.h index d07a1f94b..d468748d8 100644 --- a/drivers/cam_jpeg/cam_jpeg_dev.h +++ b/drivers/cam_jpeg/cam_jpeg_dev.h @@ -29,4 +29,15 @@ struct cam_jpeg_dev { struct mutex jpeg_mutex; int32_t open_cnt; }; + +/** + * @brief : API to register JPEG dev to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_jpeg_dev_init_module(void); + +/** + * @brief : API to remove JPEG dev from platform framework. + */ +void cam_jpeg_dev_exit_module(void); #endif /* __CAM_JPEG_DEV_H__ */ diff --git a/drivers/cam_jpeg/jpeg_hw/Makefile b/drivers/cam_jpeg/jpeg_hw/Makefile deleted file mode 100644 index f189bd13a..000000000 --- a/drivers/cam_jpeg/jpeg_hw/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/include/ - -obj-$(CONFIG_SPECTRA_CAMERA) += jpeg_enc_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += jpeg_dma_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_jpeg_hw_mgr.o diff --git a/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c b/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c index ee353c094..ba8c2869e 100644 --- a/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c +++ b/drivers/cam_jpeg/jpeg_hw/cam_jpeg_hw_mgr.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/Makefile b/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/Makefile deleted file mode 100644 index f0162f988..000000000 --- a/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/jpeg_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw - -obj-$(CONFIG_SPECTRA_CAMERA) += jpeg_dma_dev.o jpeg_dma_core.o jpeg_dma_soc.o diff --git a/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h b/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h index dc3a1c13f..6b7c8344a 100644 --- a/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h +++ b/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_core.h @@ -41,4 +41,14 @@ int cam_jpeg_dma_process_cmd(void *device_priv, uint32_t cmd_type, void *cmd_args, uint32_t arg_size); irqreturn_t cam_jpeg_dma_irq(int irq_num, void *data); +/** + * @brief : API to register JPEG DMA hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_jpeg_dma_init_module(void); + +/** + * @brief : API to remove JPEG DMA Hw from platform framework. + */ +void cam_jpeg_dma_exit_module(void); #endif /* CAM_JPEG_DMA_CORE_H */ diff --git a/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c b/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c index ce82c5e79..f717d68c8 100644 --- a/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c +++ b/drivers/cam_jpeg/jpeg_hw/jpeg_dma_hw/jpeg_dma_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -22,7 +22,6 @@ static struct cam_jpeg_dma_device_hw_info cam_jpeg_dma_hw_info = { .reserved = 0, }; -EXPORT_SYMBOL(cam_jpeg_dma_hw_info); static int cam_jpeg_dma_register_cpas(struct cam_hw_soc_info *soc_info, struct cam_jpeg_dma_device_core_info *core_info, @@ -217,17 +216,15 @@ static struct platform_driver cam_jpeg_dma_driver = { }, }; -static int __init cam_jpeg_dma_init_module(void) +int cam_jpeg_dma_init_module(void) { return platform_driver_register(&cam_jpeg_dma_driver); } -static void __exit cam_jpeg_dma_exit_module(void) +void cam_jpeg_dma_exit_module(void) { platform_driver_unregister(&cam_jpeg_dma_driver); } -module_init(cam_jpeg_dma_init_module); -module_exit(cam_jpeg_dma_exit_module); MODULE_DESCRIPTION("CAM JPEG_DMA driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/Makefile b/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/Makefile deleted file mode 100644 index 159c54bbe..000000000 --- a/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/jpeg_hw_mgr/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw - -obj-$(CONFIG_SPECTRA_CAMERA) += jpeg_enc_dev.o jpeg_enc_core.o jpeg_enc_soc.o diff --git a/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h b/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h index ca83dccb1..db505bf5b 100644 --- a/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h +++ b/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_core.h @@ -82,4 +82,14 @@ int cam_jpeg_enc_process_cmd(void *device_priv, uint32_t cmd_type, void *cmd_args, uint32_t arg_size); irqreturn_t cam_jpeg_enc_irq(int irq_num, void *data); +/** + * @brief : API to register JPEG ENC hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_jpeg_enc_init_module(void); + +/** + * @brief : API to remove JPEG ENC Hw from platform framework. + */ +void cam_jpeg_enc_exit_module(void); #endif /* CAM_JPEG_ENC_CORE_H */ diff --git a/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c b/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c index 8eb8ec367..b6ab52f37 100644 --- a/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c +++ b/drivers/cam_jpeg/jpeg_hw/jpeg_enc_hw/jpeg_enc_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -215,17 +215,15 @@ static struct platform_driver cam_jpeg_enc_driver = { }, }; -static int __init cam_jpeg_enc_init_module(void) +int cam_jpeg_enc_init_module(void) { return platform_driver_register(&cam_jpeg_enc_driver); } -static void __exit cam_jpeg_enc_exit_module(void) +void cam_jpeg_enc_exit_module(void) { platform_driver_unregister(&cam_jpeg_enc_driver); } -module_init(cam_jpeg_enc_init_module); -module_exit(cam_jpeg_enc_exit_module); MODULE_DESCRIPTION("CAM JPEG_ENC driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_lrme/Makefile b/drivers/cam_lrme/Makefile deleted file mode 100644 index 72cdba4da..000000000 --- a/drivers/cam_lrme/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/lrme_hw -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include/ - -obj-$(CONFIG_SPECTRA_CAMERA) += lrme_hw_mgr/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_lrme_dev.o cam_lrme_context.o diff --git a/drivers/cam_lrme/cam_lrme_dev.c b/drivers/cam_lrme/cam_lrme_dev.c index 656a4dbd7..4ed862d97 100644 --- a/drivers/cam_lrme/cam_lrme_dev.c +++ b/drivers/cam_lrme/cam_lrme_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include @@ -224,17 +224,15 @@ static struct platform_driver cam_lrme_driver = { }, }; -static int __init cam_lrme_dev_init_module(void) +int cam_lrme_dev_init_module(void) { return platform_driver_register(&cam_lrme_driver); } -static void __exit cam_lrme_dev_exit_module(void) +void cam_lrme_dev_exit_module(void) { platform_driver_unregister(&cam_lrme_driver); } -module_init(cam_lrme_dev_init_module); -module_exit(cam_lrme_dev_exit_module); MODULE_DESCRIPTION("MSM LRME driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_lrme/cam_lrme_dev.h b/drivers/cam_lrme/cam_lrme_dev.h new file mode 100644 index 000000000..e8f4dcfc7 --- /dev/null +++ b/drivers/cam_lrme/cam_lrme_dev.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + */ + +#ifndef _CAM_LRME_DEV_H_ +#define _CAM_LRME_DEV_H_ + +/** + * @brief : API to register LRME dev to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_lrme_dev_init_module(void); + +/** + * @brief : API to remove LRME dev from platform framework. + */ +void cam_lrme_dev_exit_module(void); + +#endif /* _CAM_LRME_DEV_H_ */ diff --git a/drivers/cam_lrme/lrme_hw_mgr/Makefile b/drivers/cam_lrme/lrme_hw_mgr/Makefile deleted file mode 100644 index 3387c3d0f..000000000 --- a/drivers/cam_lrme/lrme_hw_mgr/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme/lrme_hw_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/lrme_hw -ccflags-y += -I$(srctree)/techpack/camera -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += lrme_hw/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_lrme_hw_mgr.o diff --git a/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c b/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c index 537fc48a6..e1636a6b8 100644 --- a/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c +++ b/drivers/cam_lrme/lrme_hw_mgr/cam_lrme_hw_mgr.c @@ -1016,28 +1016,28 @@ static int cam_lrme_mgr_hw_config(void *hw_mgr_priv, static int cam_lrme_mgr_create_debugfs_entry(void) { int rc = 0; + struct dentry *dbgfileptr = NULL; - g_lrme_hw_mgr.debugfs_entry.dentry = - debugfs_create_dir("camera_lrme", NULL); - if (!g_lrme_hw_mgr.debugfs_entry.dentry) { - CAM_ERR(CAM_LRME, "failed to create dentry"); - return -ENOMEM; + dbgfileptr = debugfs_create_dir("camera_lrme", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_ISP,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + g_lrme_hw_mgr.debugfs_entry.dentry = dbgfileptr; - if (!debugfs_create_bool("dump_register", - 0644, + dbgfileptr = debugfs_create_bool("dump_register", 0644, g_lrme_hw_mgr.debugfs_entry.dentry, - &g_lrme_hw_mgr.debugfs_entry.dump_register)) { - CAM_ERR(CAM_LRME, "failed to create dump register entry"); - rc = -ENOMEM; - goto err; + &g_lrme_hw_mgr.debugfs_entry.dump_register); + if (IS_ERR(dbgfileptr)) { + if (PTR_ERR(dbgfileptr) == -ENODEV) + CAM_WARN(CAM_LRME, "DebugFS not enabled in kernel!"); + else + rc = PTR_ERR(dbgfileptr); } - return rc; - err: - debugfs_remove_recursive(g_lrme_hw_mgr.debugfs_entry.dentry); - g_lrme_hw_mgr.debugfs_entry.dentry = NULL; return rc; } @@ -1140,6 +1140,7 @@ int cam_lrme_mgr_deregister_device(int device_index) int cam_lrme_hw_mgr_deinit(void) { mutex_destroy(&g_lrme_hw_mgr.hw_mgr_mutex); + debugfs_remove_recursive(g_lrme_hw_mgr.debugfs_entry.dentry); memset(&g_lrme_hw_mgr, 0x0, sizeof(g_lrme_hw_mgr)); return 0; @@ -1194,7 +1195,6 @@ int cam_lrme_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, hw_mgr_intf->hw_dump = cam_lrme_mgr_hw_dump; cam_lrme_mgr_create_debugfs_entry(); - CAM_DBG(CAM_LRME, "Hw mgr init done"); return rc; } diff --git a/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/Makefile b/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/Makefile deleted file mode 100644 index 8df30c0f4..000000000 --- a/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sync -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cdm -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme/lrme_hw_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_lrme/lrme_hw_mgr/lrme_hw -ccflags-y += -I$(srctree)/techpack/camera0 -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_lrme_hw_dev.o cam_lrme_hw_core.o cam_lrme_hw_soc.o diff --git a/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_dev.c b/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_dev.c index 5276f74c3..36de77795 100644 --- a/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_dev.c +++ b/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_dev.c @@ -288,17 +288,15 @@ static struct platform_driver cam_lrme_hw_driver = { }, }; -static int __init cam_lrme_hw_init_module(void) +int cam_lrme_hw_init_module(void) { return platform_driver_register(&cam_lrme_hw_driver); } -static void __exit cam_lrme_hw_exit_module(void) +void cam_lrme_hw_exit_module(void) { platform_driver_unregister(&cam_lrme_hw_driver); } -module_init(cam_lrme_hw_init_module); -module_exit(cam_lrme_hw_exit_module); MODULE_DESCRIPTION("CAM LRME HW driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_intf.h b/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_intf.h index cd4d64b18..1d8cf81bc 100644 --- a/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_intf.h +++ b/drivers/cam_lrme/lrme_hw_mgr/lrme_hw/cam_lrme_hw_intf.h @@ -211,4 +211,14 @@ struct cam_lrme_hw_dump_args { size_t buf_len; }; +/** + * @brief : API to register LRME hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_lrme_hw_init_module(void); + +/** + * @brief : API to remove LRME Hw from platform framework. + */ +void cam_lrme_hw_exit_module(void); #endif /* _CAM_LRME_HW_INTF_H_ */ diff --git a/drivers/cam_ope/cam_ope_subdev.c b/drivers/cam_ope/cam_ope_subdev.c index 3a09b71a0..0624123de 100644 --- a/drivers/cam_ope/cam_ope_subdev.c +++ b/drivers/cam_ope/cam_ope_subdev.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -255,7 +256,7 @@ static const struct of_device_id cam_ope_dt_match[] = { }; -static struct platform_driver cam_ope_driver = { +static struct platform_driver cam_ope_subdev_driver = { .probe = cam_ope_subdev_probe, .remove = cam_ope_subdev_remove, .driver = { @@ -265,17 +266,15 @@ static struct platform_driver cam_ope_driver = { }, }; -static int __init cam_ope_init_module(void) +int cam_ope_subdev_init_module(void) { - return platform_driver_register(&cam_ope_driver); + return platform_driver_register(&cam_ope_subdev_driver); } -static void __exit cam_ope_exit_module(void) +void cam_ope_subdev_exit_module(void) { - platform_driver_unregister(&cam_ope_driver); + platform_driver_unregister(&cam_ope_subdev_driver); } -module_init(cam_ope_init_module); -module_exit(cam_ope_exit_module); MODULE_DESCRIPTION("MSM OPE driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c index 0e7e95fee..83f2379e7 100644 --- a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c +++ b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,6 +42,7 @@ #include "cam_cdm_util.h" #include "cam_cdm.h" #include "ope_dev_intf.h" +#include "cam_compat.h" static struct cam_ope_hw_mgr *ope_hw_mgr; @@ -182,7 +183,7 @@ static void cam_ope_free_io_config(struct cam_ope_request *req) for (i = 0; i < OPE_MAX_BATCH_SIZE; i++) { for (j = 0; j < OPE_MAX_IO_BUFS; j++) { if (req->io_buf[i][j]) { - kzfree(req->io_buf[i][j]); + cam_free_clear((void *)req->io_buf[i][j]); req->io_buf[i][j] = NULL; } } @@ -618,7 +619,7 @@ static bool cam_ope_check_req_delay(struct cam_ope_ctx *ctx_data, struct timespec64 ts; uint64_t ts_ns; - get_monotonic_boottime64(&ts); + ktime_get_boottime_ts64(&ts); ts_ns = (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); @@ -1625,7 +1626,7 @@ static void cam_ope_ctx_cdm_callback(uint32_t handle, void *userdata, ope_req = ctx->req_list[cookie]; - get_monotonic_boottime64(&ts); + ktime_get_boottime_ts64(&ts); ope_hw_mgr->last_callback_time = (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); @@ -1685,10 +1686,10 @@ static void cam_ope_ctx_cdm_callback(uint32_t handle, void *userdata, buf_data.request_id = ope_req->request_id; ope_req->request_id = 0; - kzfree(ctx->req_list[cookie]->cdm_cmd); + cam_free_clear((void *)ctx->req_list[cookie]->cdm_cmd); ctx->req_list[cookie]->cdm_cmd = NULL; cam_ope_free_io_config(ctx->req_list[cookie]); - kzfree(ctx->req_list[cookie]); + cam_free_clear((void *)ctx->req_list[cookie]); ctx->req_list[cookie] = NULL; clear_bit(cookie, ctx->bitmap); ctx->ctxt_event_cb(ctx->context_priv, flag, &buf_data); @@ -1748,7 +1749,7 @@ static int cam_ope_mgr_create_kmd_buf(struct cam_ope_hw_mgr *hw_mgr, prepare_req.frame_process = (struct ope_frame_process *)ope_cmd_buf_addr; - for (i = 0; i < ope_hw_mgr->num_ope; i++) + for (i = 0; i < ope_hw_mgr->num_ope; i++) { rc = hw_mgr->ope_dev_intf[i]->hw_ops.process_cmd( hw_mgr->ope_dev_intf[i]->hw_priv, OPE_HW_PREPARE, &prepare_req, sizeof(prepare_req)); @@ -1756,6 +1757,7 @@ static int cam_ope_mgr_create_kmd_buf(struct cam_ope_hw_mgr *hw_mgr, CAM_ERR(CAM_OPE, "OPE Dev prepare failed: %d", rc); goto end; } + } end: return rc; @@ -2259,8 +2261,6 @@ static int cam_ope_mgr_process_cmd_desc(struct cam_ope_hw_mgr *hw_mgr, if (rc || !cpu_addr) { CAM_ERR(CAM_OPE, "get cmd buf failed %x", hw_mgr->iommu_hdl); - num_cmd_buf = (num_cmd_buf > 0) ? - num_cmd_buf-- : 0; goto end; } if ((len <= cmd_desc[i].offset) || @@ -2762,9 +2762,9 @@ static int cam_ope_mgr_acquire_hw(void *hw_priv, void *hw_acquire_args) ctx->ctxt_event_cb = args->event_cb; cam_ope_ctx_clk_info_init(ctx); ctx->ctx_state = OPE_CTX_STATE_ACQUIRED; - kzfree(cdm_acquire); + cam_free_clear((void *)cdm_acquire); cdm_acquire = NULL; - kzfree(bw_update); + cam_free_clear((void *)bw_update); bw_update = NULL; mutex_unlock(&ctx->ctx_mutex); @@ -2774,7 +2774,7 @@ static int cam_ope_mgr_acquire_hw(void *hw_priv, void *hw_acquire_args) return rc; free_bw_update: - kzfree(bw_update); + cam_free_clear((void *)bw_update); bw_update = NULL; ope_clk_update_failed: ope_dev_release.ctx_id = ctx_id; @@ -2818,7 +2818,7 @@ static int cam_ope_mgr_acquire_hw(void *hw_priv, void *hw_acquire_args) cdm_acquire_failed: free_cdm_acquire: - kzfree(cdm_acquire); + cam_free_clear((void *)cdm_acquire); cdm_acquire = NULL; end: args->ctxt_to_hw_map = NULL; @@ -2930,11 +2930,11 @@ static int cam_ope_mgr_release_ctx(struct cam_ope_hw_mgr *hw_mgr, int ctx_id) continue; if (hw_mgr->ctx[ctx_id].req_list[i]->cdm_cmd) { - kzfree(hw_mgr->ctx[ctx_id].req_list[i]->cdm_cmd); + cam_free_clear((void *)hw_mgr->ctx[ctx_id].req_list[i]->cdm_cmd); hw_mgr->ctx[ctx_id].req_list[i]->cdm_cmd = NULL; } cam_ope_free_io_config(hw_mgr->ctx[ctx_id].req_list[i]); - kzfree(hw_mgr->ctx[ctx_id].req_list[i]); + cam_free_clear((void *)hw_mgr->ctx[ctx_id].req_list[i]); hw_mgr->ctx[ctx_id].req_list[i] = NULL; clear_bit(i, hw_mgr->ctx[ctx_id].bitmap); } @@ -3286,7 +3286,7 @@ static int cam_ope_mgr_prepare_hw_update(void *hw_priv, prepare_args->priv = ctx_data->req_list[request_idx]; prepare_args->pf_data->packet = packet; ope_req->hang_data.packet = packet; - get_monotonic_boottime64(&ts); + ktime_get_boottime_ts64(&ts); ctx_data->last_req_time = (uint64_t)((ts.tv_sec * 1000000000) + ts.tv_nsec); CAM_DBG(CAM_REQ, "req_id= %llu ctx_id= %d lrt=%llu", @@ -3301,10 +3301,10 @@ static int cam_ope_mgr_prepare_hw_update(void *hw_priv, return rc; end: - kzfree(ctx_data->req_list[request_idx]->cdm_cmd); + cam_free_clear((void *)ctx_data->req_list[request_idx]->cdm_cmd); ctx_data->req_list[request_idx]->cdm_cmd = NULL; req_cdm_mem_alloc_failed: - kzfree(ctx_data->req_list[request_idx]); + cam_free_clear((void *)ctx_data->req_list[request_idx]); ctx_data->req_list[request_idx] = NULL; req_mem_alloc_failed: clear_bit(request_idx, ctx_data->bitmap); @@ -3327,10 +3327,10 @@ static int cam_ope_mgr_handle_config_err( req_idx = ope_req->req_idx; ope_req->request_id = 0; - kzfree(ctx_data->req_list[req_idx]->cdm_cmd); + cam_free_clear((void *)ctx_data->req_list[req_idx]->cdm_cmd); ctx_data->req_list[req_idx]->cdm_cmd = NULL; cam_ope_free_io_config(ctx_data->req_list[req_idx]); - kzfree(ctx_data->req_list[req_idx]); + cam_free_clear((void *)ctx_data->req_list[req_idx]); ctx_data->req_list[req_idx] = NULL; clear_bit(req_idx, ctx_data->bitmap); @@ -3598,10 +3598,10 @@ static int cam_ope_mgr_flush_req(struct cam_ope_ctx *ctx_data, continue; ctx_data->req_list[idx]->request_id = 0; - kzfree(ctx_data->req_list[idx]->cdm_cmd); + cam_free_clear((void *)ctx_data->req_list[idx]->cdm_cmd); ctx_data->req_list[idx]->cdm_cmd = NULL; cam_ope_free_io_config(ctx_data->req_list[idx]); - kzfree(ctx_data->req_list[idx]); + cam_free_clear((void *)ctx_data->req_list[idx]); ctx_data->req_list[idx] = NULL; clear_bit(idx, ctx_data->bitmap); } @@ -3631,10 +3631,10 @@ static int cam_ope_mgr_flush_all(struct cam_ope_ctx *ctx_data, continue; ctx_data->req_list[i]->request_id = 0; - kzfree(ctx_data->req_list[i]->cdm_cmd); + cam_free_clear((void *)ctx_data->req_list[i]->cdm_cmd); ctx_data->req_list[i]->cdm_cmd = NULL; cam_ope_free_io_config(ctx_data->req_list[i]); - kzfree(ctx_data->req_list[i]); + cam_free_clear((void *)ctx_data->req_list[i]); ctx_data->req_list[i] = NULL; clear_bit(i, ctx_data->bitmap); } @@ -3964,28 +3964,17 @@ static int cam_ope_create_debug_fs(void) return -ENOMEM; } - if (!debugfs_create_bool("frame_dump_enable", + debugfs_create_bool("frame_dump_enable", 0644, ope_hw_mgr->dentry, - &ope_hw_mgr->frame_dump_enable)) { - CAM_ERR(CAM_OPE, - "failed to create dump_enable_debug"); - goto err; - } + &ope_hw_mgr->frame_dump_enable); - if (!debugfs_create_bool("dump_req_data_enable", + debugfs_create_bool("dump_req_data_enable", 0644, ope_hw_mgr->dentry, - &ope_hw_mgr->dump_req_data_enable)) { - CAM_ERR(CAM_OPE, - "failed to create dump_enable_debug"); - goto err; - } + &ope_hw_mgr->dump_req_data_enable); return 0; -err: - debugfs_remove_recursive(ope_hw_mgr->dentry); - return -ENOMEM; } @@ -4110,24 +4099,24 @@ int cam_ope_hw_mgr_init(struct device_node *of_node, uint64_t *hw_mgr_hdl, cam_smmu_destroy_handle(ope_hw_mgr->iommu_hdl); ope_hw_mgr->iommu_hdl = -1; ope_get_hdl_failed: - kzfree(ope_hw_mgr->ctx_bitmap); + cam_free_clear((void *)ope_hw_mgr->ctx_bitmap); ope_hw_mgr->ctx_bitmap = NULL; ope_hw_mgr->ctx_bitmap_size = 0; ope_hw_mgr->ctx_bits = 0; ctx_bitmap_alloc_failed: - kzfree(ope_hw_mgr->devices[OPE_DEV_OPE]); + cam_free_clear((void *)ope_hw_mgr->devices[OPE_DEV_OPE]); ope_hw_mgr->devices[OPE_DEV_OPE] = NULL; dev_init_failed: ope_ctx_bitmap_failed: mutex_destroy(&ope_hw_mgr->hw_mgr_mutex); for (j = i - 1; j >= 0; j--) { mutex_destroy(&ope_hw_mgr->ctx[j].ctx_mutex); - kzfree(ope_hw_mgr->ctx[j].bitmap); + cam_free_clear((void *)ope_hw_mgr->ctx[j].bitmap); ope_hw_mgr->ctx[j].bitmap = NULL; ope_hw_mgr->ctx[j].bitmap_size = 0; ope_hw_mgr->ctx[j].bits = 0; } - kzfree(ope_hw_mgr); + cam_free_clear((void *)ope_hw_mgr); ope_hw_mgr = NULL; return rc; diff --git a/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_core.c b/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_core.c index 1edc6e313..bb020f8fd 100644 --- a/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_core.c +++ b/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_core.c @@ -13,6 +13,7 @@ #include #include #include + #include "cam_io_util.h" #include "cam_hw.h" #include "cam_hw_intf.h" @@ -27,6 +28,7 @@ #include "cam_cdm_util.h" #include "ope_bus_rd.h" #include "ope_bus_wr.h" +#include "cam_compat.h" static int cam_ope_caps_vote(struct cam_ope_device_core_info *core_info, struct cam_ope_dev_bw_update *cpas_vote) @@ -250,7 +252,7 @@ int cam_ope_init_hw(void *device_priv, else core_info->cpas_start = false; free_cpas_vote: - kzfree(cpas_vote); + cam_free_clear((void *)cpas_vote); cpas_vote = NULL; end: return rc; diff --git a/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev.c b/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev.c index 8a5f629e7..0fd0a8286 100644 --- a/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev.c +++ b/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -22,7 +23,6 @@ static struct cam_ope_device_hw_info ope_hw_info; static struct ope_dev_soc ope_soc_info; -EXPORT_SYMBOL(ope_soc_info); static struct hw_version_reg ope_hw_version_reg = { .hw_ver = 0x0, @@ -266,17 +266,15 @@ static struct platform_driver cam_ope_driver = { }, }; -static int __init cam_ope_init_module(void) +int cam_ope_init_module(void) { return platform_driver_register(&cam_ope_driver); } -static void __exit cam_ope_exit_module(void) +void cam_ope_exit_module(void) { platform_driver_unregister(&cam_ope_driver); } -module_init(cam_ope_init_module); -module_exit(cam_ope_exit_module); MODULE_DESCRIPTION("CAM OPE driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev_intf.h b/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev_intf.h index aeeca5e7b..8fc5273ec 100644 --- a/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev_intf.h +++ b/drivers/cam_ope/ope_hw_mgr/ope_hw/ope_dev_intf.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef CAM_OPE_DEV_INTF_H @@ -167,5 +168,11 @@ int cam_ope_bus_rd_process(struct ope_hw *ope_hw_info, int cam_ope_bus_wr_process(struct ope_hw *ope_hw_info, int32_t ctx_id, uint32_t cmd_id, void *data); +int cam_ope_init_module(void); +void cam_ope_exit_module(void); + +int cam_ope_subdev_init_module(void); +void cam_ope_subdev_exit_module(void); + #endif /* CAM_OPE_DEV_INTF_H */ diff --git a/drivers/cam_ope/ope_hw_mgr/ope_hw/top/ope_top.c b/drivers/cam_ope/ope_hw_mgr/ope_hw/top/ope_top.c index 35f4d85e9..018747c53 100644 --- a/drivers/cam_ope/ope_hw_mgr/ope_hw/top/ope_top.c +++ b/drivers/cam_ope/ope_hw_mgr/ope_hw/top/ope_top.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2019-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -350,7 +351,8 @@ int cam_ope_top_process(struct ope_hw *ope_hw_info, rc = cam_ope_top_reset(ope_hw_info, 0, 0); break; case OPE_HW_DUMP_DEBUG: - rc - cam_ope_top_dump_debug_reg(ope_hw_info); + rc = cam_ope_top_dump_debug_reg(ope_hw_info); + break; default: break; } diff --git a/drivers/cam_req_mgr/Makefile b/drivers/cam_req_mgr/Makefile index 8ecc89ffd..2aaed1301 100644 --- a/drivers/cam_req_mgr/Makefile +++ b/drivers/cam_req_mgr/Makefile @@ -1,9 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only -ccflags-y += -I$(srctree)/techpack/camera/include/uapi ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils +ccflags-y += -I$(srctree)/include/ ccflags-y += -I$(srctree)/ obj-$(CONFIG_SPECTRA_CAMERA) += cam_req_mgr_core.o\ diff --git a/drivers/cam_req_mgr/cam_mem_mgr.c b/drivers/cam_req_mgr/cam_mem_mgr.c index 7a3378988..f10250059 100644 --- a/drivers/cam_req_mgr/cam_mem_mgr.c +++ b/drivers/cam_req_mgr/cam_mem_mgr.c @@ -1,28 +1,34 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include #include -#include #include -#include #include #include +#include +#include "cam_compat.h" #include "cam_req_mgr_util.h" #include "cam_mem_mgr.h" #include "cam_smmu_api.h" #include "cam_debug_util.h" #include "cam_trace.h" #include "cam_common_util.h" +#include "cam_compat.h" static struct cam_mem_table tbl; static atomic_t cam_mem_mgr_state = ATOMIC_INIT(CAM_MEM_MGR_UNINITIALIZED); +#if IS_REACHABLE(CONFIG_DMABUF_HEAPS) +static void cam_mem_mgr_put_dma_heaps(void); +static int cam_mem_mgr_get_dma_heaps(void); +#endif + static int cam_mem_util_get_dma_dir(uint32_t flags) { int rc = -EINVAL; @@ -39,12 +45,9 @@ static int cam_mem_util_get_dma_dir(uint32_t flags) return rc; } -static int cam_mem_util_map_cpu_va(struct dma_buf *dmabuf, - uintptr_t *vaddr, - size_t *len) +static int cam_mem_util_map_cpu_va(struct dma_buf *dmabuf, uintptr_t *vaddr, size_t *len) { - int i, j, rc; - void *addr; + int rc = 0; /* * dma_buf_begin_cpu_access() and dma_buf_end_cpu_access() @@ -56,54 +59,31 @@ static int cam_mem_util_map_cpu_va(struct dma_buf *dmabuf, return rc; } - /* - * Code could be simplified if ION support of dma_buf_vmap is - * available. This workaround takes the avandaage that ion_alloc - * returns a virtually contiguous memory region, so we just need - * to _kmap each individual page and then only use the virtual - * address returned from the first call to _kmap. - */ - for (i = 0; i < PAGE_ALIGN(dmabuf->size) / PAGE_SIZE; i++) { - addr = dma_buf_kmap(dmabuf, i); - if (IS_ERR_OR_NULL(addr)) { - CAM_ERR(CAM_MEM, "kernel map fail"); - for (j = 0; j < i; j++) - dma_buf_kunmap(dmabuf, - j, - (void *)(*vaddr + (j * PAGE_SIZE))); - *vaddr = 0; - *len = 0; - rc = -ENOSPC; - goto fail; - } - if (i == 0) - *vaddr = (uint64_t)addr; + rc = cam_compat_util_get_dmabuf_va(dmabuf, vaddr); + if (rc) { + CAM_ERR(CAM_MEM, "kernel vmap failed: rc = %d", rc); + *len = 0; + dma_buf_end_cpu_access(dmabuf, DMA_BIDIRECTIONAL); + } + else { + *len = dmabuf->size; + CAM_DBG(CAM_MEM, "vaddr = %llu, len = %zu", *vaddr, *len); } - *len = dmabuf->size; - - return 0; - -fail: - dma_buf_end_cpu_access(dmabuf, DMA_BIDIRECTIONAL); return rc; } + static int cam_mem_util_unmap_cpu_va(struct dma_buf *dmabuf, uint64_t vaddr) { - int i, rc = 0, page_num; + int rc = 0; if (!dmabuf || !vaddr) { CAM_ERR(CAM_MEM, "Invalid input args %pK %llX", dmabuf, vaddr); return -EINVAL; } - page_num = PAGE_ALIGN(dmabuf->size) / PAGE_SIZE; - - for (i = 0; i < page_num; i++) { - dma_buf_kunmap(dmabuf, i, - (void *)(vaddr + (i * PAGE_SIZE))); - } + cam_compat_util_put_dmabuf_va(dmabuf, (void *)vaddr); /* * dma_buf_begin_cpu_access() and @@ -122,38 +102,50 @@ static int cam_mem_util_unmap_cpu_va(struct dma_buf *dmabuf, static int cam_mem_mgr_create_debug_fs(void) { - tbl.dentry = debugfs_create_dir("camera_memmgr", NULL); - if (!tbl.dentry) { - CAM_ERR(CAM_MEM, "failed to create dentry"); - return -ENOMEM; - } + int rc = 0; + struct dentry *dbgfileptr = NULL; - if (!debugfs_create_bool("alloc_profile_enable", - 0644, - tbl.dentry, - &tbl.alloc_profile_enable)) { - CAM_ERR(CAM_MEM, - "failed to create alloc_profile_enable"); - goto err; + dbgfileptr = debugfs_create_dir("camera_memmgr", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_MEM,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + tbl.dentry = dbgfileptr; - return 0; -err: - debugfs_remove_recursive(tbl.dentry); - return -ENOMEM; + debugfs_create_bool("alloc_profile_enable", 0644, + tbl.dentry, &tbl.alloc_profile_enable); +end: + return rc; } int cam_mem_mgr_init(void) { int i; int bitmap_size; + int rc = 0; memset(tbl.bufq, 0, sizeof(tbl.bufq)); + if (cam_smmu_need_force_alloc_cached(&tbl.force_cache_allocs)) { + CAM_ERR(CAM_MEM, "Error in getting force cache alloc flag"); + return -EINVAL; + } + +#if IS_REACHABLE(CONFIG_DMABUF_HEAPS) + rc = cam_mem_mgr_get_dma_heaps(); + if (rc) { + CAM_ERR(CAM_MEM, "Failed in getting dma heaps rc=%d", rc); + return rc; + } +#endif bitmap_size = BITS_TO_LONGS(CAM_MEM_BUFQ_MAX) * sizeof(long); tbl.bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!tbl.bitmap) - return -ENOMEM; + if (!tbl.bitmap) { + rc = -ENOMEM; + goto put_heaps; + } tbl.bits = bitmap_size * BITS_PER_BYTE; bitmap_zero(tbl.bitmap, tbl.bits); @@ -171,6 +163,11 @@ int cam_mem_mgr_init(void) cam_mem_mgr_create_debug_fs(); return 0; +put_heaps: +#if IS_REACHABLE(CONFIG_DMABUF_HEAPS) + cam_mem_mgr_put_dma_heaps(); +#endif + return rc; } static int32_t cam_mem_get_slot(void) @@ -333,6 +330,10 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd) goto end; } +#if IS_REACHABLE(CONFIG_DMABUF_HEAPS) + CAM_DBG(CAM_MEM, "Calling dmap buf APIs for cache operations"); + cache_dir = DMA_BIDIRECTIONAL; +#else if (dmabuf_flag & ION_FLAG_CACHED) { switch (cmd->mem_cache_ops) { case CAM_MEM_CLEAN_CACHE: @@ -354,7 +355,7 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd) CAM_DBG(CAM_MEM, "BUF is not cached"); goto end; } - +#endif rc = dma_buf_begin_cpu_access(tbl.bufq[idx].dma_buf, (cmd->mem_cache_ops == CAM_MEM_CLEAN_INV_CACHE) ? DMA_BIDIRECTIONAL : DMA_TO_DEVICE); @@ -376,67 +377,177 @@ int cam_mem_mgr_cache_ops(struct cam_mem_cache_ops_cmd *cmd) } EXPORT_SYMBOL(cam_mem_mgr_cache_ops); -static int cam_mem_util_get_dma_buf(size_t len, - unsigned int heap_id_mask, - unsigned int flags, - struct dma_buf **buf) +#if IS_REACHABLE(CONFIG_DMABUF_HEAPS) +static void cam_mem_mgr_put_dma_heaps(void) +{ + CAM_DBG(CAM_MEM, "Releasing DMA Buf heaps usage"); +} + +static int cam_mem_mgr_get_dma_heaps(void) { int rc = 0; - if (!buf) { - CAM_ERR(CAM_MEM, "Invalid params"); - return -EINVAL; + tbl.system_heap = NULL; + tbl.system_uncached_heap = NULL; + tbl.camera_heap = NULL; + tbl.camera_uncached_heap = NULL; + tbl.secure_display_heap = NULL; + + tbl.system_heap = dma_heap_find("qcom,system"); + if (IS_ERR_OR_NULL(tbl.system_heap)) { + rc = PTR_ERR(tbl.system_heap); + CAM_ERR(CAM_MEM, "qcom system heap not found, rc=%d", rc); + tbl.system_heap = NULL; + goto put_heaps; } - *buf = ion_alloc(len, heap_id_mask, flags); - if (IS_ERR_OR_NULL(*buf)) - return -ENOMEM; + tbl.system_uncached_heap = dma_heap_find("qcom,system-uncached"); + if (IS_ERR_OR_NULL(tbl.system_uncached_heap)) { + if (tbl.force_cache_allocs) { + /* optional, we anyway do not use uncached */ + CAM_DBG(CAM_MEM, + "qcom system-uncached heap not found, err=%d", + PTR_ERR(tbl.system_uncached_heap)); + tbl.system_uncached_heap = NULL; + } else { + /* fatal, must need uncached heaps */ + rc = PTR_ERR(tbl.system_uncached_heap); + CAM_ERR(CAM_MEM, + "qcom system-uncached heap not found, rc=%d", + rc); + tbl.system_uncached_heap = NULL; + goto put_heaps; + } + } + + tbl.secure_display_heap = dma_heap_find("qcom,secure-display"); + if (IS_ERR_OR_NULL(tbl.secure_display_heap)) { + rc = PTR_ERR(tbl.secure_display_heap); + CAM_ERR(CAM_MEM, "qcom,secure-display heap not found, rc=%d", + rc); + tbl.secure_display_heap = NULL; + goto put_heaps; + } + + tbl.camera_heap = dma_heap_find("qcom,camera"); + if (IS_ERR_OR_NULL(tbl.camera_heap)) { + /* optional heap, not a fatal error */ + CAM_DBG(CAM_MEM, "qcom camera heap not found, err=%d", + PTR_ERR(tbl.camera_heap)); + tbl.camera_heap = NULL; + } + tbl.camera_uncached_heap = dma_heap_find("qcom,camera-uncached"); + if (IS_ERR_OR_NULL(tbl.camera_uncached_heap)) { + /* optional heap, not a fatal error */ + CAM_DBG(CAM_MEM, "qcom camera heap not found, err=%d", + PTR_ERR(tbl.camera_uncached_heap)); + tbl.camera_uncached_heap = NULL; + } + + CAM_INFO(CAM_MEM, + "Heaps : system=%pK, system_uncached=%pK, camera=%pK, camera-uncached=%pK, secure_display=%pK", + tbl.system_heap, tbl.system_uncached_heap, + tbl.camera_heap, tbl.camera_uncached_heap, + tbl.secure_display_heap); + + return 0; +put_heaps: + cam_mem_mgr_put_dma_heaps(); return rc; } -static int cam_mem_util_get_dma_buf_fd(size_t len, - size_t align, - unsigned int heap_id_mask, - unsigned int flags, - struct dma_buf **buf, - int *fd) +static int cam_mem_util_get_dma_buf(size_t len, + unsigned int cam_flags, + struct dma_buf **buf) { - struct dma_buf *dmabuf = NULL; int rc = 0; + struct dma_heap *heap; + struct dma_heap *try_heap = NULL; struct timespec64 ts1, ts2; long microsec = 0; + bool use_cached_heap = false; - if (!buf || !fd) { - CAM_ERR(CAM_MEM, "Invalid params, buf=%pK, fd=%pK", buf, fd); + if (!buf) { + CAM_ERR(CAM_MEM, "Invalid params"); return -EINVAL; } if (tbl.alloc_profile_enable) CAM_GET_TIMESTAMP(ts1); - *buf = ion_alloc(len, heap_id_mask, flags); - if (IS_ERR_OR_NULL(*buf)) - return -ENOMEM; + if ((cam_flags & CAM_MEM_FLAG_CACHE) || + (tbl.force_cache_allocs && + (!(cam_flags & CAM_MEM_FLAG_PROTECTED_MODE)))) { + CAM_DBG(CAM_MEM, + "Using CACHED heap, cam_flags=0x%x, force_cache_allocs=%d", + cam_flags, tbl.force_cache_allocs); + use_cached_heap = true; + } else if (cam_flags & CAM_MEM_FLAG_PROTECTED_MODE) { + use_cached_heap = true; + CAM_DBG(CAM_MEM, + "Using CACHED heap for secure, cam_flags=0x%x, force_cache_allocs=%d", + cam_flags, tbl.force_cache_allocs); + } else { + use_cached_heap = false; + CAM_DBG(CAM_MEM, + "Using UNCACHED heap, cam_flags=0x%x, force_cache_allocs=%d", + cam_flags, tbl.force_cache_allocs); + } + + if ((cam_flags & CAM_MEM_FLAG_PROTECTED_MODE) && + (cam_flags & CAM_MEM_FLAG_CDSP_OUTPUT)) { + heap = tbl.secure_display_heap; + CAM_ERR(CAM_MEM, "Secure CDSP not supported yet"); + return -EBADR; + } else if (cam_flags & CAM_MEM_FLAG_PROTECTED_MODE) { + heap = tbl.secure_display_heap; + CAM_ERR(CAM_MEM, "Secure mode not supported yet"); + return -EBADR; + } + + if (use_cached_heap) { + try_heap = tbl.camera_heap; + heap = tbl.system_heap; + } else { + try_heap = tbl.camera_uncached_heap; + heap = tbl.system_uncached_heap; + } - *fd = dma_buf_fd(*buf, O_CLOEXEC); - if (*fd < 0) { - CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); - rc = -EINVAL; - goto get_fd_fail; + CAM_DBG(CAM_MEM, "Using heaps : try=%pK, heap=%pK", try_heap, heap); + + *buf = NULL; + + if (!try_heap && !heap) { + CAM_ERR(CAM_MEM, + "No heap available for allocation, cant allocate"); + return -EINVAL; } - /* - * increment the ref count so that ref count becomes 2 here - * when we close fd, refcount becomes 1 and when we do - * dmap_put_buf, ref count becomes 0 and memory will be freed. - */ - dmabuf = dma_buf_get(*fd); - if (IS_ERR_OR_NULL(dmabuf)) { - CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d", *fd); - rc = -EINVAL; + if (try_heap) { + *buf = dma_heap_buffer_alloc(try_heap, len, O_RDWR, 0); + if (IS_ERR_OR_NULL(*buf)) { + CAM_WARN(CAM_MEM, + "Failed in allocating from try heap, heap=%pK, len=%zu, err=%d", + try_heap, len, PTR_ERR(*buf)); + *buf = NULL; + } + } + + if (*buf == NULL) { + *buf = dma_heap_buffer_alloc(heap, len, O_RDWR, 0); + if (IS_ERR_OR_NULL(*buf)) { + rc = PTR_ERR(*buf); + CAM_ERR(CAM_MEM, + "Failed in allocating from heap, heap=%pK, len=%zu, err=%d", + heap, len, rc); + *buf = NULL; + return rc; + } } + CAM_DBG(CAM_MEM, "Allocate success, len=%zu, *buf=%pK", len, *buf); + if (tbl.alloc_profile_enable) { CAM_GET_TIMESTAMP(ts2); CAM_GET_TIMESTAMP_DIFF_IN_MICRO(ts1, ts2, microsec); @@ -445,26 +556,32 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, } return rc; - -get_fd_fail: - dma_buf_put(*buf); - return rc; } - -static int cam_mem_util_ion_alloc(struct cam_mem_mgr_alloc_cmd *cmd, - struct dma_buf **dmabuf, - int *fd) +#else +static int cam_mem_util_get_dma_buf(size_t len, + unsigned int cam_flags, + struct dma_buf **buf) { - uint32_t heap_id; - uint32_t ion_flag = 0; - int rc; + int rc = 0; + unsigned int heap_id; + int32_t ion_flag = 0; + struct timespec64 ts1, ts2; + long microsec = 0; + + if (!buf) { + CAM_ERR(CAM_MEM, "Invalid params"); + return -EINVAL; + } - if ((cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE) && - (cmd->flags & CAM_MEM_FLAG_CDSP_OUTPUT)) { + if (tbl.alloc_profile_enable) + CAM_GET_TIMESTAMP(ts1); + + if ((cam_flags & CAM_MEM_FLAG_PROTECTED_MODE) && + (cam_flags & CAM_MEM_FLAG_CDSP_OUTPUT)) { heap_id = ION_HEAP(ION_SECURE_DISPLAY_HEAP_ID); ion_flag |= ION_FLAG_SECURE | ION_FLAG_CP_CAMERA | ION_FLAG_CP_CDSP; - } else if (cmd->flags & CAM_MEM_FLAG_PROTECTED_MODE) { + } else if (cam_flags & CAM_MEM_FLAG_PROTECTED_MODE) { heap_id = ION_HEAP(ION_SECURE_DISPLAY_HEAP_ID); ion_flag |= ION_FLAG_SECURE | ION_FLAG_CP_CAMERA; } else { @@ -472,21 +589,74 @@ static int cam_mem_util_ion_alloc(struct cam_mem_mgr_alloc_cmd *cmd, ION_HEAP(ION_CAMERA_HEAP_ID); } - if (cmd->flags & CAM_MEM_FLAG_CACHE) + if (cam_flags & CAM_MEM_FLAG_CACHE) ion_flag |= ION_FLAG_CACHED; else ion_flag &= ~ION_FLAG_CACHED; - rc = cam_mem_util_get_dma_buf_fd(cmd->len, - cmd->align, - heap_id, - ion_flag, - dmabuf, - fd); + if (tbl.force_cache_allocs && (!(ion_flag & ION_FLAG_SECURE))) + ion_flag |= ION_FLAG_CACHED; + + *buf = ion_alloc(len, heap_id, ion_flag); + if (IS_ERR_OR_NULL(*buf)) + return -ENOMEM; + + if (tbl.alloc_profile_enable) { + CAM_GET_TIMESTAMP(ts2); + CAM_GET_TIMESTAMP_DIFF_IN_MICRO(ts1, ts2, microsec); + trace_cam_log_event("IONAllocProfile", "size and time in micro", + len, microsec); + } return rc; } +#endif + +static int cam_mem_util_buffer_alloc(struct cam_mem_mgr_alloc_cmd *cmd, + struct dma_buf **dmabuf, + int *fd) +{ + int rc; + struct dma_buf *temp_dmabuf = NULL; + + rc = cam_mem_util_get_dma_buf(cmd->len, + cmd->flags, + dmabuf); + if (rc) { + CAM_ERR(CAM_MEM, + "Error allocating dma buf : len=%llu, flags=0x%x", + cmd->len, cmd->flags); + return rc; + } + + *fd = dma_buf_fd(*dmabuf, O_CLOEXEC); + if (*fd < 0) { + CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); + rc = -EINVAL; + goto put_buf; + } + CAM_DBG(CAM_MEM, "Alloc success : len=%zu, *dmabuf=%pK, fd=%d", + cmd->len, *dmabuf, *fd); + + /* + * increment the ref count so that ref count becomes 2 here + * when we close fd, refcount becomes 1 and when we do + * dmap_put_buf, ref count becomes 0 and memory will be freed. + */ + temp_dmabuf = dma_buf_get(*fd); + if (IS_ERR_OR_NULL(temp_dmabuf)) { + CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d", *fd); + rc = -EINVAL; + goto put_buf; + } + + return rc; + +put_buf: + dma_buf_put(*dmabuf); + return rc; +} static int cam_mem_util_check_alloc_flags(struct cam_mem_mgr_alloc_cmd *cmd) { @@ -637,7 +807,7 @@ int cam_mem_mgr_alloc_and_map(struct cam_mem_mgr_alloc_cmd *cmd) return rc; } - rc = cam_mem_util_ion_alloc(cmd, + rc = cam_mem_util_buffer_alloc(cmd, &dmabuf, &fd); if (rc) { @@ -909,6 +1079,10 @@ static void cam_mem_mgr_unmap_active_buf(int idx) region = CAM_SMMU_REGION_IO; cam_mem_util_unmap_hw_va(idx, region, CAM_SMMU_MAPPING_USER); + + if (tbl.bufq[idx].flags & CAM_MEM_FLAG_KMD_ACCESS) + cam_mem_util_unmap_cpu_va(tbl.bufq[idx].dma_buf, + tbl.bufq[idx].kmdvaddr); } static int cam_mem_mgr_cleanup_table(void) @@ -1096,8 +1270,6 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp, struct dma_buf *buf = NULL; int ion_fd = -1; int rc = 0; - uint32_t heap_id; - int32_t ion_flag = 0; uintptr_t kvaddr; dma_addr_t iova = 0; size_t request_len = 0; @@ -1125,17 +1297,8 @@ int cam_mem_mgr_request_mem(struct cam_mem_mgr_request_desc *inp, return -EINVAL; } - if (inp->flags & CAM_MEM_FLAG_CACHE) - ion_flag |= ION_FLAG_CACHED; - else - ion_flag &= ~ION_FLAG_CACHED; - - heap_id = ION_HEAP(ION_SYSTEM_HEAP_ID) | - ION_HEAP(ION_CAMERA_HEAP_ID); - rc = cam_mem_util_get_dma_buf(inp->size, - heap_id, - ion_flag, + inp->flags, &buf); if (rc) { @@ -1278,7 +1441,6 @@ int cam_mem_mgr_reserve_memory_region(struct cam_mem_mgr_request_desc *inp, struct dma_buf *buf = NULL; int rc = 0; int ion_fd = -1; - uint32_t heap_id; dma_addr_t iova = 0; size_t request_len = 0; uint32_t mem_handle; @@ -1306,10 +1468,7 @@ int cam_mem_mgr_reserve_memory_region(struct cam_mem_mgr_request_desc *inp, return -EINVAL; } - heap_id = ION_HEAP(ION_SYSTEM_HEAP_ID) | - ION_HEAP(ION_CAMERA_HEAP_ID); rc = cam_mem_util_get_dma_buf(inp->size, - heap_id, 0, &buf); diff --git a/drivers/cam_req_mgr/cam_mem_mgr.h b/drivers/cam_req_mgr/cam_mem_mgr.h index 2c692a076..82eb8c8e0 100644 --- a/drivers/cam_req_mgr/cam_mem_mgr.h +++ b/drivers/cam_req_mgr/cam_mem_mgr.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved. */ #ifndef _CAM_MEM_MGR_H_ @@ -8,6 +8,9 @@ #include #include +#if IS_REACHABLE(CONFIG_DMABUF_HEAPS) +#include +#endif #include #include "cam_mem_mgr_api.h" @@ -68,6 +71,7 @@ struct cam_mem_buf_queue { * @dentry: Debugfs entry * @alloc_profile_enable: Whether to enable alloc profiling * @dbg_buf_idx: debug buffer index to get usecases info + * @force_cache_allocs: Force all internal buffer allocations with cache */ struct cam_mem_table { struct mutex m_lock; @@ -77,6 +81,15 @@ struct cam_mem_table { struct dentry *dentry; bool alloc_profile_enable; size_t dbg_buf_idx; + bool force_cache_allocs; +#if IS_REACHABLE(CONFIG_DMABUF_HEAPS) + struct dma_heap *system_heap; + struct dma_heap *system_uncached_heap; + struct dma_heap *camera_heap; + struct dma_heap *camera_uncached_heap; + struct dma_heap *secure_display_heap; +#endif + }; /** diff --git a/drivers/cam_req_mgr/cam_req_mgr_core.h b/drivers/cam_req_mgr/cam_req_mgr_core.h index c638f4f79..21b3c8f2e 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_core.h +++ b/drivers/cam_req_mgr/cam_req_mgr_core.h @@ -6,7 +6,7 @@ #ifndef _CAM_REQ_MGR_CORE_H_ #define _CAM_REQ_MGR_CORE_H_ -#include +#include #include "cam_req_mgr_interface.h" #include "cam_req_mgr_core_defs.h" #include "cam_req_mgr_timer.h" diff --git a/drivers/cam_req_mgr/cam_req_mgr_debug.c b/drivers/cam_req_mgr/cam_req_mgr_debug.c index 5de86c66b..7dee3d73a 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_debug.c +++ b/drivers/cam_req_mgr/cam_req_mgr_debug.c @@ -111,29 +111,29 @@ static const struct file_operations session_info = { .write = session_info_write, }; +static struct dentry *debugfs_root; int cam_req_mgr_debug_register(struct cam_req_mgr_core_device *core_dev) { - struct dentry *debugfs_root; - char dirname[32] = {0}; - - snprintf(dirname, sizeof(dirname), "cam_req_mgr"); - debugfs_root = debugfs_create_dir(dirname, NULL); - if (!debugfs_root) - return -ENOMEM; - - if (!debugfs_create_file("sessions_info", 0644, - debugfs_root, core_dev, &session_info)) - return -ENOMEM; - - if (!debugfs_create_file("bubble_recovery", 0644, - debugfs_root, core_dev, &bubble_recovery)) - return -ENOMEM; - - if (!debugfs_create_u32("delay_detect_count", 0644, - debugfs_root, &cam_debug_mgr_delay_detect)) - return -ENOMEM; + int rc = 0; + struct dentry *dbgfileptr = NULL; - return 0; + dbgfileptr = debugfs_create_dir("cam_req_mgr", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_MEM,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; + } + /* Store parent inode for cleanup in caller */ + debugfs_root = dbgfileptr; + + debugfs_create_file("sessions_info", 0644, debugfs_root, + core_dev, &session_info); + debugfs_create_file("bubble_recovery", 0644, + debugfs_root, core_dev, &bubble_recovery); + debugfs_create_u32("delay_detect_count", 0644, + debugfs_root, &cam_debug_mgr_delay_detect); +end: + return rc; } void cam_req_mgr_debug_delay_detect(void) diff --git a/drivers/cam_req_mgr/cam_req_mgr_debug.h b/drivers/cam_req_mgr/cam_req_mgr_debug.h index ff169baed..332697022 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_debug.h +++ b/drivers/cam_req_mgr/cam_req_mgr_debug.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_REQ_MGR_DEBUG_H_ @@ -8,6 +9,7 @@ #include #include "cam_req_mgr_core.h" +#include "cam_debug_util.h" int cam_req_mgr_debug_register(struct cam_req_mgr_core_device *core_dev); diff --git a/drivers/cam_req_mgr/cam_req_mgr_dev.c b/drivers/cam_req_mgr/cam_req_mgr_dev.c index 1d2373ef7..b4339620c 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_dev.c +++ b/drivers/cam_req_mgr/cam_req_mgr_dev.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -609,10 +610,15 @@ static int cam_video_device_setup(void) g_dev.video->fops = &g_cam_fops; g_dev.video->ioctl_ops = &g_cam_ioctl_ops; g_dev.video->minor = -1; - g_dev.video->vfl_type = VFL_TYPE_GRABBER; - rc = video_register_device(g_dev.video, VFL_TYPE_GRABBER, -1); - if (rc) + g_dev.video->vfl_type = VFL_TYPE_VIDEO; + g_dev.video->device_caps |= V4L2_CAP_VIDEO_CAPTURE; + rc = video_register_device(g_dev.video, VFL_TYPE_VIDEO, -1); + if (rc) { + CAM_ERR(CAM_CRM, + "video device registration failure rc = %d, name = %s, device_caps = %d", + rc, g_dev.video->name, g_dev.video->device_caps); goto v4l2_fail; + } rc = media_entity_pads_init(&g_dev.video->entity, 0, NULL); if (rc) @@ -660,12 +666,6 @@ void cam_video_device_cleanup(void) g_dev.video = NULL; } -void cam_register_subdev_fops(struct v4l2_file_operations *fops) -{ - *fops = v4l2_subdev_fops; -} -EXPORT_SYMBOL(cam_register_subdev_fops); - void cam_subdev_notify_message(u32 subdev_type, enum cam_subdev_message_type_t message_type, uint32_t data) @@ -717,15 +717,6 @@ int cam_register_subdev(struct cam_subdev *csd) } mutex_lock(&g_dev.dev_lock); - if ((g_dev.subdev_nodes_created) && - (csd->sd_flags & V4L2_SUBDEV_FL_HAS_DEVNODE)) { - CAM_ERR(CAM_CRM, - "dynamic node is not allowed, name: %s, type :%d", - csd->name, csd->ent_function); - rc = -EINVAL; - goto reg_fail; - } - sd = &csd->sd; v4l2_subdev_init(sd, csd->ops); sd->internal_ops = csd->internal_ops; @@ -737,11 +728,34 @@ int cam_register_subdev(struct cam_subdev *csd) sd->entity.pads = NULL; sd->entity.function = csd->ent_function; + if (csd->subdev_node_created) { + CAM_ERR(CAM_CRM, + "Dynamic Node is not allowed, name: %s, type: %d", + csd->name, csd->ent_function); + rc = -EINVAL; + goto reg_fail; + } + rc = v4l2_device_register_subdev(g_dev.v4l2_dev, sd); if (rc) { CAM_ERR(CAM_CRM, "register subdev failed"); goto reg_fail; } + + rc = v4l2_device_register_subdev_nodes(g_dev.v4l2_dev); + if (rc) { + CAM_ERR(CAM_CRM, + "Device Register subdev node failed: rc = %d", rc); + goto reg_fail; + + } + + if ((sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)) { + sd->entity.name = video_device_node_name(sd->devnode); + CAM_DBG(CAM_CRM, "created node :%s", sd->entity.name); + } + + csd->subdev_node_created = true; g_dev.count++; reg_fail: @@ -775,7 +789,6 @@ static int cam_req_mgr_remove(struct platform_device *pdev) cam_v4l2_device_cleanup(); mutex_destroy(&g_dev.dev_lock); g_dev.state = false; - g_dev.subdev_nodes_created = false; return 0; } @@ -799,7 +812,6 @@ static int cam_req_mgr_probe(struct platform_device *pdev) g_dev.open_cnt = 0; mutex_init(&g_dev.cam_lock); spin_lock_init(&g_dev.cam_eventq_lock); - g_dev.subdev_nodes_created = false; mutex_init(&g_dev.dev_lock); rc = cam_req_mgr_util_init(); @@ -814,8 +826,6 @@ static int cam_req_mgr_probe(struct platform_device *pdev) goto req_mgr_core_fail; } - g_dev.state = true; - if (g_cam_req_mgr_timer_cachep == NULL) { g_cam_req_mgr_timer_cachep = kmem_cache_create("crm_timer", sizeof(struct cam_req_mgr_timer), 64, @@ -829,6 +839,7 @@ static int cam_req_mgr_probe(struct platform_device *pdev) g_cam_req_mgr_timer_cachep->name); } + g_dev.state = true; return rc; req_mgr_core_fail: @@ -848,7 +859,7 @@ static const struct of_device_id cam_req_mgr_dt_match[] = { {.compatible = "qcom,cam-req-mgr"}, {} }; -MODULE_DEVICE_TABLE(of, cam_dt_match); +MODULE_DEVICE_TABLE(of, cam_req_mgr_dt_match); static struct platform_driver cam_req_mgr_driver = { .probe = cam_req_mgr_probe, @@ -861,62 +872,16 @@ static struct platform_driver cam_req_mgr_driver = { }, }; -int cam_dev_mgr_create_subdev_nodes(void) -{ - int rc; - struct v4l2_subdev *sd; - - if (!g_dev.v4l2_dev) - return -EINVAL; - - if (g_dev.state != true) { - CAM_ERR(CAM_CRM, "camera root device not ready yet"); - return -ENODEV; - } - - mutex_lock(&g_dev.dev_lock); - if (g_dev.subdev_nodes_created) { - rc = -EEXIST; - goto create_fail; - } - - rc = v4l2_device_register_subdev_nodes(g_dev.v4l2_dev); - if (rc) { - CAM_ERR(CAM_CRM, "failed to register the sub devices"); - goto create_fail; - } - - list_for_each_entry(sd, &g_dev.v4l2_dev->subdevs, list) { - if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE)) - continue; - sd->entity.name = video_device_node_name(sd->devnode); - CAM_DBG(CAM_CRM, "created node :%s", sd->entity.name); - } - - g_dev.subdev_nodes_created = true; - -create_fail: - mutex_unlock(&g_dev.dev_lock); - return rc; -} - -static int __init cam_req_mgr_init(void) +int cam_req_mgr_init(void) { return platform_driver_register(&cam_req_mgr_driver); } +EXPORT_SYMBOL(cam_req_mgr_init); -static int __init cam_req_mgr_late_init(void) -{ - return cam_dev_mgr_create_subdev_nodes(); -} - -static void __exit cam_req_mgr_exit(void) +void cam_req_mgr_exit(void) { platform_driver_unregister(&cam_req_mgr_driver); } -module_init(cam_req_mgr_init); -late_initcall(cam_req_mgr_late_init); -module_exit(cam_req_mgr_exit); MODULE_DESCRIPTION("Camera Request Manager"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_req_mgr/cam_req_mgr_dev.h b/drivers/cam_req_mgr/cam_req_mgr_dev.h index ccf4854a0..9026f74b4 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_dev.h +++ b/drivers/cam_req_mgr/cam_req_mgr_dev.h @@ -1,17 +1,17 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #ifndef _CAM_REQ_MGR_DEV_H_ #define _CAM_REQ_MGR_DEV_H_ +#include "media/cam_req_mgr.h" /** * struct cam_req_mgr_device - a camera request manager device * * @video: pointer to struct video device. * @v4l2_dev: pointer to struct v4l2 device. - * @subdev_nodes_created: flag to check the created state. * @count: number of subdevices registered. * @dev_lock: lock for the subdevice count. * @state: state of the root device. @@ -24,7 +24,6 @@ struct cam_req_mgr_device { struct video_device *video; struct v4l2_device *v4l2_dev; - bool subdev_nodes_created; int count; struct mutex dev_lock; bool state; @@ -42,4 +41,15 @@ int cam_req_mgr_notify_message(struct cam_req_mgr_message *msg, uint32_t id, uint32_t type); +/** + * @brief : API to register REQ_MGR to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_req_mgr_init(void); + +/** + * @brief : API to remove REQ_MGR from platform framework. + */ +void cam_req_mgr_exit(void); + #endif /* _CAM_REQ_MGR_DEV_H_ */ diff --git a/drivers/cam_req_mgr/cam_req_mgr_util.c b/drivers/cam_req_mgr/cam_req_mgr_util.c index 64683eeb2..871bcff72 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_util.c +++ b/drivers/cam_req_mgr/cam_req_mgr_util.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include "cam_req_mgr_util.h" diff --git a/drivers/cam_req_mgr/cam_subdev.h b/drivers/cam_req_mgr/cam_subdev.h index 783b33a55..efc087a76 100644 --- a/drivers/cam_req_mgr/cam_subdev.h +++ b/drivers/cam_req_mgr/cam_subdev.h @@ -62,6 +62,7 @@ struct cam_subdev { struct v4l2_subdev *sd, enum cam_subdev_message_type_t msg_type, uint32_t data); + bool subdev_node_created; }; /** @@ -101,15 +102,6 @@ int cam_subdev_probe(struct cam_subdev *sd, struct platform_device *pdev, */ int cam_subdev_remove(struct cam_subdev *sd); -/** - * cam_register_subdev_fops() - * - * @brief: This common utility function assigns subdev ops - * - * @fops: v4l file operations - */ -void cam_register_subdev_fops(struct v4l2_file_operations *fops); - /** * cam_register_subdev() * diff --git a/drivers/cam_sensor_module/Makefile b/drivers/cam_sensor_module/Makefile deleted file mode 100644 index 6925b3aba..000000000 --- a/drivers/cam_sensor_module/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_res_mgr/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_utils/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cci/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_io/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_csiphy/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_actuator/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_eeprom/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_ois/ -obj-$(CONFIG_SPECTRA_CAMERA) += cam_flash/ diff --git a/drivers/cam_sensor_module/cam_actuator/Makefile b/drivers/cam_sensor_module/cam_actuator/Makefile deleted file mode 100644 index e61c6eeba..000000000 --- a/drivers/cam_sensor_module/cam_actuator/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils - - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_actuator_dev.o cam_actuator_core.o cam_actuator_soc.o diff --git a/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.c b/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.c index 46bd99fc9..92c9e6591 100644 --- a/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.c +++ b/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include "cam_actuator_dev.h" @@ -413,7 +413,7 @@ static struct i2c_driver cam_actuator_driver_i2c = { }, }; -static int __init cam_actuator_driver_init(void) +int cam_actuator_driver_init(void) { int32_t rc = 0; @@ -430,13 +430,11 @@ static int __init cam_actuator_driver_init(void) return rc; } -static void __exit cam_actuator_driver_exit(void) +void cam_actuator_driver_exit(void) { platform_driver_unregister(&cam_actuator_platform_driver); i2c_del_driver(&cam_actuator_driver_i2c); } -module_init(cam_actuator_driver_init); -module_exit(cam_actuator_driver_exit); MODULE_DESCRIPTION("cam_actuator_driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.h b/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.h index e4bfaed44..1ec575301 100644 --- a/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.h +++ b/drivers/cam_sensor_module/cam_actuator/cam_actuator_dev.h @@ -64,13 +64,13 @@ struct cam_actuator_soc_private { }; /** - * struct intf_params + * struct actuator_intf_params * @device_hdl: Device Handle * @session_hdl: Session Handle * @ops: KMD operations * @crm_cb: Callback API pointers */ -struct intf_params { +struct actuator_intf_params { int32_t device_hdl; int32_t session_hdl; int32_t link_hdl; @@ -113,8 +113,18 @@ struct cam_actuator_ctrl_t { struct cam_subdev v4l2_dev_str; struct i2c_data_settings i2c_data; struct cam_actuator_query_cap act_info; - struct intf_params bridge_intf; + struct actuator_intf_params bridge_intf; uint32_t last_flush_req; }; +/** + * @brief : API to register Actuator hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_actuator_driver_init(void); + +/** + * @brief : API to remove Actuator Hw from platform framework. + */ +void cam_actuator_driver_exit(void); #endif /* _CAM_ACTUATOR_DEV_H_ */ diff --git a/drivers/cam_sensor_module/cam_cci/Makefile b/drivers/cam_sensor_module/cam_cci/Makefile deleted file mode 100644 index a1301bf41..000000000 --- a/drivers/cam_sensor_module/cam_cci/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree) - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cci_dev.o cam_cci_core.o cam_cci_soc.o diff --git a/drivers/cam_sensor_module/cam_cci/cam_cci_dev.c b/drivers/cam_sensor_module/cam_cci/cam_cci_dev.c index 4ce815b63..dff997ab9 100644 --- a/drivers/cam_sensor_module/cam_cci/cam_cci_dev.c +++ b/drivers/cam_sensor_module/cam_cci/cam_cci_dev.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include "cam_cci_dev.h" @@ -335,7 +336,6 @@ irqreturn_t cam_cci_irq(int irq_num, void *data) cam_io_w_mb(irq_update_rd_done, base + CCI_IRQ_MASK_1_ADDR); } - cam_io_w_mb(irq_status1, base + CCI_IRQ_CLEAR_1_ADDR); cam_io_w_mb(0x1, base + CCI_IRQ_GLOBAL_CLEAR_CMD_ADDR); return IRQ_HANDLED; @@ -368,34 +368,6 @@ static const struct v4l2_subdev_ops cci_subdev_ops = { static const struct v4l2_subdev_internal_ops cci_subdev_intern_ops; -static struct v4l2_file_operations cci_v4l2_subdev_fops; - -static long cam_cci_subdev_do_ioctl( - struct file *file, unsigned int cmd, void *arg) -{ - struct video_device *vdev = video_devdata(file); - struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); - - return cam_cci_subdev_ioctl(sd, cmd, NULL); -} - -static long cam_cci_subdev_fops_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - return video_usercopy(file, cmd, arg, cam_cci_subdev_do_ioctl); -} - -#ifdef CONFIG_COMPAT -static long cam_cci_subdev_fops_compat_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) -{ - struct video_device *vdev = video_devdata(file); - struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev); - - return v4l2_subdev_call(sd, core, ioctl, cmd, NULL); -} -#endif - static int cam_cci_get_debug(void *data, u64 *val) { struct cci_device *cci_dev = (struct cci_device *)data; @@ -518,13 +490,6 @@ static int cam_cci_platform_probe(struct platform_device *pdev) mutex_init(&(new_cci_dev->init_mutex)); CAM_INFO(CAM_CCI, "Device Type :%d", soc_info->index); - cam_register_subdev_fops(&cci_v4l2_subdev_fops); - cci_v4l2_subdev_fops.unlocked_ioctl = cam_cci_subdev_fops_ioctl; -#ifdef CONFIG_COMPAT - cci_v4l2_subdev_fops.compat_ioctl32 = - cam_cci_subdev_fops_compat_ioctl; -#endif - cpas_parms.cam_cpas_client_cb = NULL; cpas_parms.cell_index = soc_info->index; cpas_parms.dev = &pdev->dev; @@ -584,44 +549,15 @@ static struct platform_driver cci_driver = { }, }; -static int cam_cci_assign_fops(void) -{ - struct v4l2_subdev *sd; - int i = 0; - - for (; i < MAX_CCI; i++) { - sd = g_cci_subdev[i]; - if (!sd) - return 0; - if (!(sd->devnode)) { - CAM_ERR(CAM_CCI, - "Invalid dev node:%pK offset: %d", - sd->devnode, i); - return -EINVAL; - } - sd->devnode->fops = &cci_v4l2_subdev_fops; - } - - return 0; -} - -static int __init cam_cci_late_init(void) -{ - return cam_cci_assign_fops(); -} - -static int __init cam_cci_init_module(void) +int cam_cci_init_module(void) { return platform_driver_register(&cci_driver); } -static void __exit cam_cci_exit_module(void) +void cam_cci_exit_module(void) { platform_driver_unregister(&cci_driver); } -module_init(cam_cci_init_module); -late_initcall(cam_cci_late_init); -module_exit(cam_cci_exit_module); MODULE_DESCRIPTION("MSM CCI driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h b/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h index 00dabdfd6..25f70d320 100644 --- a/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h +++ b/drivers/cam_sensor_module/cam_cci/cam_cci_dev.h @@ -312,6 +312,16 @@ struct v4l2_subdev *cam_cci_get_subdev(int cci_dev_index); void cam_cci_dump_registers(struct cci_device *cci_dev, enum cci_i2c_master_t master, enum cci_i2c_queue_t queue); +/** + * @brief : API to register CCI hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_cci_init_module(void); + +/** + * @brief : API to remove CCI Hw from platform framework. + */ +void cam_cci_exit_module(void); #define VIDIOC_MSM_CCI_CFG \ _IOWR('V', BASE_VIDIOC_PRIVATE + 23, struct cam_cci_ctrl) diff --git a/drivers/cam_sensor_module/cam_csiphy/Makefile b/drivers/cam_sensor_module/cam_csiphy/Makefile deleted file mode 100644 index d98b84574..000000000 --- a/drivers/cam_sensor_module/cam_csiphy/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_csiphy_soc.o cam_csiphy_dev.o cam_csiphy_core.o diff --git a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c index bc7017f2c..77288db35 100644 --- a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c +++ b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_core.c @@ -1,24 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include + +#include + +#include "cam_compat.h" #include "cam_csiphy_core.h" #include "cam_csiphy_dev.h" #include "cam_csiphy_soc.h" #include "cam_common_util.h" #include "cam_packet_util.h" - -#include - -#include -#include -#include - -#define SCM_SVC_CAMERASS 0x18 -#define SECURE_SYSCALL_ID 0x6 -#define SECURE_SYSCALL_ID_2 0x7 +#include "cam_mem_mgr.h" +#include "cam_cpas_api.h" #define LANE_MASK_2PH 0x1F #define LANE_MASK_3PH 0x7 @@ -29,34 +26,6 @@ static int csiphy_dump; module_param(csiphy_dump, int, 0644); -static int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, - bool protect, int32_t offset) -{ - struct scm_desc desc = {0}; - - if (offset >= CSIPHY_MAX_INSTANCES) { - CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset"); - return -EINVAL; - } - - desc.arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL); - desc.args[0] = protect; - desc.args[1] = csiphy_dev->csiphy_cpas_cp_reg_mask[offset]; - - if (scm_call2(SCM_SIP_FNID(SCM_SVC_CAMERASS, SECURE_SYSCALL_ID_2), - &desc)) { - CAM_ERR(CAM_CSIPHY, "scm call to hypervisor failed"); - return -EINVAL; - } - CAM_INFO(CAM_CSIPHY, "PHY : %d offset: %d SEC: %d Mask: %d", - csiphy_dev->soc_info.index, - offset, - protect, - csiphy_dev->csiphy_cpas_cp_reg_mask[offset]); - - return 0; -} - int32_t cam_csiphy_get_instance_offset( struct csiphy_device *csiphy_dev, int32_t dev_handle) @@ -691,7 +660,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev, { struct csiphy_device *csiphy_dev = (struct csiphy_device *)phy_dev; - struct intf_params *bridge_intf = NULL; + struct csiphy_intf_params *bridge_intf = NULL; struct cam_control *cmd = (struct cam_control *)arg; int32_t rc = 0; diff --git a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c index 987da8efb..586345930 100644 --- a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c +++ b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.c @@ -261,17 +261,15 @@ static struct platform_driver csiphy_driver = { }, }; -static int32_t __init cam_csiphy_init_module(void) +int32_t cam_csiphy_init_module(void) { return platform_driver_register(&csiphy_driver); } -static void __exit cam_csiphy_exit_module(void) +void cam_csiphy_exit_module(void) { platform_driver_unregister(&csiphy_driver); } -module_init(cam_csiphy_init_module); -module_exit(cam_csiphy_exit_module); MODULE_DESCRIPTION("CAM CSIPHY driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h index a2b073803..e7c4865c7 100644 --- a/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h +++ b/drivers/cam_sensor_module/cam_csiphy/cam_csiphy_dev.h @@ -121,13 +121,13 @@ struct csiphy_reg_parms_t { }; /** - * struct intf_params + * struct csiphy_intf_params * @device_hdl: Device Handle * @session_hdl: Session Handle * @ops: KMD operations * @crm_cb: Callback API pointers */ -struct intf_params { +struct csiphy_intf_params { int32_t device_hdl[CSIPHY_MAX_INSTANCES]; int32_t session_hdl[CSIPHY_MAX_INSTANCES]; int32_t link_hdl[CSIPHY_MAX_INSTANCES]; @@ -282,7 +282,7 @@ struct csiphy_device { uint8_t num_irq_registers; struct cam_subdev v4l2_dev_str; struct cam_csiphy_param csiphy_info; - struct intf_params bridge_intf; + struct csiphy_intf_params bridge_intf; uint32_t clk_lane; uint32_t acquire_count; uint32_t start_dev_count; @@ -293,4 +293,14 @@ struct csiphy_device { uint64_t csiphy_cpas_cp_reg_mask[CSIPHY_MAX_INSTANCES]; }; +/** + * @brief : API to register CSIPHY hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int32_t cam_csiphy_init_module(void); + +/** + * @brief : API to remove CSIPHY Hw from platform framework. + */ +void cam_csiphy_exit_module(void); #endif /* _CAM_CSIPHY_DEV_H_ */ diff --git a/drivers/cam_sensor_module/cam_eeprom/Makefile b/drivers/cam_sensor_module/cam_eeprom/Makefile deleted file mode 100644 index 7a676c113..000000000 --- a/drivers/cam_sensor_module/cam_eeprom/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_eeprom_dev.o cam_eeprom_core.o cam_eeprom_soc.o diff --git a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c index 328541553..5fedbed5a 100644 --- a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c +++ b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.c @@ -555,7 +555,7 @@ static struct spi_driver cam_eeprom_spi_driver = { .probe = cam_eeprom_spi_driver_probe, .remove = cam_eeprom_spi_driver_remove, }; -static int __init cam_eeprom_driver_init(void) +int cam_eeprom_driver_init(void) { int rc = 0; @@ -581,14 +581,12 @@ static int __init cam_eeprom_driver_init(void) return rc; } -static void __exit cam_eeprom_driver_exit(void) +void cam_eeprom_driver_exit(void) { platform_driver_unregister(&cam_eeprom_platform_driver); spi_unregister_driver(&cam_eeprom_spi_driver); i2c_del_driver(&cam_eeprom_i2c_driver); } -module_init(cam_eeprom_driver_init); -module_exit(cam_eeprom_driver_exit); MODULE_DESCRIPTION("CAM EEPROM driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h index 66f8aaddc..7f2f27687 100644 --- a/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h +++ b/drivers/cam_sensor_module/cam_eeprom/cam_eeprom_dev.h @@ -195,4 +195,15 @@ struct cam_eeprom_ctrl_t { int32_t cam_eeprom_update_i2c_info(struct cam_eeprom_ctrl_t *e_ctrl, struct cam_eeprom_i2c_info_t *i2c_info); +/** + * @brief : API to register EEPROM hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_eeprom_driver_init(void); + +/** + * @brief : API to remove EEPROM Hw from platform framework. + */ +void cam_eeprom_driver_exit(void); + #endif /*_CAM_EEPROM_DEV_H_ */ diff --git a/drivers/cam_sensor_module/cam_flash/Makefile b/drivers/cam_sensor_module/cam_flash/Makefile deleted file mode 100644 index da9e9e1b1..000000000 --- a/drivers/cam_sensor_module/cam_flash/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_res_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_flash_dev.o cam_flash_core.o cam_flash_soc.o diff --git a/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c b/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c index 947117c33..d2eb034e2 100644 --- a/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c +++ b/drivers/cam_sensor_module/cam_flash/cam_flash_dev.c @@ -693,7 +693,7 @@ static struct i2c_driver cam_flash_i2c_driver = { }, }; -static int32_t __init cam_flash_init_module(void) +int32_t cam_flash_init_module(void) { int32_t rc = 0; @@ -708,13 +708,11 @@ static int32_t __init cam_flash_init_module(void) return rc; } -static void __exit cam_flash_exit_module(void) +void cam_flash_exit_module(void) { platform_driver_unregister(&cam_flash_platform_driver); i2c_del_driver(&cam_flash_i2c_driver); } -module_init(cam_flash_init_module); -module_exit(cam_flash_exit_module); MODULE_DESCRIPTION("CAM FLASH"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_flash/cam_flash_dev.h b/drivers/cam_sensor_module/cam_flash/cam_flash_dev.h index 28f2fa14e..b6f93275c 100644 --- a/drivers/cam_sensor_module/cam_flash/cam_flash_dev.h +++ b/drivers/cam_sensor_module/cam_flash/cam_flash_dev.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2017-2019, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_FLASH_DEV_H_ @@ -13,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -28,6 +28,7 @@ #include "cam_soc_util.h" #include "cam_debug_util.h" #include "cam_sensor_io.h" +#include "cam_flash_leds.h" #include "cam_flash_core.h" #include "cam_context.h" @@ -233,4 +234,14 @@ int cam_flash_pmic_flush_request(struct cam_flash_ctrl *fctrl, void cam_flash_shutdown(struct cam_flash_ctrl *fctrl); int cam_flash_release_dev(struct cam_flash_ctrl *fctrl); +/** + * @brief : API to register FLASH hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int32_t cam_flash_init_module(void); + +/** + * @brief : API to remove FLASH Hw from platform framework. + */ +void cam_flash_exit_module(void); #endif /*_CAM_FLASH_DEV_H_*/ diff --git a/drivers/cam_sensor_module/cam_flash/cam_flash_leds.h b/drivers/cam_sensor_module/cam_flash/cam_flash_leds.h new file mode 100644 index 000000000..ff92d1bee --- /dev/null +++ b/drivers/cam_sensor_module/cam_flash/cam_flash_leds.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef __CAM_FLASH_LEDS_H +#define __CAM_FLASH_LEDS_H + +#include + +#define ENABLE_REGULATOR BIT(0) +#define DISABLE_REGULATOR BIT(1) +#define QUERY_MAX_AVAIL_CURRENT BIT(2) +#define QUERY_MAX_CURRENT BIT(3) + +#define FLASH_LED_PREPARE_OPTIONS_MASK GENMASK(3, 0) + +int qpnp_flash_register_led_prepare(struct device *dev, void *data); + +#if (defined CONFIG_LEDS_QTI_FLASH || defined CONFIG_LEDS_QPNP_FLASH_V2) +int qpnp_flash_led_prepare(struct led_trigger *trig, int options, + int *max_current); +#else +static inline int qpnp_flash_led_prepare(struct led_trigger *trig, int options, + int *max_current) +{ + return -ENODEV; +} +#endif + +#ifdef CONFIG_BACKLIGHT_QCOM_SPMI_WLED +int wled_flash_led_prepare(struct led_trigger *trig, int options, + int *max_current); +#else +static inline int wled_flash_led_prepare(struct led_trigger *trig, int options, + int *max_current) +{ + return -EINVAL; +} +#endif + +#endif diff --git a/drivers/cam_sensor_module/cam_flash/cam_flash_soc.c b/drivers/cam_sensor_module/cam_flash/cam_flash_soc.c index 4b3ee2f62..0f84596b9 100644 --- a/drivers/cam_sensor_module/cam_flash/cam_flash_soc.c +++ b/drivers/cam_sensor_module/cam_flash/cam_flash_soc.c @@ -1,13 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2018, 2020, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include #include "cam_flash_soc.h" #include "cam_res_mgr_api.h" -#include +#include static int32_t cam_get_source_node_info( struct device_node *of_node, diff --git a/drivers/cam_sensor_module/cam_ois/Makefile b/drivers/cam_sensor_module/cam_ois/Makefile deleted file mode 100644 index fa7fabc0f..000000000 --- a/drivers/cam_sensor_module/cam_ois/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_res_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core/ - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_ois_dev.o cam_ois_core.o cam_ois_soc.o diff --git a/drivers/cam_sensor_module/cam_ois/cam_ois_core.c b/drivers/cam_sensor_module/cam_ois/cam_ois_core.c index 2b018dd33..0cb705c2b 100644 --- a/drivers/cam_sensor_module/cam_ois/cam_ois_core.c +++ b/drivers/cam_sensor_module/cam_ois/cam_ois_core.c @@ -5,7 +5,7 @@ #include #include -#include + #include #include "cam_ois_core.h" #include "cam_ois_soc.h" @@ -305,7 +305,7 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) char name_coeff[32] = {0}; struct device *dev = &(o_ctrl->pdev->dev); struct cam_sensor_i2c_reg_setting i2c_reg_setting; - struct page *page = NULL; + void *vaddr = NULL; if (!o_ctrl) { CAM_ERR(CAM_OIS, "Invalid Args"); @@ -332,18 +332,17 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; i2c_reg_setting.size = total_bytes; i2c_reg_setting.delay = 0; - fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * - total_bytes) >> PAGE_SHIFT; - page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), - fw_size, 0, GFP_KERNEL); - if (!page) { - CAM_ERR(CAM_OIS, "Failed in allocating i2c_array"); + fw_size = (sizeof(struct cam_sensor_i2c_reg_array) * total_bytes); + vaddr = vmalloc(fw_size); + if (!vaddr) { + CAM_ERR(CAM_OIS, + "Failed in allocating i2c_array: fw_size: %u", fw_size); release_firmware(fw); return -ENOMEM; } i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) ( - page_address(page)); + vaddr); for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes; cnt++, ptr++) { @@ -360,9 +359,8 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc); goto release_firmware; } - cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), - page, fw_size); - page = NULL; + vfree(vaddr); + vaddr = NULL; fw_size = 0; release_firmware(fw); @@ -377,18 +375,17 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) i2c_reg_setting.data_type = CAMERA_SENSOR_I2C_TYPE_BYTE; i2c_reg_setting.size = total_bytes; i2c_reg_setting.delay = 0; - fw_size = PAGE_ALIGN(sizeof(struct cam_sensor_i2c_reg_array) * - total_bytes) >> PAGE_SHIFT; - page = cma_alloc(dev_get_cma_area((o_ctrl->soc_info.dev)), - fw_size, 0, GFP_KERNEL); - if (!page) { - CAM_ERR(CAM_OIS, "Failed in allocating i2c_array"); + fw_size = (sizeof(struct cam_sensor_i2c_reg_array) * total_bytes); + vaddr = vmalloc(fw_size); + if (!vaddr) { + CAM_ERR(CAM_OIS, + "Failed in allocating i2c_array: fw_size: %u", fw_size); release_firmware(fw); return -ENOMEM; } i2c_reg_setting.reg_setting = (struct cam_sensor_i2c_reg_array *) ( - page_address(page)); + vaddr); for (cnt = 0, ptr = (uint8_t *)fw->data; cnt < total_bytes; cnt++, ptr++) { @@ -405,10 +402,10 @@ static int cam_ois_fw_download(struct cam_ois_ctrl_t *o_ctrl) CAM_ERR(CAM_OIS, "OIS FW download failed %d", rc); release_firmware: - cma_release(dev_get_cma_area((o_ctrl->soc_info.dev)), - page, fw_size); + vfree(vaddr); + vaddr = NULL; + fw_size = 0; release_firmware(fw); - return rc; } diff --git a/drivers/cam_sensor_module/cam_ois/cam_ois_dev.c b/drivers/cam_sensor_module/cam_ois/cam_ois_dev.c index 10044cec6..667cbb44e 100644 --- a/drivers/cam_sensor_module/cam_ois/cam_ois_dev.c +++ b/drivers/cam_sensor_module/cam_ois/cam_ois_dev.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #include "cam_ois_dev.h" @@ -384,7 +384,7 @@ static struct i2c_driver cam_ois_i2c_driver = { static struct cam_ois_registered_driver_t registered_driver = { 0, 0}; -static int __init cam_ois_driver_init(void) +int cam_ois_driver_init(void) { int rc = 0; @@ -407,7 +407,7 @@ static int __init cam_ois_driver_init(void) return rc; } -static void __exit cam_ois_driver_exit(void) +void cam_ois_driver_exit(void) { if (registered_driver.platform_driver) platform_driver_unregister(&cam_ois_platform_driver); @@ -416,7 +416,5 @@ static void __exit cam_ois_driver_exit(void) i2c_del_driver(&cam_ois_i2c_driver); } -module_init(cam_ois_driver_init); -module_exit(cam_ois_driver_exit); MODULE_DESCRIPTION("CAM OIS driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h b/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h index 788243ae9..eb0a69d11 100644 --- a/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h +++ b/drivers/cam_sensor_module/cam_ois/cam_ois_dev.h @@ -124,4 +124,14 @@ struct cam_ois_ctrl_t { struct cam_ois_opcode opcode; }; +/** + * @brief : API to register OIS hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_ois_driver_init(void); + +/** + * @brief : API to remove OIS Hw from platform framework. + */ +void cam_ois_driver_exit(void); #endif /*_CAM_OIS_DEV_H_ */ diff --git a/drivers/cam_sensor_module/cam_res_mgr/Makefile b/drivers/cam_sensor_module/cam_res_mgr/Makefile deleted file mode 100644 index 1c8ccb0e3..000000000 --- a/drivers/cam_sensor_module/cam_res_mgr/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -#ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_res_mgr.o diff --git a/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c b/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c index 58a927426..14a01e81b 100644 --- a/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c +++ b/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr.c @@ -725,17 +725,15 @@ static struct platform_driver cam_res_mgr_driver = { }, }; -static int __init cam_res_mgr_init(void) +int cam_res_mgr_init(void) { return platform_driver_register(&cam_res_mgr_driver); } -static void __exit cam_res_mgr_exit(void) +void cam_res_mgr_exit(void) { platform_driver_unregister(&cam_res_mgr_driver); } -module_init(cam_res_mgr_init); -module_exit(cam_res_mgr_exit); MODULE_DESCRIPTION("Camera resource manager driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr_api.h b/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr_api.h index e259ba7f2..b47c68dea 100644 --- a/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr_api.h +++ b/drivers/cam_sensor_module/cam_res_mgr/cam_res_mgr_api.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ #ifndef __CAM_RES_MGR_API_H__ @@ -138,4 +138,14 @@ int cam_res_mgr_gpio_set_value(unsigned int gpio, int value); */ void cam_res_mgr_shared_clk_config(bool value); +/** + * @brief : API to register RES_MGR to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_res_mgr_init(void); + +/** + * @brief : API to remove RES_MGR from platform framework. + */ +void cam_res_mgr_exit(void); #endif /* __CAM_RES_MGR_API_H__ */ diff --git a/drivers/cam_sensor_module/cam_sensor/Makefile b/drivers/cam_sensor_module/cam_sensor/Makefile deleted file mode 100644 index d3a6fbb6c..000000000 --- a/drivers/cam_sensor_module/cam_sensor/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_dev.o cam_sensor_core.o cam_sensor_soc.o diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.c b/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.c index 765a1244a..848234196 100644 --- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.c +++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.c @@ -366,7 +366,7 @@ static struct i2c_driver cam_sensor_driver_i2c = { }, }; -static int __init cam_sensor_driver_init(void) +int cam_sensor_driver_init(void) { int32_t rc = 0; @@ -384,13 +384,11 @@ static int __init cam_sensor_driver_init(void) return rc; } -static void __exit cam_sensor_driver_exit(void) +void cam_sensor_driver_exit(void) { platform_driver_unregister(&cam_sensor_platform_driver); i2c_del_driver(&cam_sensor_driver_i2c); } -module_init(cam_sensor_driver_init); -module_exit(cam_sensor_driver_exit); MODULE_DESCRIPTION("cam_sensor_driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h b/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h index b1963e15e..8586ce51c 100644 --- a/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h +++ b/drivers/cam_sensor_module/cam_sensor/cam_sensor_dev.h @@ -46,14 +46,14 @@ enum cam_sensor_state_t { }; /** - * struct intf_params + * struct sensor_intf_params * @device_hdl: Device Handle * @session_hdl: Session Handle * @link_hdl: Link Handle * @ops: KMD operations * @crm_cb: Callback API pointers */ -struct intf_params { +struct sensor_intf_params { int32_t device_hdl; int32_t session_hdl; int32_t link_hdl; @@ -104,7 +104,7 @@ struct cam_sensor_ctrl_t { uint8_t sensor_probe_data_type; struct i2c_data_settings i2c_data; struct cam_sensor_query_cap sensor_info; - struct intf_params bridge_intf; + struct sensor_intf_params bridge_intf; uint32_t streamon_count; uint32_t streamoff_count; int bob_reg_index; @@ -113,4 +113,15 @@ struct cam_sensor_ctrl_t { uint16_t pipeline_delay; }; +/** + * @brief : API to register SENSOR hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_sensor_driver_init(void); + +/** + * @brief : API to remove SENSOR Hw from platform framework. + */ +void cam_sensor_driver_exit(void); + #endif /* _CAM_SENSOR_DEV_H_ */ diff --git a/drivers/cam_sensor_module/cam_sensor_io/Makefile b/drivers/cam_sensor_module/cam_sensor_io/Makefile deleted file mode 100644 index 5b11171fa..000000000 --- a/drivers/cam_sensor_module/cam_sensor_io/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_io.o cam_sensor_cci_i2c.o cam_sensor_qup_i2c.o cam_sensor_spi.o diff --git a/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c b/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c index cf6987b09..02cc1c7e3 100644 --- a/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c +++ b/drivers/cam_sensor_module/cam_sensor_io/cam_sensor_spi.c @@ -1,9 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved. */ -#include #include "cam_sensor_spi.h" #include "cam_debug_util.h" @@ -111,7 +110,8 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client, uint32_t len, hlen; uint8_t retries = client->spi_client->retries; uint32_t txr = 0, rxr = 0; - struct page *page_tx = NULL, *page_rx = NULL; + void *vaddr_tx = NULL; + void *vaddr_rx = NULL; hlen = cam_camera_spi_get_hlen(inst); len = hlen + num_byte; @@ -125,30 +125,32 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client, if (tx) { ctx = tx; } else { - txr = PAGE_ALIGN(len) >> PAGE_SHIFT; - page_tx = cma_alloc(dev_get_cma_area(dev), - txr, 0, GFP_KERNEL); - if (!page_tx) + txr = len; + vaddr_tx = vmalloc(txr); + if (!vaddr_tx) { + CAM_ERR(CAM_SENSOR, + "Fail to allocate Memory: len: %u", txr); return -ENOMEM; + } - ctx = page_address(page_tx); + ctx = (char *)vaddr_tx; } if (num_byte) { if (rx) { crx = rx; } else { - rxr = PAGE_ALIGN(len) >> PAGE_SHIFT; - page_rx = cma_alloc(dev_get_cma_area(dev), - rxr, 0, GFP_KERNEL); - if (!page_rx) { + rxr = len; + vaddr_rx = vmalloc(rxr); + if (!vaddr_rx) { if (!tx) - cma_release(dev_get_cma_area(dev), - page_tx, txr); - + vfree(vaddr_tx); + CAM_ERR(CAM_SENSOR, + "Fail to allocate memory: len: %u", + rxr); return -ENOMEM; } - crx = page_address(page_rx); + crx = (char *)vaddr_rx; } } else { crx = NULL; @@ -168,10 +170,14 @@ static int32_t cam_spi_tx_helper(struct camera_io_master *client, memcpy(data, crx + hlen, num_byte); out: - if (!tx) - cma_release(dev_get_cma_area(dev), page_tx, txr); - if (!rx) - cma_release(dev_get_cma_area(dev), page_rx, rxr); + if (!tx) { + vfree(vaddr_tx); + vaddr_tx = NULL; + } + if (!rx) { + vfree(vaddr_rx); + vaddr_rx = NULL; + } return rc; } diff --git a/drivers/cam_sensor_module/cam_sensor_utils/Makefile b/drivers/cam_sensor_module/cam_sensor_utils/Makefile deleted file mode 100644 index d822b2a73..000000000 --- a/drivers/cam_sensor_module/cam_sensor_utils/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_sensor_io -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_cci -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_sensor_module/cam_res_mgr -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_cpas/include -ccflags-y += -I$(src) - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sensor_util.o diff --git a/drivers/cam_smmu/Makefile b/drivers/cam_smmu/Makefile deleted file mode 100644 index 2968a7a1e..000000000 --- a/drivers/cam_smmu/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_smmu_api.o diff --git a/drivers/cam_smmu/cam_smmu_api.c b/drivers/cam_smmu/cam_smmu_api.c index 49db0ec16..e05d6328f 100644 --- a/drivers/cam_smmu/cam_smmu_api.c +++ b/drivers/cam_smmu/cam_smmu_api.c @@ -10,15 +10,17 @@ #include #include #include +#include #include #include #include #include #include - -#include #include + #include + +#include "cam_compat.h" #include "cam_smmu_api.h" #include "cam_debug_util.h" #include "cam_trace.h" @@ -46,13 +48,7 @@ static int g_num_pf_handled = 4; module_param(g_num_pf_handled, int, 0644); -struct firmware_alloc_info { - struct device *fw_dev; - void *fw_kva; - dma_addr_t fw_dma_hdl; -}; - -struct firmware_alloc_info icp_fw; +struct cam_fw_alloc_info icp_fw; struct cam_smmu_work_payload { int idx; @@ -64,6 +60,12 @@ struct cam_smmu_work_payload { struct list_head list; }; +enum cam_io_coherency_mode { + CAM_SMMU_NO_COHERENCY, + CAM_SMMU_DMA_COHERENT, + CAM_SMMU_DMA_COHERENT_HINT_CACHED, +}; + enum cam_protection_type { CAM_PROT_INVALID, CAM_NON_SECURE, @@ -157,6 +159,7 @@ struct cam_context_bank_info { bool is_mul_client; int device_count; int num_shared_hdl; + enum cam_io_coherency_mode coherency_mode; /* discard iova - non-zero values are valid */ dma_addr_t discard_iova_start; @@ -177,6 +180,7 @@ struct cam_iommu_cb_set { struct dentry *dentry; bool cb_dump_enable; bool map_profile_enable; + bool force_cache_allocs; }; static const struct of_device_id msm_cam_smmu_dt_match[] = { @@ -359,6 +363,111 @@ static void cam_smmu_dump_monitor_array( } } +int cam_smmu_need_force_alloc_cached(bool *force_alloc_cached) +{ + int idx; + uint32_t curr_mode = 0, final_mode = 0; + bool validate = false; + + if (!force_alloc_cached) { + CAM_ERR(CAM_SMMU, "Invalid arg"); + return -EINVAL; + } + + CAM_INFO(CAM_SMMU, "force_cache_allocs=%d", + iommu_cb_set.force_cache_allocs); + + /* + * First validate whether all SMMU CBs are properly setup to comply with + * iommu_cb_set.force_alloc_cached flag. + * This helps as a validation check to make sure a valid DT combination + * is set for a given chipset. + */ + for (idx = 0; idx < iommu_cb_set.cb_num; idx++) { + /* ignore secure cb for now. need to revisit */ + if (iommu_cb_set.cb_info[idx].is_secure) + continue; + + curr_mode = iommu_cb_set.cb_info[idx].coherency_mode; + + /* + * 1. No coherency: + * We can map both CACHED and UNCACHED buffers into same CB. + * We need to allocate UNCACHED buffers for Cmdbuffers + * and Shared Buffers. UNCAHE support must exists with memory + * allocators (ion or dma-buf-heaps) for CmdBuffers, + * SharedBuffers to work - as it is difficult to do + * cache operations on these buffers in camera design. + * ImageBuffers can be CACHED or UNCACHED. If CACHED, clients + * need to make required CACHE operations. + * Cannot force all allocations to CACHE. + * 2. dma-coherent: + * We cannot map CACHED and UNCACHED buffers into the same CB + * This means, we must force allocate all buffers to be + * CACHED. + * 3. dma-coherent-hint-cached + * We can map both CACHED and UNCACHED buffers into the same + * CB. So any option is fine force_cache_allocs. + * Forcing to cache is preferable though. + * + * Other rule we are enforcing is - all camera CBs (except + * secure CB) must have same coherency mode set. Assume one CB + * is having no_coherency mode and other CB is having + * dma_coherent. For no_coherency CB to work - we must not force + * buffers to be CACHE (exa cmd buffers), for dma_coherent mode + * we must force all buffers to be CACHED. But at the time of + * allocation, we dont know to which CB we will be mapping this + * buffer. So it becomes difficult to generalize cache + * allocations and io coherency mode that we want to support. + * So, to simplify, all camera CBs will have same mode. + */ + + CAM_DBG(CAM_SMMU, "[%s] : curr_mode=%d", + iommu_cb_set.cb_info[idx].name[0], curr_mode); + + if (curr_mode == CAM_SMMU_NO_COHERENCY) { + if (iommu_cb_set.force_cache_allocs) { + CAM_ERR(CAM_SMMU, + "[%s] Can't force alloc cache with no coherency", + iommu_cb_set.cb_info[idx].name[0]); + return -EINVAL; + } + } else if (curr_mode == CAM_SMMU_DMA_COHERENT) { + if (!iommu_cb_set.force_cache_allocs) { + CAM_ERR(CAM_SMMU, + "[%s] Must force cache allocs for dma coherent device", + iommu_cb_set.cb_info[idx].name[0]); + return -EINVAL; + } + } + + if (validate) { + if (curr_mode != final_mode) { + CAM_ERR(CAM_SMMU, + "[%s] CBs having different coherency modes final=%d, curr=%d", + iommu_cb_set.cb_info[idx].name[0], + final_mode, curr_mode); + return -EINVAL; + } + } else { + validate = true; + final_mode = curr_mode; + } + } + + /* + * To be more accurate - if this flag is TRUE and if this buffer will + * be mapped to external devices like CVP - we need to ensure we do + * one of below : + * 1. CVP CB having dma-coherent or dma-coherent-hint-cached + * 2. camera/cvp sw layers properly doing required cache operations. We + * cannot anymore assume these buffers (camera <--> cvp) are uncached + */ + *force_alloc_cached = iommu_cb_set.force_cache_allocs; + + return 0; +} + static void cam_smmu_page_fault_work(struct work_struct *work) { int j; @@ -1309,23 +1418,25 @@ int cam_smmu_alloc_firmware(int32_t smmu_hdl, firmware_start = iommu_cb_set.cb_info[idx].firmware_info.iova_start; CAM_DBG(CAM_SMMU, "Firmware area len from DT = %zu", firmware_len); - icp_fw.fw_kva = dma_alloc_coherent(icp_fw.fw_dev, - firmware_len, - &icp_fw.fw_dma_hdl, - GFP_KERNEL); - if (!icp_fw.fw_kva) { - CAM_ERR(CAM_SMMU, "FW memory alloc failed"); - rc = -ENOMEM; + rc = cam_reserve_icp_fw(&icp_fw, firmware_len); + if (rc) goto unlock_and_end; - } else { + else CAM_DBG(CAM_SMMU, "DMA alloc returned fw = %pK, hdl = %pK", - icp_fw.fw_kva, (void *)icp_fw.fw_dma_hdl); - } + icp_fw.fw_kva, (void *)icp_fw.fw_hdl); domain = iommu_cb_set.cb_info[idx].domain; + + /* + * Revisit this - what should we map this with - CACHED or UNCACHED? + * chipsets using dma-coherent-hint-cached - leaving it like this is + * fine as we can map both CACHED and UNCACHED on same CB. + * But on chipsets which use dma-coherent - all the buffers that are + * being mapped to this CB must be CACHED + */ rc = iommu_map(domain, firmware_start, - icp_fw.fw_dma_hdl, + (phys_addr_t) icp_fw.fw_hdl, firmware_len, IOMMU_READ|IOMMU_WRITE|IOMMU_PRIV); @@ -1344,10 +1455,7 @@ int cam_smmu_alloc_firmware(int32_t smmu_hdl, return rc; alloc_fail: - dma_free_coherent(icp_fw.fw_dev, - firmware_len, - icp_fw.fw_kva, - icp_fw.fw_dma_hdl); + cam_unreserve_icp_fw(&icp_fw, firmware_len); unlock_and_end: mutex_unlock(&iommu_cb_set.cb_info[idx].lock); end: @@ -1407,13 +1515,10 @@ int cam_smmu_dealloc_firmware(int32_t smmu_hdl) rc = -EINVAL; } - dma_free_coherent(icp_fw.fw_dev, - firmware_len, - icp_fw.fw_kva, - icp_fw.fw_dma_hdl); + cam_unreserve_icp_fw(&icp_fw, firmware_len); - icp_fw.fw_kva = 0; - icp_fw.fw_dma_hdl = 0; + icp_fw.fw_kva = NULL; + icp_fw.fw_hdl = 0; iommu_cb_set.cb_info[idx].is_fw_allocated = false; @@ -1469,6 +1574,14 @@ int cam_smmu_alloc_qdss(int32_t smmu_hdl, CAM_DBG(CAM_SMMU, "QDSS area len from DT = %zu", qdss_len); domain = iommu_cb_set.cb_info[idx].domain; + + /* + * Revisit this - what should we map this with - CACHED or UNCACHED? + * chipsets using dma-coherent-hint-cached - leaving it like this is + * fine as we can map both CACHED and UNCACHED on same CB. + * But on chipsets which use dma-coherent - all the buffers that are + * being mapped to this CB must be CACHED + */ rc = iommu_map(domain, qdss_start, qdss_phy_addr, @@ -1698,6 +1811,7 @@ int cam_smmu_reserve_sec_heap(int32_t smmu_hdl, size_t sec_heap_iova_len = 0; int idx; int rc = 0; + int prot = 0; idx = GET_SMMU_TABLE_IDX(smmu_hdl); if (idx < 0 || idx >= iommu_cb_set.cb_num) { @@ -1748,11 +1862,16 @@ int cam_smmu_reserve_sec_heap(int32_t smmu_hdl, sec_heap_iova = iommu_cb_set.cb_info[idx].secheap_info.iova_start; sec_heap_iova_len = iommu_cb_set.cb_info[idx].secheap_info.iova_len; + + prot = IOMMU_READ | IOMMU_WRITE; + if (iommu_cb_set.force_cache_allocs) + prot |= IOMMU_CACHE; + size = iommu_map_sg(iommu_cb_set.cb_info[idx].domain, sec_heap_iova, secheap_buf->table->sgl, secheap_buf->table->nents, - IOMMU_READ | IOMMU_WRITE); + prot); if (size != sec_heap_iova_len) { CAM_ERR(CAM_SMMU, "IOMMU mapping failed"); goto err_unmap_sg; @@ -1845,6 +1964,7 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, int rc = 0; struct timespec64 ts1, ts2; long microsec = 0; + int prot = 0; if (IS_ERR_OR_NULL(buf)) { rc = PTR_ERR(buf); @@ -1895,8 +2015,12 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, goto err_unmap_sg; } + prot = IOMMU_READ | IOMMU_WRITE; + if (iommu_cb_set.force_cache_allocs) + prot |= IOMMU_CACHE; + size = iommu_map_sg(domain, iova, table->sgl, table->nents, - IOMMU_READ | IOMMU_WRITE); + prot); if (size < 0) { CAM_ERR(CAM_SMMU, "IOMMU mapping failed"); @@ -1937,8 +2061,9 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, } CAM_DBG(CAM_SMMU, - "iova=%pK, region_id=%d, paddr=%pK, len=%d, dma_map_attrs=%d", - iova, region_id, *paddr_ptr, *len_ptr, attach->dma_map_attrs); + "iova=%pK, region_id=%d, paddr=0x%x, len=%d, dma_map_attrs=%d", + iova, region_id, (uint64_t)*paddr_ptr, *len_ptr, + attach->dma_map_attrs); if (iommu_cb_set.map_profile_enable) { CAM_GET_TIMESTAMP(ts2); @@ -1985,7 +2110,8 @@ static int cam_smmu_map_buffer_validate(struct dma_buf *buf, rc = -ENOSPC; goto err_alloc; } - CAM_DBG(CAM_SMMU, "idx=%d, dma_buf=%pK, dev=%pK, paddr=%pK, len=%u", + + CAM_DBG(CAM_SMMU, "idx=%d, dma_buf=%pK, dev=%pK, paddr=0x%x, len=%u", idx, buf, (void *)iommu_cb_set.cb_info[idx].dev, (void *)*paddr_ptr, (unsigned int)*len_ptr); @@ -2098,7 +2224,7 @@ static int cam_smmu_unmap_buf_and_remove_from_list( mapping_info); CAM_DBG(CAM_SMMU, - "region_id=%d, paddr=%pK, len=%d, dma_map_attrs=%d", + "region_id=%d, paddr=0x%x, len=%d, dma_map_attrs=%d", mapping_info->region_id, mapping_info->paddr, mapping_info->len, mapping_info->attach->dma_map_attrs); @@ -2359,6 +2485,9 @@ static int cam_smmu_alloc_scratch_buffer_add_to_list(int idx, goto err_iommu_map; } + if (iommu_cb_set.force_cache_allocs) + iommu_dir |= IOMMU_CACHE; + if (iommu_map_sg(domain, iova, table->sgl, @@ -3404,9 +3533,8 @@ EXPORT_SYMBOL(cam_smmu_destroy_handle); static void cam_smmu_deinit_cb(struct cam_context_bank_info *cb) { - if (cb->io_support && cb->domain) { + if (cb->io_support && cb->domain) cb->domain = NULL; - } if (cb->shared_support) { gen_pool_destroy(cb->shared_mem_pool); @@ -3494,11 +3622,9 @@ static int cam_smmu_setup_cb(struct cam_context_bank_info *cb, goto end; } - iommu_dma_enable_best_fit_algo(dev); - - if (cb->discard_iova_start) - iommu_dma_reserve_iova(dev, cb->discard_iova_start, - cb->discard_iova_len); + /* Enable custom iommu features, if applicable */ + cam_smmu_util_iommu_custom(dev, cb->discard_iova_start, + cb->discard_iova_len); cb->state = CAM_SMMU_ATTACH; } else { @@ -3816,6 +3942,7 @@ static int cam_populate_smmu_context_banks(struct device *dev, struct cam_context_bank_info *cb; struct device *ctx = NULL; int i = 0; + bool dma_coherent, dma_coherent_hint; if (!dev) { CAM_ERR(CAM_SMMU, "Error: Invalid device"); @@ -3880,6 +4007,27 @@ static int cam_populate_smmu_context_banks(struct device *dev, ctx = dev; CAM_DBG(CAM_SMMU, "getting Arm SMMU ctx : %s", cb->name[0]); + cb->coherency_mode = CAM_SMMU_NO_COHERENCY; + + dma_coherent = of_property_read_bool(dev->of_node, "dma-coherent"); + dma_coherent_hint = of_property_read_bool(dev->of_node, + "dma-coherent-hint-cached"); + + if (dma_coherent && dma_coherent_hint) { + CAM_ERR(CAM_SMMU, + "[%s] : Cannot enable both dma-coherent and dma-coherent-hint-cached", + cb->name[0]); + return -EBADR; + } + + if (dma_coherent) + cb->coherency_mode = CAM_SMMU_DMA_COHERENT; + else if (dma_coherent_hint) + cb->coherency_mode = CAM_SMMU_DMA_COHERENT_HINT_CACHED; + + CAM_DBG(CAM_SMMU, "[%s] : io cohereny mode %d", cb->name[0], + cb->coherency_mode); + rc = cam_smmu_setup_cb(cb, ctx); if (rc < 0) { CAM_ERR(CAM_SMMU, "Error: failed to setup cb : %s", @@ -3916,36 +4064,24 @@ static int cam_populate_smmu_context_banks(struct device *dev, static int cam_smmu_create_debug_fs(void) { - iommu_cb_set.dentry = debugfs_create_dir("camera_smmu", - NULL); - - if (!iommu_cb_set.dentry) { - CAM_ERR(CAM_SMMU, "failed to create dentry"); - return -ENOMEM; - } - - if (!debugfs_create_bool("cb_dump_enable", - 0644, - iommu_cb_set.dentry, - &iommu_cb_set.cb_dump_enable)) { - CAM_ERR(CAM_SMMU, - "failed to create dump_enable_debug"); - goto err; - } + int rc = 0; + struct dentry *dbgfileptr = NULL; - if (!debugfs_create_bool("map_profile_enable", - 0644, - iommu_cb_set.dentry, - &iommu_cb_set.map_profile_enable)) { - CAM_ERR(CAM_SMMU, - "failed to create map_profile_enable"); - goto err; + dbgfileptr = debugfs_create_dir("camera_smmu", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_SMMU,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + iommu_cb_set.dentry = dbgfileptr; - return 0; -err: - debugfs_remove_recursive(iommu_cb_set.dentry); - return -ENOMEM; + debugfs_create_bool("cb_dump_enable", 0644, + iommu_cb_set.dentry, &iommu_cb_set.cb_dump_enable); + debugfs_create_bool("map_profile_enable", 0644, + iommu_cb_set.dentry, &iommu_cb_set.map_profile_enable); +end: + return rc; } static int cam_smmu_probe(struct platform_device *pdev) @@ -3982,7 +4118,7 @@ static int cam_smmu_probe(struct platform_device *pdev) if (of_device_is_compatible(dev->of_node, "qcom,msm-cam-smmu-fw-dev")) { icp_fw.fw_dev = &pdev->dev; icp_fw.fw_kva = NULL; - icp_fw.fw_dma_hdl = 0; + icp_fw.fw_hdl = 0; return rc; } @@ -4031,17 +4167,15 @@ static struct platform_driver cam_smmu_driver = { }, }; -static int __init cam_smmu_init_module(void) +int cam_smmu_init_module(void) { return platform_driver_register(&cam_smmu_driver); } -static void __exit cam_smmu_exit_module(void) +void cam_smmu_exit_module(void) { platform_driver_unregister(&cam_smmu_driver); } -module_init(cam_smmu_init_module); -module_exit(cam_smmu_exit_module); MODULE_DESCRIPTION("MSM Camera SMMU driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_smmu/cam_smmu_api.h b/drivers/cam_smmu/cam_smmu_api.h index 4a4a0d312..19638e8b6 100644 --- a/drivers/cam_smmu/cam_smmu_api.h +++ b/drivers/cam_smmu/cam_smmu_api.h @@ -400,4 +400,21 @@ int cam_smmu_get_io_region_info(int32_t smmu_hdl, dma_addr_t *iova, size_t *len, dma_addr_t *discard_iova_start, size_t *discard_iova_len); +/** + * @brief : API to register SMMU hw to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_smmu_init_module(void); + +/** + * @brief : API to remove SMMU Hw from platform framework. + */ +void cam_smmu_exit_module(void); + +/** + * @brief : API to determine whether to force all allocations to CACHED + */ +int cam_smmu_need_force_alloc_cached(bool *force_alloc_cached); + + #endif /* _CAM_SMMU_API_H_ */ diff --git a/drivers/cam_sync/Makefile b/drivers/cam_sync/Makefile deleted file mode 100644 index 3008761f5..000000000 --- a/drivers/cam_sync/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_utils -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr -ccflags-$(CONFIG_MSM_GLOBAL_SYNX) += -I$(srctree)/drivers/media/platform/msm/synx -ccflags-y += -I$(src) - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_sync.o cam_sync_util.o diff --git a/drivers/cam_sync/cam_sync.c b/drivers/cam_sync/cam_sync.c index d548933f2..753452826 100644 --- a/drivers/cam_sync/cam_sync.c +++ b/drivers/cam_sync/cam_sync.c @@ -12,6 +12,7 @@ #include "cam_sync_util.h" #include "cam_debug_util.h" #include "cam_common_util.h" +#include "cam_compat.h" #include "cam_req_mgr_workq.h" #ifdef CONFIG_MSM_GLOBAL_SYNX @@ -1015,22 +1016,23 @@ static void cam_sync_init_entity(struct sync_device *sync_dev) static int cam_sync_create_debugfs(void) { - sync_dev->dentry = debugfs_create_dir("camera_sync", NULL); + int rc = 0; + struct dentry *dbgfileptr = NULL; - if (!sync_dev->dentry) { - CAM_ERR(CAM_SYNC, "Failed to create sync dir"); - return -ENOMEM; + dbgfileptr = debugfs_create_dir("camera_sync", NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_SYNC,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + sync_dev->dentry = dbgfileptr; - if (!debugfs_create_bool("trigger_cb_without_switch", - 0644, sync_dev->dentry, - &trigger_cb_without_switch)) { - CAM_ERR(CAM_SYNC, - "failed to create trigger_cb_without_switch entry"); - return -ENOMEM; - } + debugfs_create_bool("trigger_cb_without_switch", 0644, + sync_dev->dentry, &trigger_cb_without_switch); - return 0; +end: + return rc; } #ifdef CONFIG_MSM_GLOBAL_SYNX @@ -1089,11 +1091,16 @@ static int cam_sync_probe(struct platform_device *pdev) sync_dev->vdev->fops = &cam_sync_v4l2_fops; sync_dev->vdev->ioctl_ops = &g_cam_sync_ioctl_ops; sync_dev->vdev->minor = -1; - sync_dev->vdev->vfl_type = VFL_TYPE_GRABBER; + sync_dev->vdev->vfl_type = VFL_TYPE_VIDEO; + sync_dev->vdev->device_caps |= V4L2_CAP_VIDEO_CAPTURE; rc = video_register_device(sync_dev->vdev, - VFL_TYPE_GRABBER, -1); - if (rc < 0) + VFL_TYPE_VIDEO, -1); + if (rc < 0) { + CAM_ERR(CAM_SYNC, + "video device registration failure rc = %d, name = %s, device_caps = %d", + rc, sync_dev->vdev->name, sync_dev->vdev->device_caps); goto v4l2_fail; + } cam_sync_init_entity(sync_dev); video_set_drvdata(sync_dev->vdev, sync_dev); @@ -1164,10 +1171,9 @@ static struct platform_driver cam_sync_driver = { }, }; -static int __init cam_sync_init(void) +int cam_sync_init(void) { int rc; - rc = platform_device_register(&cam_sync_device); if (rc) return -ENODEV; @@ -1175,7 +1181,7 @@ static int __init cam_sync_init(void) return platform_driver_register(&cam_sync_driver); } -static void __exit cam_sync_exit(void) +void cam_sync_exit(void) { int idx; @@ -1186,7 +1192,5 @@ static void __exit cam_sync_exit(void) kfree(sync_dev); } -module_init(cam_sync_init); -module_exit(cam_sync_exit); MODULE_DESCRIPTION("Camera sync driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/cam_sync/cam_sync_api.h b/drivers/cam_sync/cam_sync_api.h index 3304acb50..a46e37b31 100644 --- a/drivers/cam_sync/cam_sync_api.h +++ b/drivers/cam_sync/cam_sync_api.h @@ -150,4 +150,14 @@ int cam_sync_wait(int32_t sync_obj, uint64_t timeout_ms); */ int cam_sync_check_valid(int32_t sync_obj); +/** + * @brief : API to register SYNC to platform framework. + * @return struct platform_device pointer on on success, or ERR_PTR() on error. + */ +int cam_sync_init(void); + +/** + * @brief : API to remove SYNC from platform framework. + */ +void cam_sync_exit(void); #endif /* __CAM_SYNC_API_H__ */ diff --git a/drivers/cam_utils/Makefile b/drivers/cam_utils/Makefile deleted file mode 100644 index e17c2f50b..000000000 --- a/drivers/cam_utils/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -ccflags-y += -I$(srctree)/techpack/camera/include/uapi -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_core/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_req_mgr/ -ccflags-y += -I$(srctree)/techpack/camera/drivers/cam_smmu/ - -obj-$(CONFIG_SPECTRA_CAMERA) += cam_soc_util.o cam_io_util.o cam_packet_util.o cam_debug_util.o cam_trace.o cam_common_util.o -obj-$(CONFIG_SPECTRA_CAMERA) += cam_cx_ipeak.o diff --git a/drivers/cam_utils/cam_compat.c b/drivers/cam_utils/cam_compat.c new file mode 100644 index 000000000..3d7bd949b --- /dev/null +++ b/drivers/cam_utils/cam_compat.c @@ -0,0 +1,253 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include + +#include "cam_compat.h" +#include "cam_debug_util.h" +#include "cam_cpas_api.h" + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) +int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length) +{ + int rc = 0; + struct device_node *of_node; + struct device_node *mem_node; + struct resource res; + + of_node = (icp_fw->fw_dev)->of_node; + mem_node = of_parse_phandle(of_node, "memory-region", 0); + if (!mem_node) { + rc = -ENOMEM; + CAM_ERR(CAM_SMMU, "FW memory carveout not found"); + goto end; + } + rc = of_address_to_resource(mem_node, 0, &res); + of_node_put(mem_node); + if (rc < 0) { + CAM_ERR(CAM_SMMU, "Unable to get start of FW mem carveout"); + goto end; + } + icp_fw->fw_hdl = res.start; + icp_fw->fw_kva = ioremap_wc(icp_fw->fw_hdl, fw_length); + if (!icp_fw->fw_kva) { + CAM_ERR(CAM_SMMU, "Failed to map the FW."); + rc = -ENOMEM; + goto end; + } + memset_io(icp_fw->fw_kva, 0, fw_length); + +end: + return rc; +} + +void cam_unreserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length) +{ + iounmap(icp_fw->fw_kva); +} + +int cam_ife_notify_safe_lut_scm(bool safe_trigger) +{ + const uint32_t smmu_se_ife = 0; + uint32_t camera_hw_version, rc = 0; + + rc = cam_cpas_get_cpas_hw_version(&camera_hw_version); + if (!rc && qcom_scm_smmu_notify_secure_lut(smmu_se_ife, safe_trigger)) { + switch (camera_hw_version) { + case CAM_CPAS_TITAN_170_V100: + case CAM_CPAS_TITAN_170_V110: + case CAM_CPAS_TITAN_175_V100: + CAM_ERR(CAM_ISP, "scm call to enable safe failed"); + rc = -EINVAL; + break; + default: + break; + } + } + + return rc; +} + +int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, + bool protect, int32_t offset) +{ + int rc = 0; + + if (offset >= CSIPHY_MAX_INSTANCES) { + CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset"); + rc = -EINVAL; + } else if (qcom_scm_camera_protect_phy_lanes(protect, + csiphy_dev->csiphy_cpas_cp_reg_mask[offset])) { + CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed"); + rc = -EINVAL; + } + + return 0; +} + +void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa) +{ + int reg_val; + + qcom_scm_io_readl(errata_wa->data.reg_info.offset, ®_val); + reg_val |= errata_wa->data.reg_info.value; + qcom_scm_io_writel(errata_wa->data.reg_info.offset, reg_val); +} +#else +int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length) +{ + int rc = 0; + + icp_fw->fw_kva = dma_alloc_coherent(icp_fw->fw_dev, fw_length, + &icp_fw->fw_hdl, GFP_KERNEL); + + if (!icp_fw->fw_kva) { + CAM_ERR(CAM_SMMU, "FW memory alloc failed"); + rc = -ENOMEM; + } + + return rc; +} + +void cam_unreserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length) +{ + dma_free_coherent(icp_fw->fw_dev, fw_length, icp_fw->fw_kva, + icp_fw->fw_hdl); +} + +int cam_ife_notify_safe_lut_scm(bool safe_trigger) +{ + const uint32_t smmu_se_ife = 0; + uint32_t camera_hw_version, rc = 0; + struct scm_desc description = { + .arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL), + .args[0] = smmu_se_ife, + .args[1] = safe_trigger, + }; + + rc = cam_cpas_get_cpas_hw_version(&camera_hw_version); + if (!rc && scm_call2(SCM_SIP_FNID(0x15, 0x3), &description)) { + switch (camera_hw_version) { + case CAM_CPAS_TITAN_170_V100: + case CAM_CPAS_TITAN_170_V110: + case CAM_CPAS_TITAN_175_V100: + CAM_ERR(CAM_ISP, "scm call to enable safe failed"); + rc = -EINVAL; + break; + default: + break; + } + } + + return rc; +} + +int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, + bool protect, int32_t offset) +{ + int rc = 0; + struct scm_desc description = { + .arginfo = SCM_ARGS(2, SCM_VAL, SCM_VAL), + .args[0] = protect, + .args[1] = csiphy_dev->csiphy_cpas_cp_reg_mask[offset], + }; + + if (offset >= CSIPHY_MAX_INSTANCES) { + CAM_ERR(CAM_CSIPHY, "Invalid CSIPHY offset"); + rc = -EINVAL; + } else if (scm_call2(SCM_SIP_FNID(0x18, 0x7), &description)) { + CAM_ERR(CAM_CSIPHY, "SCM call to hypervisor failed"); + rc = -EINVAL; + } + + return 0; +} + +void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa) +{ + int reg_val; + + reg_val = scm_io_read(errata_wa->data.reg_info.offset); + reg_val |= errata_wa->data.reg_info.value; + scm_io_write(errata_wa->data.reg_info.offset, reg_val); +} +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +void cam_free_clear(const void * ptr) +{ + kfree_sensitive(ptr); +} +#else +void cam_free_clear(const void * ptr) +{ + kzfree(ptr); +} +#endif + + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) +void cam_smmu_util_iommu_custom(struct device *dev, + dma_addr_t discard_start, size_t discard_length) +{ + return; +} + +int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr) +{ + struct dma_buf_map mapping; + int error_code = dma_buf_vmap(dmabuf, &mapping); + + if (error_code) + *vaddr = 0; + else + *vaddr = (mapping.is_iomem) ? + (uintptr_t)mapping.vaddr_iomem : (uintptr_t)mapping.vaddr; + + return error_code; +} + +void cam_compat_util_put_dmabuf_va(struct dma_buf *dmabuf, void *vaddr) +{ + struct dma_buf_map mapping = DMA_BUF_MAP_INIT_VADDR(vaddr); + + dma_buf_vunmap(dmabuf, &mapping); +} + +#else +void cam_smmu_util_iommu_custom(struct device *dev, + dma_addr_t discard_start, size_t discard_length) +{ + iommu_dma_enable_best_fit_algo(dev); + + if (discard_start) + iommu_dma_reserve_iova(dev, discard_start, discard_length); + + return; +} + +int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr) +{ + int error_code = 0; + void *addr = dma_buf_vmap(dmabuf); + + if (!addr) { + *vaddr = 0; + error_code = -ENOSPC; + } else { + *vaddr = (uintptr_t)addr; + } + + return error_code; +} + +void cam_compat_util_put_dmabuf_va(struct dma_buf *dmabuf, void *vaddr) +{ + dma_buf_vunmap(dmabuf, vaddr); +} + +#endif diff --git a/drivers/cam_utils/cam_compat.h b/drivers/cam_utils/cam_compat.h new file mode 100644 index 000000000..c75da60ad --- /dev/null +++ b/drivers/cam_utils/cam_compat.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + */ + +#ifndef _CAM_COMPAT_H_ +#define _CAM_COMPAT_H_ + +#include +#include +#include + +#include "cam_csiphy_dev.h" +#include "cam_cpastop_hw.h" + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0) + +#define VFL_TYPE_VIDEO VFL_TYPE_GRABBER + +#endif + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0) + +#include +#include +#include + +#else + +#include +#include +#include + +#endif + +struct cam_fw_alloc_info { + struct device *fw_dev; + void *fw_kva; + uint64_t fw_hdl; +}; + +int cam_reserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length); +void cam_unreserve_icp_fw(struct cam_fw_alloc_info *icp_fw, size_t fw_length); +void cam_cpastop_scm_write(struct cam_cpas_hw_errata_wa *errata_wa); +int cam_ife_notify_safe_lut_scm(bool safe_trigger); +int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev, + bool protect, int32_t offset); +void cam_free_clear(const void *); +int cam_compat_util_get_dmabuf_va(struct dma_buf *dmabuf, uintptr_t *vaddr); +void cam_compat_util_put_dmabuf_va(struct dma_buf *dmabuf, void *vaddr); +void cam_smmu_util_iommu_custom(struct device *dev, + dma_addr_t discard_start, size_t discard_length); + +#endif /* _CAM_COMPAT_H_ */ diff --git a/drivers/cam_utils/cam_debug_util.c b/drivers/cam_utils/cam_debug_util.c index bc7aab55b..974957d96 100644 --- a/drivers/cam_utils/cam_debug_util.c +++ b/drivers/cam_utils/cam_debug_util.c @@ -99,6 +99,9 @@ const char *cam_get_module_name(unsigned int module_id) case CAM_PRESIL: name = "CAM-PRESIL"; break; + case CAM_IO_ACCESS: + name = "CAM-IO-ACCESS"; + break; default: name = "CAM"; break; diff --git a/drivers/cam_utils/cam_debug_util.h b/drivers/cam_utils/cam_debug_util.h index 1b2000ac0..3fdf741fb 100644 --- a/drivers/cam_utils/cam_debug_util.h +++ b/drivers/cam_utils/cam_debug_util.h @@ -46,6 +46,9 @@ #define CAM_OPE (1 << 28) #define CAM_PRESIL (1 << 27) +/* CAM_IO_ACCESS: Tracks IO read/write */ +#define CAM_IO_ACCESS (1 << 29) + #define STR_BUFFER_MAX_LENGTH 1024 /* diff --git a/drivers/cam_utils/cam_io_util.c b/drivers/cam_utils/cam_io_util.c index fcbc4b5e0..183fb76ee 100644 --- a/drivers/cam_utils/cam_io_util.c +++ b/drivers/cam_utils/cam_io_util.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2011-2014, 2017-2018, The Linux Foundation. + * Copyright (c) 2011-2014, 2017-2018, 2020, The Linux Foundation. * All rights reserved. */ @@ -15,8 +15,8 @@ int cam_io_w(uint32_t data, void __iomem *addr) if (!addr) return -EINVAL; - CAM_DBG(CAM_UTIL, "0x%pK %08x", addr, data); - writel_relaxed_no_log(data, addr); + CAM_DBG(CAM_IO_ACCESS, "0x%pK %08x", addr, data); + writel_relaxed(data, addr); return 0; } @@ -26,12 +26,8 @@ int cam_io_w_mb(uint32_t data, void __iomem *addr) if (!addr) return -EINVAL; - CAM_DBG(CAM_UTIL, "0x%pK %08x", addr, data); - /* Ensure previous writes are done */ - wmb(); - writel_relaxed_no_log(data, addr); - /* Ensure previous writes are done */ - wmb(); + CAM_DBG(CAM_IO_ACCESS, "0x%pK %08x", addr, data); + writel(data, addr); return 0; } @@ -41,12 +37,12 @@ uint32_t cam_io_r(void __iomem *addr) uint32_t data; if (!addr) { - CAM_ERR(CAM_UTIL, "Invalid args"); + CAM_ERR(CAM_IO_ACCESS, "Invalid args"); return 0; } data = readl_relaxed(addr); - CAM_DBG(CAM_UTIL, "0x%pK %08x", addr, data); + CAM_DBG(CAM_IO_ACCESS, "0x%pK %08x", addr, data); return data; } @@ -56,16 +52,12 @@ uint32_t cam_io_r_mb(void __iomem *addr) uint32_t data; if (!addr) { - CAM_ERR(CAM_UTIL, "Invalid args"); + CAM_ERR(CAM_IO_ACCESS, "Invalid args"); return 0; } - /* Ensure previous read is done */ - rmb(); - data = readl_relaxed(addr); - CAM_DBG(CAM_UTIL, "0x%pK %08x", addr, data); - /* Ensure previous read is done */ - rmb(); + data = readl(addr); + CAM_DBG(CAM_IO_ACCESS, "0x%pK %08x", addr, data); return data; } @@ -80,10 +72,10 @@ int cam_io_memcpy(void __iomem *dest_addr, if (!dest_addr || !src_addr) return -EINVAL; - CAM_DBG(CAM_UTIL, "%pK %pK %d", dest_addr, src_addr, len); + CAM_DBG(CAM_IO_ACCESS, "%pK %pK %d", dest_addr, src_addr, len); for (i = 0; i < len/4; i++) { - CAM_DBG(CAM_UTIL, "0x%pK %08x", d, *s); + CAM_DBG(CAM_IO_ACCESS, "0x%pK %08x", d, *s); writel_relaxed(*s++, d++); } @@ -100,7 +92,7 @@ int cam_io_memcpy_mb(void __iomem *dest_addr, if (!dest_addr || !src_addr) return -EINVAL; - CAM_DBG(CAM_UTIL, "%pK %pK %d", dest_addr, src_addr, len); + CAM_DBG(CAM_IO_ACCESS, "%pK %pK %d", dest_addr, src_addr, len); /* * Do not use cam_io_w_mb to avoid double wmb() after a write @@ -108,7 +100,7 @@ int cam_io_memcpy_mb(void __iomem *dest_addr, */ wmb(); for (i = 0; i < (len / 4); i++) { - CAM_DBG(CAM_UTIL, "0x%pK %08x", d, *s); + CAM_DBG(CAM_IO_ACCESS, "0x%pK %08x", d, *s); writel_relaxed(*s++, d++); } /* Ensure previous writes are done */ @@ -134,7 +126,7 @@ int cam_io_poll_value(void __iomem *addr, uint32_t wait_data, uint32_t retry, } if (cnt > retry) { - CAM_DBG(CAM_UTIL, "Poll failed by value"); + CAM_DBG(CAM_IO_ACCESS, "Poll failed by value"); rc = -EINVAL; } @@ -159,7 +151,7 @@ int cam_io_poll_value_wmask(void __iomem *addr, uint32_t wait_data, } if (cnt > retry) { - CAM_DBG(CAM_UTIL, "Poll failed with mask"); + CAM_DBG(CAM_IO_ACCESS, "Poll failed with mask"); rc = -EINVAL; } @@ -175,7 +167,7 @@ int cam_io_w_same_offset_block(const uint32_t *data, void __iomem *addr, return -EINVAL; for (i = 0; i < len; i++) { - CAM_DBG(CAM_UTIL, "i= %d len =%d val=%x addr =%pK", + CAM_DBG(CAM_IO_ACCESS, "i= %d len =%d val=%x addr =%pK", i, len, data[i], addr); writel_relaxed(data[i], addr); } @@ -192,7 +184,7 @@ int cam_io_w_mb_same_offset_block(const uint32_t *data, void __iomem *addr, return -EINVAL; for (i = 0; i < len; i++) { - CAM_DBG(CAM_UTIL, "i= %d len =%d val=%x addr =%pK", + CAM_DBG(CAM_IO_ACCESS, "i= %d len =%d val=%x addr =%pK", i, len, data[i], addr); /* Ensure previous writes are done */ wmb(); @@ -213,7 +205,8 @@ int cam_io_w_offset_val_block(const uint32_t data[][2], return -EINVAL; for (i = 0; i < len; i++) { - CAM_DBG(CAM_UTIL, "i= %d len =%d val=%x addr_base =%pK reg=%x", + CAM_DBG(CAM_IO_ACCESS, + "i= %d len =%d val=%x addr_base =%pK reg=%x", i, len, __VAL(i), addr_base, __OFFSET(i)); writel_relaxed(__VAL(i), addr_base + __OFFSET(i)); } @@ -232,7 +225,8 @@ int cam_io_w_mb_offset_val_block(const uint32_t data[][2], /* Ensure write is done */ wmb(); for (i = 0; i < len; i++) { - CAM_DBG(CAM_UTIL, "i= %d len =%d val=%x addr_base =%pK reg=%x", + CAM_DBG(CAM_IO_ACCESS, + "i= %d len =%d val=%x addr_base =%pK reg=%x", i, len, __VAL(i), addr_base, __OFFSET(i)); writel_relaxed(__VAL(i), addr_base + __OFFSET(i)); } @@ -250,7 +244,7 @@ int cam_io_dump(void __iomem *base_addr, uint32_t start_offset, int size) int i; uint32_t data; - CAM_DBG(CAM_UTIL, "addr=%pK offset=0x%x size=%d", + CAM_DBG(CAM_IO_ACCESS, "addr=%pK offset=0x%x size=%d", base_addr, start_offset, size); if (!base_addr || (size <= 0)) @@ -268,13 +262,13 @@ int cam_io_dump(void __iomem *base_addr, uint32_t start_offset, int size) snprintf(p_str, 10, "%08x ", data); p_str += 9; if ((i + 1) % NUM_REGISTER_PER_LINE == 0) { - CAM_ERR(CAM_UTIL, "%s", line_str); + CAM_ERR(CAM_IO_ACCESS, "%s", line_str); line_str[0] = '\0'; p_str = line_str; } } if (line_str[0] != '\0') - CAM_ERR(CAM_UTIL, "%s", line_str); + CAM_ERR(CAM_IO_ACCESS, "%s", line_str); return 0; } diff --git a/drivers/cam_utils/cam_soc_bus.c b/drivers/cam_utils/cam_soc_bus.c new file mode 100644 index 000000000..465a7da4f --- /dev/null +++ b/drivers/cam_utils/cam_soc_bus.c @@ -0,0 +1,232 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. + */ + +#include +#include "cam_soc_bus.h" + +/** + * struct cam_soc_bus_client_data : Bus client data + * + * @pdata: Bus pdata information + * @client_id: Bus client id + * @num_paths: Number of paths for this client + * @curr_vote_level: current voted index + * @dyn_vote: whether dynamic voting enabled + */ +struct cam_soc_bus_client_data { + struct msm_bus_scale_pdata *pdata; + uint32_t client_id; + int num_paths; + unsigned int curr_vote_level; + bool dyn_vote; +}; + +int cam_soc_bus_client_update_request(void *client, unsigned int idx) +{ + int rc = 0; + struct cam_soc_bus_client *bus_client = + (struct cam_soc_bus_client *) client; + struct cam_soc_bus_client_data *bus_client_data = + (struct cam_soc_bus_client_data *) bus_client->client_data; + + if (bus_client_data->dyn_vote) { + CAM_ERR(CAM_UTIL, + "Dyn update not allowed client[%d][%s], dyn_vote: %d", + bus_client_data->client_id, + bus_client->common_data->name, + bus_client_data->dyn_vote); + rc = -EINVAL; + goto end; + } + + if (idx >= bus_client->common_data->num_usecases) { + CAM_ERR(CAM_UTIL, "Invalid vote level=%d, usecases=%d", idx, + bus_client->common_data->num_usecases); + rc = -EINVAL; + goto end; + } + + CAM_DBG(CAM_PERF, "Bus client=[%d][%s] index[%d]", + bus_client_data->client_id, bus_client->common_data->name, idx); + + rc = msm_bus_scale_client_update_request(bus_client_data->client_id, + idx); + if (rc) { + CAM_ERR(CAM_UTIL, + "Update request failed, client[%d][%s], idx: %d", + bus_client_data->client_id, + bus_client->common_data->name, idx); + goto end; + } + +end: + return rc; +} + +int cam_soc_bus_client_update_bw(void *client, uint64_t ab, uint64_t ib) +{ + int idx = 0; + struct msm_bus_paths *path; + struct msm_bus_scale_pdata *pdata; + struct cam_soc_bus_client *bus_client = + (struct cam_soc_bus_client *) client; + struct cam_soc_bus_client_data *bus_client_data = + (struct cam_soc_bus_client_data *) bus_client->client_data; + int rc = 0; + + if ((bus_client->common_data->num_usecases != 2) || + (bus_client_data->num_paths != 1) || + (!bus_client_data->dyn_vote)) { + CAM_ERR(CAM_UTIL, + "dynamic update not allowed Bus client=[%d][%s], %d %d %d", + bus_client_data->client_id, + bus_client->common_data->name, + bus_client->common_data->num_usecases, + bus_client_data->num_paths, + bus_client_data->dyn_vote); + rc = -EINVAL; + goto end; + } + + idx = bus_client_data->curr_vote_level; + idx = 1 - idx; + bus_client_data->curr_vote_level = idx; + + pdata = bus_client_data->pdata; + path = &(pdata->usecase[idx]); + path->vectors[0].ab = ab; + path->vectors[0].ib = ib; + + CAM_DBG(CAM_PERF, "Bus client=[%d][%s] :ab[%llu] ib[%llu], index[%d]", + bus_client_data->client_id, bus_client->common_data->name, ab, + ib, idx); + rc = msm_bus_scale_client_update_request(bus_client_data->client_id, + idx); + if (rc) { + CAM_ERR(CAM_UTIL, + "Update request failed, client[%d][%s], idx: %d", + bus_client_data->client_id, + bus_client->common_data->name, idx); + return rc; + } + +end: + return rc; +} + +int cam_soc_bus_client_register(struct platform_device *pdev, + struct device_node *dev_node, void **client, + struct cam_soc_bus_client_common_data *common_data) +{ + struct msm_bus_scale_pdata *pdata = NULL; + struct cam_soc_bus_client *bus_client = NULL; + struct cam_soc_bus_client_data *bus_client_data = NULL; + uint32_t client_id; + int rc; + + bus_client = kzalloc(sizeof(struct cam_soc_bus_client), GFP_KERNEL); + if (!bus_client) { + CAM_ERR(CAM_UTIL, "Non Enought Memroy"); + rc = -ENOMEM; + goto end; + } + + *client = bus_client; + + bus_client_data = kzalloc(sizeof(struct cam_soc_bus_client_data), + GFP_KERNEL); + if (!bus_client_data) { + kfree(bus_client); + *client = NULL; + rc = -ENOMEM; + goto end; + } + + bus_client->client_data = bus_client_data; + pdata = msm_bus_pdata_from_node(pdev, + dev_node); + if (!pdata) { + CAM_ERR(CAM_UTIL, "failed get_pdata"); + rc = -EINVAL; + goto error; + } + + if ((pdata->num_usecases == 0) || + (pdata->usecase[0].num_paths == 0)) { + CAM_ERR(CAM_UTIL, "usecase=%d", pdata->num_usecases); + rc = -EINVAL; + goto error; + } + + client_id = msm_bus_scale_register_client(pdata); + if (!client_id) { + CAM_ERR(CAM_UTIL, "failed in register bus client_data"); + rc = -EINVAL; + goto error; + } + + bus_client->common_data = common_data; + + bus_client_data->dyn_vote = of_property_read_bool(dev_node, + "qcom,msm-bus-vector-dyn-vote"); + + if (bus_client_data->dyn_vote && (pdata->num_usecases != 2)) { + CAM_ERR(CAM_UTIL, "Excess or less vectors %d", + pdata->num_usecases); + rc = -EINVAL; + goto fail_unregister_client; + } + + rc = msm_bus_scale_client_update_request(client_id, 0); + if (rc) { + CAM_ERR(CAM_UTIL, "Bus client update request failed, rc = %d", + rc); + goto fail_unregister_client; + } + + bus_client->common_data->src_id = pdata->usecase[0].vectors[0].src; + bus_client->common_data->dst_id = pdata->usecase[0].vectors[0].dst; + bus_client_data->pdata = pdata; + bus_client_data->client_id = client_id; + bus_client->common_data->num_usecases = pdata->num_usecases; + bus_client_data->num_paths = pdata->usecase[0].num_paths; + bus_client->common_data->name = pdata->name; + + CAM_DBG(CAM_PERF, "Register Bus Client=[%d][%s] : src=%d, dst=%d", + bus_client_data->client_id, bus_client->common_data->name, + bus_client->common_data->src_id, + bus_client->common_data->dst_id); + + return 0; +fail_unregister_client: + msm_bus_scale_unregister_client(bus_client_data->client_id); +error: + kfree(bus_client_data); + bus_client->client_data = NULL; + kfree(bus_client); + *client = NULL; +end: + return rc; + +} + +void cam_soc_bus_client_unregister(void **client) +{ + struct cam_soc_bus_client *bus_client = + (struct cam_soc_bus_client *) (*client); + struct cam_soc_bus_client_data *bus_client_data = + (struct cam_soc_bus_client_data *) bus_client->client_data; + + if (bus_client_data->dyn_vote) + cam_soc_bus_client_update_bw(bus_client, 0, 0); + else + cam_soc_bus_client_update_request(bus_client, 0); + + msm_bus_scale_unregister_client(bus_client_data->client_id); + kfree(bus_client_data); + bus_client->client_data = NULL; + kfree(bus_client); + *client = NULL; +} diff --git a/drivers/cam_utils/cam_soc_bus.h b/drivers/cam_utils/cam_soc_bus.h new file mode 100644 index 000000000..518b6524d --- /dev/null +++ b/drivers/cam_utils/cam_soc_bus.h @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + */ + +#ifndef _CAM_SOC_BUS_H_ +#define _CAM_SOC_BUS_H_ + +#include +#include +#include +#include "cam_debug_util.h" + +#define CAM_SOC_BUS_MAX_NUM_USECASES 8 + +/** + * struct cam_soc_bus_client_ab_ib : Bandwidth values for selected usecase + * + * @ab: Arbitrated Bandwidth + * @ib: Instantaneous Bandwidth + */ +struct cam_soc_bus_client_ab_ib { + uint64_t ab; + uint64_t ib; +}; + +/** + * struct cam_soc_bus_client_common_data : Common data fields for bus client + * + * @name: Name of bus client + * @src_id: Bus master/src id + * @dst_id: Bus slave/dst id + * @num_usecases: Number of use cases for this client + * @bw_pair: Bandwidth values for applicable usecases + */ +struct cam_soc_bus_client_common_data { + const char *name; + uint32_t src_id; + uint32_t dst_id; + int num_usecases; + struct cam_soc_bus_client_ab_ib bw_pair[CAM_SOC_BUS_MAX_NUM_USECASES]; +}; + +/** + * struct cam_soc_bus_client : Bus client information + * + * @client_data: Bus client data + * @common_data: Common data fields for bus client + */ +struct cam_soc_bus_client { + void *client_data; + struct cam_soc_bus_client_common_data *common_data; +}; + + +#if IS_REACHABLE(CONFIG_QCOM_BUS_SCALING) || \ + IS_REACHABLE(CONFIG_INTERCONNECT_QCOM) + +int cam_soc_bus_client_update_request(void *client, unsigned int idx); + +int cam_soc_bus_client_update_bw(void *client, uint64_t ab, + uint64_t ib); + +int cam_soc_bus_client_register(struct platform_device *pdev, + struct device_node *dev_node, void **client, + struct cam_soc_bus_client_common_data *common_data); + +void cam_soc_bus_client_unregister(void **client); + +#else +static inline int cam_soc_bus_client_update_request(void *client, + unsigned int idx) +{ + return 0; +} + +static inline int cam_soc_bus_client_update_bw(void *client, + uint64_t ab, uint64_t ib) +{ + return 0; +} + +static inline int cam_soc_bus_client_register( + struct platform_device *pdev, struct device_node *dev_node, + void **client, struct cam_soc_bus_client_common_data *common_data) +{ + return 0; +} + +static inline void cam_soc_bus_client_unregister(void **client) +{ +} + +#endif + +#endif /* _CAM_SOC_BUS_H_ */ diff --git a/drivers/cam_utils/cam_soc_icc.c b/drivers/cam_utils/cam_soc_icc.c new file mode 100644 index 000000000..147d80262 --- /dev/null +++ b/drivers/cam_utils/cam_soc_icc.c @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. + */ + +#include +#include "cam_soc_bus.h" + +/** + * struct cam_soc_bus_client_data : Bus client data + * + * @icc_data: Bus icc path information + */ +struct cam_soc_bus_client_data { + struct icc_path *icc_data; +}; + +int cam_soc_bus_client_update_request(void *client, unsigned int idx) +{ + int rc = 0; + uint64_t ab = 0, ib = 0; + struct cam_soc_bus_client *bus_client = + (struct cam_soc_bus_client *) client; + struct cam_soc_bus_client_data *bus_client_data = + (struct cam_soc_bus_client_data *) bus_client->client_data; + + if (idx >= bus_client->common_data->num_usecases) { + CAM_ERR(CAM_UTIL, "Invalid vote level=%d, usecases=%d", idx, + bus_client->common_data->num_usecases); + rc = -EINVAL; + goto end; + } + + ab = bus_client->common_data->bw_pair[idx].ab; + ib = bus_client->common_data->bw_pair[idx].ib; + + CAM_DBG(CAM_PERF, "Bus client=[%s] index[%d] ab[%llu] ib[%llu]", + bus_client->common_data->name, idx, ab, ib); + + rc = icc_set_bw(bus_client_data->icc_data, Bps_to_icc(ab), + Bps_to_icc(ib)); + if (rc) { + CAM_ERR(CAM_UTIL, + "Update request failed, client[%s], idx: %d", + bus_client->common_data->name, idx); + goto end; + } + +end: + return rc; +} + +int cam_soc_bus_client_update_bw(void *client, uint64_t ab, uint64_t ib) +{ + struct cam_soc_bus_client *bus_client = + (struct cam_soc_bus_client *) client; + struct cam_soc_bus_client_data *bus_client_data = + (struct cam_soc_bus_client_data *) bus_client->client_data; + int rc = 0; + + CAM_DBG(CAM_PERF, "Bus client=[%s] :ab[%llu] ib[%llu]", + bus_client->common_data->name, ab, ib); + rc = icc_set_bw(bus_client_data->icc_data, Bps_to_icc(ab), + Bps_to_icc(ib)); + if (rc) { + CAM_ERR(CAM_UTIL, "Update request failed, client[%s]", + bus_client->common_data->name); + goto end; + } + +end: + return rc; +} + +int cam_soc_bus_client_register(struct platform_device *pdev, + struct device_node *dev_node, void **client, + struct cam_soc_bus_client_common_data *common_data) +{ + struct cam_soc_bus_client *bus_client = NULL; + struct cam_soc_bus_client_data *bus_client_data = NULL; + int rc = 0; + + bus_client = kzalloc(sizeof(struct cam_soc_bus_client), GFP_KERNEL); + if (!bus_client) { + CAM_ERR(CAM_UTIL, "soc bus client is NULL"); + rc = -ENOMEM; + goto end; + } + + *client = bus_client; + + bus_client_data = kzalloc(sizeof(struct cam_soc_bus_client_data), + GFP_KERNEL); + if (!bus_client_data) { + kfree(bus_client); + *client = NULL; + rc = -ENOMEM; + goto end; + } + + bus_client->client_data = bus_client_data; + bus_client->common_data = common_data; + bus_client_data->icc_data = icc_get(&pdev->dev, + bus_client->common_data->src_id, + bus_client->common_data->dst_id); + if (IS_ERR_OR_NULL(bus_client_data->icc_data)) { + CAM_ERR(CAM_UTIL, "failed in register bus client"); + rc = -EINVAL; + goto error; + } + + rc = icc_set_bw(bus_client_data->icc_data, 0, 0); + if (rc) { + CAM_ERR(CAM_UTIL, "Bus client update request failed, rc = %d", + rc); + goto fail_unregister_client; + } + + CAM_DBG(CAM_PERF, "Register Bus Client=[%s] : src=%d, dst=%d", + bus_client->common_data->name, bus_client->common_data->src_id, + bus_client->common_data->dst_id); + + return 0; + +fail_unregister_client: + icc_put(bus_client_data->icc_data); +error: + kfree(bus_client_data); + bus_client->client_data = NULL; + kfree(bus_client); + *client = NULL; +end: + return rc; + +} + +void cam_soc_bus_client_unregister(void **client) +{ + struct cam_soc_bus_client *bus_client = + (struct cam_soc_bus_client *) (*client); + struct cam_soc_bus_client_data *bus_client_data = + (struct cam_soc_bus_client_data *) bus_client->client_data; + + icc_put(bus_client_data->icc_data); + kfree(bus_client_data); + bus_client->client_data = NULL; + kfree(bus_client); + *client = NULL; + +} diff --git a/drivers/cam_utils/cam_soc_util.c b/drivers/cam_utils/cam_soc_util.c index 57c8efaf7..764fa90a3 100644 --- a/drivers/cam_utils/cam_soc_util.c +++ b/drivers/cam_utils/cam_soc_util.c @@ -14,7 +14,6 @@ #include "cam_mem_mgr.h" static char supported_clk_info[256]; -static char debugfs_dir_name[64]; int cam_soc_util_get_clk_level(struct cam_hw_soc_info *soc_info, int64_t clk_rate, int clk_idx, int32_t *clk_lvl) @@ -181,51 +180,51 @@ DEFINE_SIMPLE_ATTRIBUTE(cam_soc_util_clk_lvl_control, * * @return: Success or failure */ -static int cam_soc_util_create_clk_lvl_debugfs( - struct cam_hw_soc_info *soc_info) +static int cam_soc_util_create_clk_lvl_debugfs(struct cam_hw_soc_info *soc_info) { - struct dentry *dentry = NULL; + char debugfs_dir_name[64]; + int rc = 0; + struct dentry *dbgfileptr = NULL; if (!soc_info) { CAM_ERR(CAM_UTIL, "soc info is NULL"); return -EINVAL; } - if (soc_info->dentry) - return 0; + if (soc_info->dentry) { + CAM_DBG(CAM_UTIL, "Debugfs entry for %s already exist", + soc_info->dev_name); + goto end; + } memset(debugfs_dir_name, 0, sizeof(debugfs_dir_name)); strlcat(debugfs_dir_name, "clk_dir_", sizeof(debugfs_dir_name)); strlcat(debugfs_dir_name, soc_info->dev_name, sizeof(debugfs_dir_name)); - dentry = soc_info->dentry; - dentry = debugfs_create_dir(debugfs_dir_name, NULL); - if (!dentry) { - CAM_ERR(CAM_UTIL, "failed to create debug directory"); - return -ENOMEM; - } - - if (!debugfs_create_file("clk_lvl_options", 0444, - dentry, soc_info, &cam_soc_util_clk_lvl_options)) { - CAM_ERR(CAM_UTIL, "failed to create clk_lvl_options"); - goto err; + dbgfileptr = debugfs_create_dir(debugfs_dir_name, NULL); + if (!dbgfileptr) { + CAM_ERR(CAM_UTIL,"DebugFS could not create directory!"); + rc = -ENOENT; + goto end; } + /* Store parent inode for cleanup in caller */ + soc_info->dentry = dbgfileptr; - if (!debugfs_create_file("clk_lvl_control", 0644, - dentry, soc_info, &cam_soc_util_clk_lvl_control)) { - CAM_ERR(CAM_UTIL, "failed to create clk_lvl_control"); - goto err; + dbgfileptr = debugfs_create_file("clk_lvl_options", 0444, + soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_options); + dbgfileptr = debugfs_create_file("clk_lvl_control", 0644, + soc_info->dentry, soc_info, &cam_soc_util_clk_lvl_control); + if (IS_ERR(dbgfileptr)) { + if (PTR_ERR(dbgfileptr) == -ENODEV) + CAM_WARN(CAM_UTIL, "DebugFS not enabled in kernel!"); + else + rc = PTR_ERR(dbgfileptr); } CAM_DBG(CAM_UTIL, "clk lvl debugfs for %s successfully created", soc_info->dev_name); - - return 0; - -err: - debugfs_remove_recursive(dentry); - dentry = NULL; - return -ENOMEM; +end: + return rc; } /** diff --git a/drivers/cam_utils/cam_soc_util.h b/drivers/cam_utils/cam_soc_util.h index bb4aff5e7..0950150d7 100644 --- a/drivers/cam_utils/cam_soc_util.h +++ b/drivers/cam_utils/cam_soc_util.h @@ -18,7 +18,7 @@ #include #include "cam_io_util.h" -#include +#include #define NO_SET_RATE -1 #define INIT_RATE -2 diff --git a/drivers/cam_utils/cam_trace.h b/drivers/cam_utils/cam_trace.h index 94e26405c..be30708a5 100644 --- a/drivers/cam_utils/cam_trace.h +++ b/drivers/cam_utils/cam_trace.h @@ -11,7 +11,7 @@ #undef TRACE_INCLUDE_PATH #define TRACE_INCLUDE_PATH . #undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE ../../techpack/camera/drivers/cam_utils/cam_trace +#define TRACE_INCLUDE_FILE ./cam_trace #include #include diff --git a/drivers/camera_main.c b/drivers/camera_main.c new file mode 100644 index 000000000..e1c7b2051 --- /dev/null +++ b/drivers/camera_main.c @@ -0,0 +1,292 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + */ +#include +#include + +#include "cam_req_mgr_dev.h" +#include "cam_sync_api.h" +#include "cam_smmu_api.h" +#include "cam_cpas_hw_intf.h" +#include "cam_cdm_intf_api.h" + +#include "cam_ife_csid_dev.h" +#include "cam_vfe.h" +#include "cam_isp_dev.h" + +#include "cam_res_mgr_api.h" +#include "cam_cci_dev.h" +#include "cam_sensor_dev.h" +#include "cam_actuator_dev.h" +#include "cam_csiphy_dev.h" +#include "cam_eeprom_dev.h" +#include "cam_ois_dev.h" + +#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) +#include "cam_flash_dev.h" +#endif + +#include "a5_core.h" +#include "ipe_core.h" +#include "bps_core.h" +#include "cam_icp_subdev.h" + +#include "jpeg_dma_core.h" +#include "jpeg_enc_core.h" +#include "cam_jpeg_dev.h" + +#include "cam_fd_hw_intf.h" +#include "cam_fd_dev.h" + +#include "cam_lrme_hw_intf.h" +#include "cam_lrme_dev.h" + +#include "cam_custom_dev.h" +#include "cam_custom_csid_dev.h" +#include "cam_custom_sub_mod_dev.h" + +#include "cam_debug_util.h" +#include "ope_dev_intf.h" +#include "cam_csid_ppi100.h" +#include "cam_tfe_dev.h" +#include "cam_tfe_csid530.h" +#include "cam_top_tpg_v1.h" + +struct camera_submodule_component { + int (*init)(void); + void (*exit)(void); +}; + +struct camera_submodule { + char *name; + uint num_component; + const struct camera_submodule_component *component; +}; + +static const struct camera_submodule_component camera_base[] = { + {&cam_req_mgr_init, &cam_req_mgr_exit}, + {&cam_sync_init, &cam_sync_exit}, + {&cam_smmu_init_module, &cam_smmu_exit_module}, + {&cam_cpas_dev_init_module, &cam_cpas_dev_exit_module}, + {&cam_cdm_intf_init_module, &cam_cdm_intf_exit_module}, + {&cam_hw_cdm_init_module, &cam_hw_cdm_exit_module}, +}; + +static const struct camera_submodule_component camera_tfe[] = { +#ifdef CONFIG_SPECTRA_TFE + {&cam_csid_ppi100_init_module, &cam_csid_ppi100_exit_module}, + {&cam_tfe_init_module, &cam_tfe_exit_module}, + {&cam_tfe_csid530_init_module, &cam_tfe_csid530_exit_module}, +#endif +}; + +static const struct camera_submodule_component camera_isp[] = { +#ifdef CONFIG_SPECTRA_ISP + {&cam_top_tpg_v1_init_module, &cam_top_tpg_v1_exit_module}, + {&cam_isp_dev_init_module, &cam_isp_dev_exit_module}, +#endif +}; + +static const struct camera_submodule_component camera_sensor[] = { +#ifdef CONFIG_SPECTRA_SENSOR + {&cam_res_mgr_init, &cam_res_mgr_exit}, + {&cam_cci_init_module, &cam_cci_exit_module}, + {&cam_csiphy_init_module, &cam_csiphy_exit_module}, + {&cam_actuator_driver_init, &cam_actuator_driver_exit}, + {&cam_sensor_driver_init, &cam_sensor_driver_exit}, + {&cam_eeprom_driver_init, &cam_eeprom_driver_exit}, + {&cam_ois_driver_init, &cam_ois_driver_exit}, +#if IS_REACHABLE(CONFIG_LEDS_QPNP_FLASH_V2) + {&cam_flash_init_module, &cam_flash_exit_module}, +#endif +#endif +}; + +static const struct camera_submodule_component camera_icp[] = { +#ifdef CONFIG_SPECTRA_ICP + {&cam_a5_init_module, &cam_a5_exit_module}, + {&cam_ipe_init_module, &cam_ipe_exit_module}, + {&cam_bps_init_module, &cam_bps_exit_module}, + {&cam_icp_init_module, &cam_icp_exit_module}, +#endif +}; + +static const struct camera_submodule_component camera_ope[] = { +#ifdef CONFIG_SPECTRA_OPE + {&cam_ope_init_module, &cam_ope_exit_module}, + {&cam_ope_subdev_init_module, &cam_ope_subdev_exit_module}, +#endif +}; + +static const struct camera_submodule_component camera_jpeg[] = { +#ifdef CONFIG_SPECTRA_JPEG + {&cam_jpeg_enc_init_module, &cam_jpeg_enc_exit_module}, + {&cam_jpeg_dma_init_module, &cam_jpeg_dma_exit_module}, + {&cam_jpeg_dev_init_module, &cam_jpeg_dev_exit_module}, +#endif +}; + +static const struct camera_submodule_component camera_fd[] = { +#ifdef CONFIG_SPECTRA_FD + {&cam_fd_hw_init_module, &cam_fd_hw_exit_module}, + {&cam_fd_dev_init_module, &cam_fd_dev_exit_module}, +#endif +}; + +static const struct camera_submodule_component camera_lrme[] = { +#ifdef CONFIG_SPECTRA_LRME + {&cam_lrme_hw_init_module, &cam_lrme_hw_exit_module}, + {&cam_lrme_dev_init_module, &cam_lrme_dev_exit_module}, +#endif +}; + +static const struct camera_submodule_component camera_custom[] = { +#ifdef CONFIG_SPECTRA_CUSTOM + {&cam_custom_hw_sub_module_init, &cam_custom_hw_sub_module_exit}, + {&cam_custom_csid_driver_init, &cam_custom_csid_driver_exit}, + {&cam_custom_dev_init_module, &cam_custom_dev_exit_module}, +#endif +}; + +static const struct camera_submodule submodule_table[] = { + { + .name = "Camera BASE", + .num_component = ARRAY_SIZE(camera_base), + .component = camera_base, + }, + { + .name = "Camera TFE", + .num_component = ARRAY_SIZE(camera_tfe), + .component = camera_tfe, + }, + { + .name = "Camera ISP", + .num_component = ARRAY_SIZE(camera_isp), + .component = camera_isp, + }, + { + .name = "Camera SENSOR", + .num_component = ARRAY_SIZE(camera_sensor), + .component = camera_sensor + }, + { + .name = "Camera ICP", + .num_component = ARRAY_SIZE(camera_icp), + .component = camera_icp, + }, + { + .name = "Camera OPE", + .num_component = ARRAY_SIZE(camera_ope), + .component = camera_ope, + }, + { + .name = "Camera JPEG", + .num_component = ARRAY_SIZE(camera_jpeg), + .component = camera_jpeg, + }, + { + .name = "Camera FD", + .num_component = ARRAY_SIZE(camera_fd), + .component = camera_fd, + }, + { + .name = "Camera LRME", + .num_component = ARRAY_SIZE(camera_lrme), + .component = camera_lrme, + }, + { + .name = "Camera CUSTOM", + .num_component = ARRAY_SIZE(camera_custom), + .component = camera_custom, + } +}; + +static int camera_verify_submodules(void) +{ + int rc = 0; + int i, j, num_components; + + for (i = 0; i < ARRAY_SIZE(submodule_table); i++) { + num_components = submodule_table[i].num_component; + for (j = 0; j < num_components; j++) { + if (!submodule_table[i].component[j].init || + !submodule_table[i].component[j].exit) { + CAM_ERR(CAM_UTIL, + "%s module has init = %ps, exit = %ps", + submodule_table[i].name, + submodule_table[i].component[j].init, + submodule_table[i].component[j].exit); + rc = -EINVAL; + goto end; + } + } + } + +end: + return rc; +} + +static void __camera_exit(int i, int j) +{ + uint num_exits; + + /* Exit from current submodule */ + for (j -= 1; j >= 0; j--) + submodule_table[i].component[j].exit(); + + /* Exit remaining submodules */ + for (i -= 1; i >= 0; i--) { + num_exits = submodule_table[i].num_component; + for (j = num_exits - 1; j >= 0; j--) + submodule_table[i].component[j].exit(); + } +} + +static int camera_init(void) +{ + int rc; + uint i, j, num_inits; + + rc = camera_verify_submodules(); + if (rc) + goto end_init; + + /* For Probing all available submodules */ + for (i = 0; i < ARRAY_SIZE(submodule_table); i++) { + num_inits = submodule_table[i].num_component; + CAM_DBG(CAM_UTIL, "Number of %s components: %u", + submodule_table[i].name, num_inits); + for (j = 0; j < num_inits; j++) { + rc = submodule_table[i].component[j].init(); + if (rc) { + CAM_ERR(CAM_UTIL, + "%s module failure at %ps rc = %d", + submodule_table[i].name, + submodule_table[i].component[j].init, + rc); + __camera_exit(i, j); + goto end_init; + } + } + } + + CAM_INFO(CAM_UTIL, "Spectra camera driver initialized!"); + +end_init: + return rc; +} + +static void camera_exit(void) +{ + __camera_exit(ARRAY_SIZE(submodule_table), 0); + + CAM_INFO(CAM_UTIL, "Spectra camera driver exited!"); +} + +module_init(camera_init); +module_exit(camera_exit); + +MODULE_DESCRIPTION("Spectra camera driver"); +MODULE_LICENSE("GPL v2"); diff --git a/dt-bindings/msm-camera.h b/dt-bindings/msm-camera.h new file mode 100644 index 000000000..9d3b5dd1d --- /dev/null +++ b/dt-bindings/msm-camera.h @@ -0,0 +1,99 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + */ + +#ifndef __MSM_CAMERA_H +#define __MSM_CAMERA_H + +/* CPAS path data types */ +#define CAM_CPAS_PATH_DATA_IFE_START_OFFSET 0 +#define CAM_CPAS_PATH_DATA_IFE_LINEAR (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 0) +#define CAM_CPAS_PATH_DATA_IFE_VID (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 1) +#define CAM_CPAS_PATH_DATA_IFE_DISP (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 2) +#define CAM_CPAS_PATH_DATA_IFE_STATS (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 3) +#define CAM_CPAS_PATH_DATA_IFE_RDI0 (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 4) +#define CAM_CPAS_PATH_DATA_IFE_RDI1 (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 5) +#define CAM_CPAS_PATH_DATA_IFE_RDI2 (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 6) +#define CAM_CPAS_PATH_DATA_IFE_RDI3 (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 7) +#define CAM_CPAS_PATH_DATA_IFE_PDAF (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 8) +#define CAM_CPAS_PATH_DATA_IFE_PIXEL_RAW \ + (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 9) +#define CAM_CPAS_PATH_DATA_IFE_MAX_OFFSET \ + (CAM_CPAS_PATH_DATA_IFE_START_OFFSET + 31) + +#define CAM_CPAS_PATH_DATA_IPE_START_OFFSET 32 +#define CAM_CPAS_PATH_DATA_IPE_RD_IN (CAM_CPAS_PATH_DATA_IPE_START_OFFSET + 0) +#define CAM_CPAS_PATH_DATA_IPE_RD_REF (CAM_CPAS_PATH_DATA_IPE_START_OFFSET + 1) +#define CAM_CPAS_PATH_DATA_IPE_WR_VID (CAM_CPAS_PATH_DATA_IPE_START_OFFSET + 2) +#define CAM_CPAS_PATH_DATA_IPE_WR_DISP (CAM_CPAS_PATH_DATA_IPE_START_OFFSET + 3) +#define CAM_CPAS_PATH_DATA_IPE_WR_REF (CAM_CPAS_PATH_DATA_IPE_START_OFFSET + 4) +#define CAM_CPAS_PATH_DATA_IPE_MAX_OFFSET \ + (CAM_CPAS_PATH_DATA_IPE_START_OFFSET + 31) + +#define CAM_CPAS_PATH_DATA_OPE_START_OFFSET 64 +#define CAM_CPAS_PATH_DATA_OPE_RD_IN (CAM_CPAS_PATH_DATA_OPE_START_OFFSET + 0) +#define CAM_CPAS_PATH_DATA_OPE_RD_REF (CAM_CPAS_PATH_DATA_OPE_START_OFFSET + 1) +#define CAM_CPAS_PATH_DATA_OPE_WR_VID (CAM_CPAS_PATH_DATA_OPE_START_OFFSET + 2) +#define CAM_CPAS_PATH_DATA_OPE_WR_DISP (CAM_CPAS_PATH_DATA_OPE_START_OFFSET + 3) +#define CAM_CPAS_PATH_DATA_OPE_WR_REF (CAM_CPAS_PATH_DATA_OPE_START_OFFSET + 4) +#define CAM_CPAS_PATH_DATA_OPE_MAX_OFFSET \ + (CAM_CPAS_PATH_DATA_OPE_START_OFFSET + 31) + +#define CAM_CPAS_PATH_DATA_SFE_START_OFFSET 96 +#define CAM_CPAS_PATH_DATA_SFE_NRDI (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 0) +#define CAM_CPAS_PATH_DATA_SFE_RDI0 (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 1) +#define CAM_CPAS_PATH_DATA_SFE_RDI1 (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 2) +#define CAM_CPAS_PATH_DATA_SFE_RDI2 (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 3) +#define CAM_CPAS_PATH_DATA_SFE_RDI3 (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 4) +#define CAM_CPAS_PATH_DATA_SFE_RDI4 (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 5) +#define CAM_CPAS_PATH_DATA_SFE_STATS (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 6) +#define CAM_CPAS_PATH_DATA_SFE_MAX_OFFSET \ + (CAM_CPAS_PATH_DATA_SFE_START_OFFSET + 31) + +#define CAM_CPAS_PATH_DATA_CONSO_OFFSET 256 +#define CAM_CPAS_PATH_DATA_ALL (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 0) + +/* IFE consolidated paths */ +#define CAM_CPAS_PATH_DATA_IFE_LINEAR_PDAF (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 1) +#define CAM_CPAS_PATH_DATA_IFE_UBWC_STATS (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 2) +#define CAM_CPAS_PATH_DATA_IFE_PIXEL_ALL (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 3) +#define CAM_CPAS_PATH_DATA_IFE_RDI_PIXEL_RAW \ + (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 4) +#define CAM_CPAS_PATH_DATA_IFE_RDI_ALL (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 5) +#define CAM_CPAS_PATH_DATA_IFE_UBWC (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 6) +#define CAM_CPAS_PATH_DATA_IFE_LINEAR_STATS \ + (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 7) + +/* IPE Consolidated paths */ +#define CAM_CPAS_PATH_DATA_IPE_WR_VID_DISP (CAM_CPAS_PATH_DATA_CONSO_OFFSET + 1) + +/* CPAS transaction types */ +#define CAM_CPAS_TRANSACTION_READ 0 +#define CAM_CPAS_TRANSACTION_WRITE 1 + +/* CPAS traffic merge types */ +#define CAM_CPAS_TRAFFIC_MERGE_SUM 0 +#define CAM_CPAS_TRAFFIC_MERGE_SUM_INTERLEAVE 1 + +/* Feature bit type */ +#define CAM_CPAS_FEATURE_TYPE_DISABLE 0 +#define CAM_CPAS_FEATURE_TYPE_ENABLE 1 +#define CAM_CPAS_FEATURE_TYPE_VALUE 2 + +/* Feature support bit positions in feature fuse register*/ +#define CAM_CPAS_QCFA_BINNING_ENABLE 0 +#define CAM_CPAS_SECURE_CAMERA_ENABLE 1 +#define CAM_CPAS_MF_HDR_ENABLE 2 +#define CAM_CPAS_MP_LIMIT_FUSE 3 +#define CAM_CPAS_ISP_FUSE 4 +#define CAM_CPAS_ISP_PIX_FUSE 5 +#define CAM_CPAS_FUSE_FEATURE_MAX 6 + +/* Flash type*/ +#define CAM_FLASH_TYPE_PMIC 0 +#define CAM_FLASH_TYPE_I2C 1 +#define CAM_FLASH_TYPE_GPIO 2 + +#endif diff --git a/include/Kbuild b/include/Kbuild deleted file mode 100644 index bab1145bc..000000000 --- a/include/Kbuild +++ /dev/null @@ -1,2 +0,0 @@ -# Top-level Makefile calls into asm-$(ARCH) -# List only non-arch directories below diff --git a/include/uapi/Android.mk b/include/uapi/Android.mk new file mode 100644 index 000000000..a39ec2641 --- /dev/null +++ b/include/uapi/Android.mk @@ -0,0 +1,10 @@ +# Standalone camera UAPI header android target +LOCAL_PATH := $(call my-dir) +# Path variable for other modules to include for compilation +LOCAL_EXPORT_CAMERA_UAPI_INCLUDE := $(LOCAL_PATH)/camera/ + +CAMERA_HEADERS := $(call all-subdir-named-files,*.h) +KERNEL_SCRIPTS := $(shell pwd)/kernel/msm-$(TARGET_KERNEL_VERSION)/scripts + +include $(CLEAR_VARS) +LOCAL_MODULE := camera-uapi diff --git a/include/uapi/Kbuild b/include/uapi/Kbuild deleted file mode 100644 index 93dffc4ba..000000000 --- a/include/uapi/Kbuild +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note - -header-y += media/ diff --git a/include/uapi/media/cam_cpas.h b/include/uapi/camera/media/cam_cpas.h similarity index 100% rename from include/uapi/media/cam_cpas.h rename to include/uapi/camera/media/cam_cpas.h diff --git a/include/uapi/media/cam_custom.h b/include/uapi/camera/media/cam_custom.h similarity index 100% rename from include/uapi/media/cam_custom.h rename to include/uapi/camera/media/cam_custom.h diff --git a/include/uapi/media/cam_defs.h b/include/uapi/camera/media/cam_defs.h similarity index 100% rename from include/uapi/media/cam_defs.h rename to include/uapi/camera/media/cam_defs.h diff --git a/include/uapi/media/cam_fd.h b/include/uapi/camera/media/cam_fd.h similarity index 100% rename from include/uapi/media/cam_fd.h rename to include/uapi/camera/media/cam_fd.h diff --git a/include/uapi/media/cam_icp.h b/include/uapi/camera/media/cam_icp.h similarity index 100% rename from include/uapi/media/cam_icp.h rename to include/uapi/camera/media/cam_icp.h diff --git a/include/uapi/media/cam_isp.h b/include/uapi/camera/media/cam_isp.h similarity index 100% rename from include/uapi/media/cam_isp.h rename to include/uapi/camera/media/cam_isp.h diff --git a/include/uapi/media/cam_isp_ife.h b/include/uapi/camera/media/cam_isp_ife.h similarity index 100% rename from include/uapi/media/cam_isp_ife.h rename to include/uapi/camera/media/cam_isp_ife.h diff --git a/include/uapi/media/cam_isp_tfe.h b/include/uapi/camera/media/cam_isp_tfe.h similarity index 100% rename from include/uapi/media/cam_isp_tfe.h rename to include/uapi/camera/media/cam_isp_tfe.h diff --git a/include/uapi/media/cam_isp_vfe.h b/include/uapi/camera/media/cam_isp_vfe.h similarity index 100% rename from include/uapi/media/cam_isp_vfe.h rename to include/uapi/camera/media/cam_isp_vfe.h diff --git a/include/uapi/media/cam_jpeg.h b/include/uapi/camera/media/cam_jpeg.h similarity index 100% rename from include/uapi/media/cam_jpeg.h rename to include/uapi/camera/media/cam_jpeg.h diff --git a/include/uapi/media/cam_lrme.h b/include/uapi/camera/media/cam_lrme.h similarity index 100% rename from include/uapi/media/cam_lrme.h rename to include/uapi/camera/media/cam_lrme.h diff --git a/include/uapi/media/cam_ope.h b/include/uapi/camera/media/cam_ope.h similarity index 100% rename from include/uapi/media/cam_ope.h rename to include/uapi/camera/media/cam_ope.h diff --git a/include/uapi/media/cam_req_mgr.h b/include/uapi/camera/media/cam_req_mgr.h similarity index 100% rename from include/uapi/media/cam_req_mgr.h rename to include/uapi/camera/media/cam_req_mgr.h diff --git a/include/uapi/media/cam_sensor.h b/include/uapi/camera/media/cam_sensor.h similarity index 100% rename from include/uapi/media/cam_sensor.h rename to include/uapi/camera/media/cam_sensor.h diff --git a/include/uapi/media/cam_sync.h b/include/uapi/camera/media/cam_sync.h similarity index 100% rename from include/uapi/media/cam_sync.h rename to include/uapi/camera/media/cam_sync.h diff --git a/include/uapi/media/cam_tfe.h b/include/uapi/camera/media/cam_tfe.h similarity index 99% rename from include/uapi/media/cam_tfe.h rename to include/uapi/camera/media/cam_tfe.h index 7da549346..16bd4e6ee 100644 --- a/include/uapi/media/cam_tfe.h +++ b/include/uapi/camera/media/cam_tfe.h @@ -10,7 +10,6 @@ #include "cam_isp_tfe.h" #include "cam_cpas.h" - /* ISP TFE driver name */ #define CAM_ISP_TFE_DEV_NAME "cam-isp" diff --git a/include/uapi/media/Kbuild b/include/uapi/media/Kbuild deleted file mode 100644 index e7971dac1..000000000 --- a/include/uapi/media/Kbuild +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note - -header-y += cam_cpas.h -header-y += cam_defs.h -header-y += cam_fd.h -header-y += cam_icp.h -header-y += cam_isp.h -header-y += cam_isp_vfe.h -header-y += cam_isp_ife.h -header-y += cam_jpeg.h -header-y += cam_req_mgr.h -header-y += cam_sensor.h -header-y += cam_sync.h -header-y += cam_lrme.h diff --git a/product.mk b/product.mk new file mode 100644 index 000000000..b77946bab --- /dev/null +++ b/product.mk @@ -0,0 +1 @@ +PRODUCT_PACKAGES += camera.ko