From 657b260037a12ed85881f6f84cf47516ae0df17d Mon Sep 17 00:00:00 2001 From: Gilberto Gambugge Date: Fri, 2 Jun 2023 23:30:09 -0300 Subject: [PATCH] techpack: add camera legacy support Add camera legacy support by checking BOARD_CONFIG_CAMERA_KERNEL_NAME to decide which folder will be used to compile the camera techpack. Also, due to camera legacy, the camera uapi kernel headers installation routines need to be updated to consider the camera legacy support. This commit also fixes the routines to install kernel headers for 'make headers_install' and also 'qti_generate_kernel_headers_arm' and 'qti_generate_kernel_headers_arm64'. Change-Id: I845c5cb49c388bc15eba2fbf0ed0724e93de5192 Reviewed-on: https://gerrit.mot.com/2632695 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Reviewed-by: Rafael Ortolan Reviewed-by: Rav(CR) Vembu Reviewed-by: Miguel Nicodemus Tested-by: Jira Key Submit-Approved: Jira Key --- Android.bp | 103 +++++++++++++++++++++++++++++++++++ gen_headers_arm.bp | 18 +----- gen_headers_arm64.bp | 16 +----- kernel_headers.py | 14 ++++- scripts/Makefile.headersinst | 16 ++++++ techpack/Kbuild | 23 +++++++- 6 files changed, 154 insertions(+), 36 deletions(-) diff --git a/Android.bp b/Android.bp index 3d5382bfbd47..ea277ab7c4a6 100644 --- a/Android.bp +++ b/Android.bp @@ -28,6 +28,109 @@ kernel_headers_verbose = "" build = ["gen_headers_arm.bp", "gen_headers_arm64.bp"] +soong_config_module_type { + name: "mmi_camera_legacy_genrule_defaults", + module_type: "genrule_defaults", + config_namespace: "mmi_camera_legacy", + variables: ["board_config_camera_legacy_kernel"], + properties: ["cmd"], +} + +soong_config_string_variable { + name: "board_config_camera_legacy_kernel", + values: ["enabled", "disabled"], +} + +mmi_camera_legacy_genrule_defaults { + name: "mmi_kernel_headers_cmdrules_arm", + soong_config_variables: { + board_config_camera_legacy_kernel: { + disabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm) " + + "--version_makefile $(location Makefile) " + + "--arch_syscall_tool $(location arch/arm/tools/syscallhdr.sh) " + + "--arch_syscall_tbl $(location arch/arm/tools/syscall.tbl) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h)", + }, + enabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm) " + + "--version_makefile $(location Makefile) " + + "--arch_syscall_tool $(location arch/arm/tools/syscallhdr.sh) " + + "--arch_syscall_tbl $(location arch/arm/tools/syscall.tbl) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h) " + + "--camera_legacy ", + }, + }, + }, +} + +mmi_camera_legacy_genrule_defaults { + name: "mmi_kernel_headers_cmdrules_arm64", + soong_config_variables: { + board_config_camera_legacy_kernel: { + disabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm64 " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm64/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm64/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm64.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm64) " + + "--version_makefile $(location Makefile) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h)", + }, + enabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm64 " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm64/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm64/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm64.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm64) " + + "--version_makefile $(location Makefile) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h) " + + "--camera_legacy ", + }, + }, + }, +} + cc_library_headers { name: "qti_kernel_headers", arch: { diff --git a/gen_headers_arm.bp b/gen_headers_arm.bp index 2894fb4a72f1..700d838800f8 100644 --- a/gen_headers_arm.bp +++ b/gen_headers_arm.bp @@ -1035,22 +1035,6 @@ genrule { ":qti_generate_gen_headers_arm", ], exclude_srcs: gen_headers_exclude_srcs_arm, - cmd: "python3 $(location kernel_headers.py) " + - kernel_headers_verbose + - "--header_arch arm " + - "--gen_dir $(genDir) " + - "--arch_asm_kbuild $(location arch/arm/include/uapi/asm/Kbuild) " + - "--arch_include_uapi $(locations arch/arm/include/uapi/**/*.h) " + - "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + - "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " + - "headers " + - "--old_gen_headers_bp $(location gen_headers_arm.bp) " + - "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm) " + - "--version_makefile $(location Makefile) " + - "--arch_syscall_tool $(location arch/arm/tools/syscallhdr.sh) " + - "--arch_syscall_tbl $(location arch/arm/tools/syscall.tbl) " + - "--headers_install $(location headers_install.sh) " + - "--unifdef $(location unifdef) " + - "--include_uapi $(locations include/uapi/**/*.h)", out: ["linux/version.h"] + gen_headers_out_arm, + defaults: ["mmi_kernel_headers_cmdrules_arm"], } diff --git a/gen_headers_arm64.bp b/gen_headers_arm64.bp index f90c1b771b13..72c154e0eeee 100644 --- a/gen_headers_arm64.bp +++ b/gen_headers_arm64.bp @@ -1028,20 +1028,6 @@ genrule { ":qti_generate_gen_headers_arm64", ], exclude_srcs: gen_headers_exclude_srcs_arm64, - cmd: "python3 $(location kernel_headers.py) " + - kernel_headers_verbose + - "--header_arch arm64 " + - "--gen_dir $(genDir) " + - "--arch_asm_kbuild $(location arch/arm64/include/uapi/asm/Kbuild) " + - "--arch_include_uapi $(locations arch/arm64/include/uapi/**/*.h) " + - "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + - "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " + - "headers " + - "--old_gen_headers_bp $(location gen_headers_arm64.bp) " + - "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm64) " + - "--version_makefile $(location Makefile) " + - "--headers_install $(location headers_install.sh) " + - "--unifdef $(location unifdef) " + - "--include_uapi $(locations include/uapi/**/*.h)", out: ["linux/version.h"] + gen_headers_out_arm64, + defaults: ["mmi_kernel_headers_cmdrules_arm64"], } diff --git a/kernel_headers.py b/kernel_headers.py index c21e31e3c321..bb2d1da166cd 100644 --- a/kernel_headers.py +++ b/kernel_headers.py @@ -755,7 +755,7 @@ def gen_headers( verbose, header_arch, gen_dir, arch_asm_kbuild, asm_generic_kbuild, module_dir, old_gen_headers_bp, new_gen_headers_bp, version_makefile, arch_syscall_tool, arch_syscall_tbl, headers_install, unifdef, include_uapi, - arch_include_uapi, techpack_include_uapi): + arch_include_uapi, techpack_include_uapi, camera_legacy): """Generate the kernel headers. This script generates the version.h file, the arch-specific headers including @@ -814,6 +814,11 @@ def gen_headers( arch_uapi_include_prefix, h): error_count += 1 + + if camera_legacy == True: + legacy_product = os.getenv('TARGET_PRODUCT').split("_", 1)[0] + techpack_include_uapi = [i.replace('techpack/camera','techpack/camera-legacy/' + legacy_product) for i in techpack_include_uapi] + for h in techpack_include_uapi: techpack_uapi_include_prefix = os.path.join(h.split('/include/uapi')[0], 'include', 'uapi') + os.sep if not run_headers_install( @@ -953,6 +958,11 @@ def main(): required=True, nargs='*', help='The list of include/uapi header files.') + parser_headers.add_argument( + '--camera_legacy', + default=False, + action='store_true', + help='If set, define the camera legacy folder being used. By default, it\'s disabled.') args = parser.parse_args() @@ -1003,7 +1013,7 @@ def main(): args.asm_generic_kbuild, module_dir, args.old_gen_headers_bp, args.new_gen_headers_bp, args.version_makefile, args.arch_syscall_tool, args.arch_syscall_tbl, args.headers_install, args.unifdef, args.include_uapi, args.arch_include_uapi, - args.techpack_include_uapi) + args.techpack_include_uapi, args.camera_legacy) print('error: unknown mode: %s' % args.mode) return 1 diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index d5e131471131..6ce0f66ce1ce 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -35,13 +35,29 @@ $(subdirs): # We have only sub-directories there. skip-inst := $(if $(filter %/uapi,$(obj)),1) +ifeq ($(skip-inst),) +ifeq ($(BOARD_CONFIG_CAMERA_KERNEL_NAME),) +skip-inst := $(if $(filter legacy,$(obj)),1) +else +ifneq (, $(findstring camera, $(obj))) +ifeq (, $(findstring $(BOARD_CONFIG_CAMERA_KERNEL_NAME), $(obj))) +skip-inst := 1 +endif +endif +endif +endif + ifeq ($(skip-inst),) # Kbuild file is optional kbuild-file := $(srctree)/$(obj)/Kbuild -include $(kbuild-file) +ifeq (, $(findstring $(BOARD_CONFIG_CAMERA_KERNEL_NAME), $(obj))) installdir := $(INSTALL_HDR_PATH)/$(dst) +else +installdir := $(INSTALL_HDR_PATH)/$(subst camera-legacy/$(BOARD_CONFIG_CAMERA_KERNEL_NAME),camera,$(dst)) +endif gendir := $(objtree)/$(subst include/,include/generated/,$(obj)) header-files := $(notdir $(wildcard $(srcdir)/*.h)) header-files += $(notdir $(wildcard $(srcdir)/*.agh)) diff --git a/techpack/Kbuild b/techpack/Kbuild index d5f247d78d85..74df4b3ebf3d 100644 --- a/techpack/Kbuild +++ b/techpack/Kbuild @@ -1,8 +1,27 @@ # SPDX-License-Identifier: GPL-2.0-only TECHPACK?=y -techpack-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*") +ifeq ($(BOARD_CONFIG_CAMERA_KERNEL_NAME),) +$(info "using default camera path") +techpack-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*"\ + | grep -v legacy) +else +$(info "using camera-legacy/$(BOARD_CONFIG_CAMERA_KERNEL_NAME)") +techpack-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*"\ + | grep -v camera) +techpack-dirs += $(shell find $(srctree)/techpack -maxdepth 2 -mindepth 2 -name "$(BOARD_CONFIG_CAMERA_KERNEL_NAME)") +endif obj-${TECHPACK} += stub/ $(addsuffix /,$(subst $(srctree)/techpack/,,$(techpack-dirs))) -techpack-header-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*") +ifeq ($(BOARD_CONFIG_CAMERA_KERNEL_NAME),) +$(info "using default camera path") +techpack-header-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*"\ + | grep -v legacy) +else +$(info "using camera-legacy/$(BOARD_CONFIG_CAMERA_KERNEL_NAME)") +techpack-header-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*"\ + | grep -v camera) +techpack-header-dirs += $(shell find $(srctree)/techpack -maxdepth 2 -mindepth 2 -name "$(BOARD_CONFIG_CAMERA_KERNEL_NAME)") +endif + header-${TECHPACK} += $(addsuffix /include/uapi/,$(subst $(srctree)/techpack/,,$(techpack-header-dirs)))