bt-kernel: Additional bazel configuration

- add support to copy *.ko to out dir
- enable conditional compilation with config flags
- enable CONFIG_BT_HW_SECURE_DISABLE with dependency on securemsm-kernel
- re-enable compilation of bt_fm_slim with new headers
- add fallthrough attribute btfm_slim_hw_interface.c
- move BTFMSLIM_DEV_NAME to btfm_slim.h
- add target.bzl file to define specific targets

Change-Id: I7f7920870d81125f95b020ef33df77df3f937682
Signed-off-by: Franklin Abreu Bueno <quic_fabreu@quicinc.com>
This commit is contained in:
Franklin Abreu Bueno
2023-02-06 16:04:44 -08:00
committed by Gerrit - the friendly Code Review server
parent 15d9682357
commit 176b51aefa
8 changed files with 140 additions and 34 deletions

View File

@@ -1,5 +1,13 @@
load(":bt_kernel.bzl", "define_bt_modules")
load("//build/kernel/kleaf:kernel.bzl", "ddk_headers")
targets = ["pineapple"]
ddk_headers(
name = "btfmcodec_headers",
hdrs = glob([
"btfmcodec/include/*.h"
]),
includes = ["btfmcodec/include"]
)
define_bt_modules(targets)
load(":target.bzl", "define_pineapple")
define_pineapple()

View File

@@ -1,24 +1,34 @@
load("//msm-kernel:target_variants.bzl", "get_all_variants")
load("//build/kernel/kleaf:kernel.bzl", "ddk_module")
load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
load(":bt_modules.bzl", "bt_modules")
def _get_module_srcs(module):
def _get_config_choices(config_srcs, options):
choices = []
for option in config_srcs:
choices.extend(config_srcs[option].get(option in options, []))
return choices
def _get_module_srcs(module, options):
"""
Gets all the module sources, formats them with the path for that module
and then groups them together
It also includes all the headers within the `include` directory
`native.glob()` returns a new list with every file need for the current package
"""
srcs = module.srcs + _get_config_choices(module.config_srcs, options)
return native.glob(
["{}/{}".format(module.path, src) for src in module.srcs] + ["include/*.h"]
["{}/{}".format(module.path, src) for src in srcs] + ["include/*.h"]
)
def _get_module_deps(module, formatter):
def _get_module_deps(module, options, formatter):
"""
Formats the dependent targets with the necessary prefix
Args:
module: kernel module
options: dependencies that rely on a config option
formatter: function that will replace the format string within `deps`
Example:
kernel build = "pineapple_gki"
@@ -26,36 +36,60 @@ def _get_module_deps(module, formatter):
The formatted string will look as follow
formatted_dep = formatter(dep) = "pineapple_gki_btpower"
"""
return [formatter(dep) for dep in module.deps]
deps = module.deps + _get_config_choices(module.config_deps, options)
return [formatter(dep) for dep in deps]
def define_target_variant_modules(target, variant, modules):
def _get_build_options(modules, config_options):
all_options = {option: True for option in config_options}
all_options = all_options | {module.config_opt: True for module in modules if module.config_opt}
return all_options
def define_target_variant_modules(target, variant, modules, config_options = []):
"""
Generates the ddk_module for each of our kernel modules
Args:
target: either `pineapple` or `kalama`
variant: either `gki` or `consolidate`
modules: bt_modules dict defined in `bt_modules.bzl`
modules: bt_modules dictionary defined in `bt_modules.bzl`
config_options: decides which kernel modules to build
"""
kernel_build = "{}_{}".format(target, variant)
modules = [modules.get(module_name) for module_name in modules]
kernel_build_label = "//msm-kernel:{}".format(kernel_build)
modules = [bt_modules.get(module_name) for module_name in modules]
options = _get_build_options(modules, config_options)
formatter = lambda s : s.replace("%b", kernel_build)
all_modules = []
for module in modules:
rule_name = "{}_{}".format(kernel_build, module.name)
module_srcs = _get_module_srcs(module)
module_srcs = _get_module_srcs(module, options)
ddk_module(
name = rule_name,
kernel_build = "//msm-kernel:{}".format(kernel_build),
kernel_build = kernel_build_label,
srcs = module_srcs,
out = "{}.ko".format(module.name),
deps = ["//msm-kernel:all_headers"] + _get_module_deps(module, formatter),
deps = ["//msm-kernel:all_headers"] + _get_module_deps(module, options, formatter),
includes = ["include"],
local_defines = options.keys(),
visibility = ["//visibility:public"],
)
def define_bt_modules(targets):
for target in targets:
for (t, v) in get_all_variants():
if t == target:
define_target_variant_modules(t, v, bt_modules)
all_modules.append(rule_name)
copy_to_dist_dir(
name = "{}_bt-kernel_dist".format(kernel_build),
data = all_modules,
dist_dir = "out/target/product/{}/dlkm/lib/modules".format(target),
flat = True,
wipe_dist_dir = False,
allow_duplicate_filenames = False,
mode_overrides = {"**/*": "644"},
log = "info",
)
def define_bt_modules(target, modules, config_options = []):
for (t, v) in get_all_variants():
if t == target:
define_target_variant_modules(t, v, modules, config_options)

View File

@@ -5,7 +5,7 @@ FMRTC_PATH = "rtc6226"
# This dictionary holds all the BT modules included in the bt-kernel
bt_modules = {}
def register_bt_modules(name, path = None, config_opt = None, srcs = {}, deps = []):
def register_bt_modules(name, path = None, config_opt = None, srcs = [], config_srcs = {}, deps = [], config_deps = {}):
"""
Register modules
Args:
@@ -13,14 +13,37 @@ def register_bt_modules(name, path = None, config_opt = None, srcs = {}, deps =
path: Path in which the source files can be found
config_opt: Config name used in Kconfig (not needed currently)
srcs: source files and local headers
config_srcs: source files and local headers that depend on a config define being enabled.
deps: a list of dependent targets
config_deps: a list of dependent targets that depend on a config define being enabled.
"""
processed_config_srcs = {}
processed_config_deps = {}
for config_src_name in config_srcs:
config_src = config_srcs[config_src_name]
if type(config_src) == "list":
processed_config_srcs[config_src_name] = {True: config_src}
else:
processed_config_srcs[config_src_name] = config_src
for config_deps_name in config_deps:
config_dep = config_deps[config_deps_name]
if type(config_dep) == "list":
processed_config_deps[config_deps_name] = {True: config_dep}
else:
processed_config_deps[config_deps_name] = config_dep
module = struct(
name = name,
path = path,
srcs = srcs,
config_srcs = processed_config_srcs,
config_opt = config_opt,
deps = deps
deps = deps,
config_deps = processed_config_deps,
)
bt_modules[name] = module
@@ -29,22 +52,43 @@ def register_bt_modules(name, path = None, config_opt = None, srcs = {}, deps =
register_bt_modules(
name = "btpower",
path = PWR_PATH,
config_opt = "CONFIG_MSM_BT_PWR",
srcs = ["btpower.c"]
config_opt = "CONFIG_MSM_BT_POWER",
srcs = ["btpower.c"],
config_deps = {
"CONFIG_BT_HW_SECURE_DISABLE": [
"//vendor/qcom/opensource/securemsm-kernel:%b_smcinvoke_dlkm",
]
},
)
register_bt_modules(
name = "bt_fm_slim",
path = SLIMBUS_PATH,
config_opt = "CONFIG_BTFM_SLIM",
# config_opt = "CONFIG_BTFM_SLIM",
srcs = [
"btfm_slim.c",
"btfm_slim.h",
"btfm_slim_codec.c",
"btfm_slim_slave.c",
"btfm_slim_slave.h",
"btfm_slim_codec.c",
],
deps = [":%b_btpower"]
deps = [":%b_btpower"],
)
# Not enabled/compiling until btfmcodec is enabled
register_bt_modules(
name = "btfm_slim_codec",
path = SLIMBUS_PATH,
# config_opt = "CONFIG_SLIM_BTFM_CODEC",
srcs = [
"btfm_slim.c",
"btfm_slim.h",
"btfm_slim_slave.c",
"btfm_slim_slave.h",
"btfm_slim_hw_interface.c",
"btfm_slim_hw_interface.h",
],
deps = [":%b_btpower", ":btfmcodec_headers"],
)
register_bt_modules(
@@ -55,5 +99,5 @@ register_bt_modules(
"radio-rtc6226-common.c",
"radio-rtc6226-i2c.c",
"radio-rtc6226.h",
]
],
)

View File

@@ -22,7 +22,9 @@
#include "btpower.h"
#include "btfm_slim.h"
#include "btfm_slim_slave.h"
#if IS_ENABLED(CONFIG_SLIM_BTFM_CODEC)
#include "btfm_slim_hw_interface.h"
#endif
#define DELAY_FOR_PORT_OPEN_MS (200)
#define SLIM_MANF_ID_QCOM 0x217

View File

@@ -29,7 +29,11 @@
#define PGD 1
#define IFD 0
#if IS_ENABLED(CONFIG_BTFM_SLIM)
#define BTFMSLIM_DEV_NAME "btfmslim_slave"
#else
#define BTFMSLIM_DEV_NAME "btfmslim"
#endif
/* Codec driver defines */
enum {

View File

@@ -329,6 +329,7 @@ static int btfm_slim_dai_get_channel_map(void *dai,
switch (id) {
case BTFM_FM_SLIM_TX:
num = 2;
fallthrough;
case BTFM_BT_SCO_SLIM_TX:
if (!tx_slot || !tx_num) {
BTFMSLIM_ERR("Invalid tx_slot %p or tx_num %p",

View File

@@ -6,12 +6,6 @@
#ifndef __LINUX_BTFM_SLIM_HW_INTERFACE_H
#define __LINUX_BTFM_SLIM_HW_INTERFACE_H
#if IS_ENABLED(CONFIG_BTFM_SLIM)
#define BTFMSLIM_DEV_NAME "btfmslim_slave"
#else
#define BTFMSLIM_DEV_NAME "btfmslim"
#endif
// Todo protect with flags
int btfm_slim_register_hw_ep(struct btfmslim *btfm_slim);
void btfm_slim_unregister_hwep(void);

19
target.bzl Normal file
View File

@@ -0,0 +1,19 @@
load(":bt_kernel.bzl", "define_bt_modules")
def define_pineapple():
define_bt_modules(
target = "pineapple",
modules = [
"btpower",
"bt_fm_slim",
"radio-i2c-rtc6226-qca",
# "btfm_slim_codec",
],
config_options = [
"CONFIG_MSM_BT_POWER",
"CONFIG_BTFM_SLIM",
"CONFIG_I2C_RTC6226_QCA",
# "CONFIG_SLIM_BTFM_CODEC",
"CONFIG_BT_HW_SECURE_DISABLE",
]
)