asoc: Compile audio driver UAPI as overlay

Install the audio UAPI header files for other modules and
userspace can use them.

Change-Id: Ib178f32bac46e3e95f78db33098d68b6ee834516
Signed-off-by: Meng Wang <mengw@codeaurora.org>
This commit is contained in:
Meng Wang 2021-01-13 09:06:21 +08:00 committed by Gerrit - the friendly Code Review server
parent c979dac299
commit 96e7b3758f
3 changed files with 157 additions and 10 deletions

61
Android.bp Normal file
View File

@ -0,0 +1,61 @@
headers_src = [
"include/uapi/audio/*/**/*.h",
]
audio_headers_out = [
"linux/avtimer.h",
"linux/msm_audio.h",
"linux/msm_audio_aac.h",
"linux/msm_audio_ac3.h",
"linux/msm_audio_alac.h",
"linux/msm_audio_amrnb.h",
"linux/msm_audio_amrwb.h",
"linux/msm_audio_amrwbplus.h",
"linux/msm_audio_ape.h",
"linux/msm_audio_calibration.h",
"linux/msm_audio_g711.h",
"linux/msm_audio_g711_dec.h",
"linux/msm_audio_mvs.h",
"linux/msm_audio_qcp.h",
"linux/msm_audio_sbc.h",
"linux/msm_audio_voicememo.h",
"linux/msm_audio_wma.h",
"linux/msm_audio_wmapro.h",
"linux/wcd-spi-ac-params.h",
"sound/audio_compressed_formats.h",
"sound/audio_effects.h",
"sound/audio_slimslave.h",
"sound/devdep_params.h",
"sound/lsm_params.h",
"sound/msmcal-hwdep.h",
"sound/voice_params.h",
"sound/wcd-dsp-glink.h",
]
audio_kernel_headers_verbose = "--verbose "
genrule {
name: "qti_generate_audio_kernel_headers",
tools: ["headers_install.sh",
"unifdef"
],
tool_files: [
"audio_kernel_headers.py",
],
srcs: headers_src,
cmd: "python3 -u $(location audio_kernel_headers.py) " +
audio_kernel_headers_verbose +
"--header_arch arm64 " +
"--gen_dir $(genDir) " +
"--audio_include_uapi $(locations include/uapi/audio/*/**/*.h) " +
"--unifdef $(location unifdef) " +
"--headers_install $(location headers_install.sh)",
out: audio_headers_out,
}
cc_library_headers {
name: "qti_audio_kernel_uapi",
generated_headers: ["qti_generate_audio_kernel_headers"],
export_generated_headers: ["qti_generate_audio_kernel_headers"],
vendor: true,
recovery_available: true
}

View File

@ -4,13 +4,6 @@ UAPI_OUT := $(PRODUCT_OUT)/obj/vendor/qcom/opensource/audio-kernel/include
LOCAL_PATH := $(call my-dir)
ifeq ($(call is-board-platform-in-list,taro), true)
$(shell mkdir -p $(PRODUCT_OUT)/obj/vendor;)
$(shell mkdir -p $(PRODUCT_OUT)/obj/vendor/qcom;)
$(shell mkdir -p $(PRODUCT_OUT)/obj/vendor/qcom/opensource;)
$(shell mkdir -p $(PRODUCT_OUT)/obj/vendor/qcom/opensource/audio-kernel;)
$(shell mkdir -p $(PRODUCT_OUT)/obj/vendor/qcom/opensource/audio-kernel/include;)
$(shell mkdir -p $(UAPI_OUT)/linux;)
$(shell mkdir -p $(UAPI_OUT)/sound;)
$(shell rm -rf $(PRODUCT_OUT)/obj/DLKM_OBJ/vendor/qcom/opensource/audio-kernel/Module.symvers)
endif
@ -322,8 +315,5 @@ LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
include $(DLKM_DIR)/Build_external_kernelmodule.mk
###########################################################
$(shell cp $(LOCAL_PATH)/include/uapi/audio/linux/* $(UAPI_OUT)/linux)
$(shell cp $(LOCAL_PATH)/include/uapi/audio/sound/* $(UAPI_OUT)/sound)
endif # DLKM check
endif # supported target check

96
audio_kernel_headers.py Normal file
View File

@ -0,0 +1,96 @@
# Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
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_audio_headers(verbose, gen_dir, headers_install, unifdef, audio_include_uapi):
error_count = 0
for h in audio_include_uapi:
audio_uapi_include_prefix = os.path.join(h.split('/include/uapi/')[0],
'include',
'uapi',
'audio') + os.sep
if not run_headers_install(
verbose, gen_dir, headers_install, unifdef,
audio_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(
'--audio_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('audio_include_uapi [%s]' % args.audio_include_uapi)
print('headers_install [%s]' % args.headers_install)
print('unifdef [%s]' % args.unifdef)
return gen_audio_headers(args.verbose, args.gen_dir,
args.headers_install, args.unifdef, args.audio_include_uapi)
if __name__ == '__main__':
sys.exit(main())