Skip to content

Commit

Permalink
msm: camera: export UAPI header files
Browse files Browse the repository at this point in the history
Export UAPI header files for userspace to use them.
Correct header file inclusion within a file.

Change-Id: Ifc6736a32a8597537e2f50aa61febae89af626a9
Signed-off-by: Nirmal Abraham <[email protected]>
  • Loading branch information
Nirmal Abraham committed Sep 7, 2022
1 parent 7d19958 commit 15a3a59
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 12 deletions.
50 changes: 50 additions & 0 deletions Android.bp
Original file line number Diff line number Diff line change
@@ -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
}
85 changes: 85 additions & 0 deletions camera_kernel_headers.py
Original file line number Diff line number Diff line change
@@ -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())
3 changes: 2 additions & 1 deletion include/uapi/camera/media/cam_cpas.h
Original file line number Diff line number Diff line change
@@ -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 <media/cam_defs.h>
#include "cam_defs.h"

#define CAM_FAMILY_CAMERA_SS 1
#define CAM_FAMILY_CPAS_SS 2
Expand Down
3 changes: 2 additions & 1 deletion include/uapi/camera/media/cam_fd.h
Original file line number Diff line number Diff line change
@@ -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 <media/cam_defs.h>
#include "cam_defs.h"

#define CAM_FD_MAX_FACES 35
#define CAM_FD_RAW_RESULT_ENTRIES 512
Expand Down
5 changes: 3 additions & 2 deletions include/uapi/camera/media/cam_icp.h
Original file line number Diff line number Diff line change
@@ -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 <media/cam_defs.h>
#include <media/cam_cpas.h>
#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
Expand Down
9 changes: 5 additions & 4 deletions include/uapi/camera/media/cam_isp.h
Original file line number Diff line number Diff line change
@@ -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 <media/cam_defs.h>
#include <media/cam_isp_vfe.h>
#include <media/cam_isp_ife.h>
#include <media/cam_cpas.h>
#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"
Expand Down
3 changes: 2 additions & 1 deletion include/uapi/camera/media/cam_jpeg.h
Original file line number Diff line number Diff line change
@@ -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 <media/cam_defs.h>
#include "cam_defs.h"

/* enc, dma, cdm(enc/dma) are used in querycap */
#define CAM_JPEG_DEV_TYPE_ENC 0
Expand Down
3 changes: 2 additions & 1 deletion include/uapi/camera/media/cam_lrme.h
Original file line number Diff line number Diff line change
@@ -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 <media/cam_defs.h>
#include "cam_defs.h"

/* LRME Resource Types */

Expand Down
3 changes: 2 additions & 1 deletion include/uapi/camera/media/cam_req_mgr.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -10,7 +11,7 @@
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/media.h>
#include <media/cam_defs.h>
#include "cam_defs.h"

#define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode"

Expand Down
3 changes: 2 additions & 1 deletion include/uapi/camera/media/cam_sensor.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/* 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__
#define __UAPI_CAM_SENSOR_H__

#include <linux/types.h>
#include <linux/ioctl.h>
#include <media/cam_defs.h>
#include "cam_defs.h"

#define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1)
#define CAM_FLASH_MAX_LED_TRIGGERS 3
Expand Down

0 comments on commit 15a3a59

Please sign in to comment.