diff --git a/Android.bp b/Android.bp new file mode 100644 index 000000000..f64a52ccc --- /dev/null +++ b/Android.bp @@ -0,0 +1,50 @@ +headers_src = [ + "include/uapi/*/**/*.h", +] + +camera_headers_out = [ + "media/cam_cpas.h", + "media/cam_custom.h", + "media/cam_defs.h", + "media/cam_fd.h", + "media/cam_icp.h", + "media/cam_isp.h", + "media/cam_isp_ife.h", + "media/cam_isp_tfe.h", + "media/cam_isp_vfe.h", + "media/cam_jpeg.h", + "media/cam_lrme.h", + "media/cam_ope.h", + "media/cam_req_mgr.h", + "media/cam_sensor.h", + "media/cam_sync.h", + "media/cam_tfe.h", +] + +camera_kernel_headers_verbose = "--verbose " +genrule { + name: "qti_generate_camera_kernel_headers", + tools: ["headers_install.sh", + "unifdef" + ], + tool_files: [ + "camera_kernel_headers.py", + ], + srcs: headers_src, + cmd: "python3 -u $(location camera_kernel_headers.py) " + + camera_kernel_headers_verbose + + "--header_arch arm64 " + + "--gen_dir $(genDir) " + + "--camera_include_uapi $(locations include/uapi/*/**/*.h) " + + "--unifdef $(location unifdef) " + + "--headers_install $(location headers_install.sh)", + out: camera_headers_out, +} + +cc_library_headers { + name: "qti_camera_kernel_uapi", + generated_headers: ["qti_generate_camera_kernel_headers"], + export_generated_headers: ["qti_generate_camera_kernel_headers"], + vendor: true, + recovery_available: true +} diff --git a/camera_kernel_headers.py b/camera_kernel_headers.py new file mode 100644 index 000000000..b444aefbc --- /dev/null +++ b/camera_kernel_headers.py @@ -0,0 +1,85 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + +import argparse +import filecmp +import os +import re +import subprocess +import sys + +def run_headers_install(verbose, gen_dir, headers_install, unifdef, prefix, h): + if not h.startswith(prefix): + print('error: expected prefix [%s] on header [%s]' % (prefix, h)) + return False + + out_h = os.path.join(gen_dir, h[len(prefix):]) + (out_h_dirname, out_h_basename) = os.path.split(out_h) + env = os.environ.copy() + env["LOC_UNIFDEF"] = unifdef + cmd = ["sh", headers_install, h, out_h] + + if verbose: + print('run_headers_install: cmd is %s' % cmd) + + result = subprocess.call(cmd, env=env) + + if result != 0: + print('error: run_headers_install: cmd %s failed %d' % (cmd, result)) + return False + return True + +def gen_camera_headers(verbose, gen_dir, headers_install, unifdef, camera_include_uapi): + error_count = 0 + for h in camera_include_uapi: + camera_uapi_include_prefix = os.path.join(h.split('/include/uapi/camera')[0], + 'include', + 'uapi', + 'camera') + os.sep + + if not run_headers_install( + verbose, gen_dir, headers_install, unifdef, + camera_uapi_include_prefix, h): error_count += 1 + return error_count + +def main(): + """Parse command line arguments and perform top level control.""" + parser = argparse.ArgumentParser( + description=__doc__, + formatter_class=argparse.RawDescriptionHelpFormatter) + + # Arguments that apply to every invocation of this script. + parser.add_argument( + '--verbose', action='store_true', + help='Print output that describes the workings of this script.') + parser.add_argument( + '--header_arch', required=True, + help='The arch for which to generate headers.') + parser.add_argument( + '--gen_dir', required=True, + help='Where to place the generated files.') + parser.add_argument( + '--camera_include_uapi', required=True, nargs='*', + help='The list of techpack/*/include/uapi header files.') + parser.add_argument( + '--headers_install', required=True, + help='The headers_install tool to process input headers.') + parser.add_argument( + '--unifdef', + required=True, + help='The unifdef tool used by headers_install.') + + args = parser.parse_args() + + if args.verbose: + print('header_arch [%s]' % args.header_arch) + print('gen_dir [%s]' % args.gen_dir) + print('camera_include_uapi [%s]' % args.camera_include_uapi) + print('headers_install [%s]' % args.headers_install) + print('unifdef [%s]' % args.unifdef) + + return gen_camera_headers(args.verbose, args.gen_dir, + args.headers_install, args.unifdef, args.camera_include_uapi) + +if __name__ == '__main__': + sys.exit(main()) diff --git a/include/uapi/camera/media/cam_cpas.h b/include/uapi/camera/media/cam_cpas.h index 2a44d9349..2fdfd6516 100644 --- a/include/uapi/camera/media/cam_cpas.h +++ b/include/uapi/camera/media/cam_cpas.h @@ -1,12 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_CPAS_H__ #define __UAPI_CAM_CPAS_H__ -#include +#include "cam_defs.h" #define CAM_FAMILY_CAMERA_SS 1 #define CAM_FAMILY_CPAS_SS 2 diff --git a/include/uapi/camera/media/cam_fd.h b/include/uapi/camera/media/cam_fd.h index 126be4555..85d0c384f 100644 --- a/include/uapi/camera/media/cam_fd.h +++ b/include/uapi/camera/media/cam_fd.h @@ -1,12 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_FD_H__ #define __UAPI_CAM_FD_H__ -#include +#include "cam_defs.h" #define CAM_FD_MAX_FACES 35 #define CAM_FD_RAW_RESULT_ENTRIES 512 diff --git a/include/uapi/camera/media/cam_icp.h b/include/uapi/camera/media/cam_icp.h index 4b5419d2f..57b3a3b22 100644 --- a/include/uapi/camera/media/cam_icp.h +++ b/include/uapi/camera/media/cam_icp.h @@ -1,13 +1,14 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_ICP_H__ #define __UAPI_CAM_ICP_H__ -#include -#include +#include "cam_defs.h" +#include "cam_cpas.h" /* icp, ipe, bps, cdm(ipe/bps) are used in querycap */ #define CAM_ICP_DEV_TYPE_A5 1 diff --git a/include/uapi/camera/media/cam_isp.h b/include/uapi/camera/media/cam_isp.h index e4778cfc9..76b41b51f 100644 --- a/include/uapi/camera/media/cam_isp.h +++ b/include/uapi/camera/media/cam_isp.h @@ -1,15 +1,16 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_ISP_H__ #define __UAPI_CAM_ISP_H__ -#include -#include -#include -#include +#include "cam_defs.h" +#include "cam_isp_vfe.h" +#include "cam_isp_ife.h" +#include "cam_cpas.h" /* ISP driver name */ #define CAM_ISP_DEV_NAME "cam-isp" diff --git a/include/uapi/camera/media/cam_jpeg.h b/include/uapi/camera/media/cam_jpeg.h index fd0ed2a2c..48111cff5 100644 --- a/include/uapi/camera/media/cam_jpeg.h +++ b/include/uapi/camera/media/cam_jpeg.h @@ -1,12 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_JPEG_H__ #define __UAPI_CAM_JPEG_H__ -#include +#include "cam_defs.h" /* enc, dma, cdm(enc/dma) are used in querycap */ #define CAM_JPEG_DEV_TYPE_ENC 0 diff --git a/include/uapi/camera/media/cam_lrme.h b/include/uapi/camera/media/cam_lrme.h index e3bd9449f..37e8d3cc7 100644 --- a/include/uapi/camera/media/cam_lrme.h +++ b/include/uapi/camera/media/cam_lrme.h @@ -1,12 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_LRME_H__ #define __UAPI_CAM_LRME_H__ -#include +#include "cam_defs.h" /* LRME Resource Types */ diff --git a/include/uapi/camera/media/cam_req_mgr.h b/include/uapi/camera/media/cam_req_mgr.h index ebec0b04b..d408885bb 100644 --- a/include/uapi/camera/media/cam_req_mgr.h +++ b/include/uapi/camera/media/cam_req_mgr.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_LINUX_CAM_REQ_MGR_H @@ -10,7 +11,7 @@ #include #include #include -#include +#include "cam_defs.h" #define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode" diff --git a/include/uapi/camera/media/cam_sensor.h b/include/uapi/camera/media/cam_sensor.h index 9d16af961..4425aebe8 100644 --- a/include/uapi/camera/media/cam_sensor.h +++ b/include/uapi/camera/media/cam_sensor.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ /* * Copyright (c) 2016-2019, 2021 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef __UAPI_CAM_SENSOR_H__ @@ -8,7 +9,7 @@ #include #include -#include +#include "cam_defs.h" #define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1) #define CAM_FLASH_MAX_LED_TRIGGERS 3