blob: e3fd424be7c7ca91b2ddd44c4bd6d5a098441597 [file] [log] [blame]
# Copyright 2020 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/components.gni")
import("//build/drivers.gni")
# Defines a controller driver
#
# This template creates a fuchsia_driver and driver_package customized for a
# specific target. Each instantiation must provide a dependency on a
# source_set that provides an implementation of camera::ProductConfig::Create.
# See //src/camera/drivers/controller/configs/product_config.h for more
# details.
#
# Example:
# ```
# camera_controller_driver(my_product_controller) {
# deps = [
# "//src/camera/drivers/controller/configs/my_product",
# ]
# }
# ```
#
# Parameters
# deps (required)
# List of additional dependencies to link. This must provide an implementation
# of camera::ProductConfig::Create.
# Type: list(path)
#
# board (optional)
# The name of the board.
# Type: string
# Default: $target_name
#
# package_name (optional)
# The name of the driver package.
# Type: string
# Default: $board-camera-controller
#
# gdc_config_files (optional)
# List of paths, relative to //prebuilt/camera/arm/gdc/configs, to include
# in the driver package.
# Type: list(path)
#
# watermark_files (optional)
# List of paths, relative to //prebuilt/camera/watermark, to include in the
# driver package.
# Type: list(path)
#
template("camera_controller_driver") {
board = target_name
package_name = "${board}-camera-controller"
if (defined(invoker.package_name)) {
package_name = invoker.package_name
}
driver_target = "${package_name}_driver"
fuchsia_driver(driver_target) {
output_name = package_name
deps = [ "//src/camera/drivers/controller:source" ]
if (defined(invoker.deps)) {
deps += invoker.deps
}
configs += [ "//build/config/fuchsia:enable_zircon_asserts" ]
}
driver_component_target = "${package_name}_driver_component"
fuchsia_driver_component(driver_component_target) {
deps = [ ":${driver_target}" ]
info = "${driver_target}-info.json"
manifest = "meta/camera-controller-${board}.cml"
}
if (defined(invoker.gdc_config_files)) {
resource("firmware-configs-$package_name") {
sources = []
foreach(config_file, invoker.gdc_config_files) {
assert(
get_path_info(config_file, "dir") == ".",
"gdc_config_files entry cannot have sub-directory: " + config_file)
sources += [ "//prebuilt/camera/arm/gdc/configs/" + config_file ]
}
outputs = [ "lib/firmware/{{source_file_part}}" ]
}
}
if (defined(invoker.watermark_files)) {
resource("firmware-watermarks-$package_name") {
sources = []
foreach(watermark_file, invoker.watermark_files) {
assert(get_path_info(watermark_file, "dir") == ".",
"waternark_files entry cannot have sub-directory: " +
watermark_file)
sources += [ "//prebuilt/camera/watermark/" + watermark_file ]
}
outputs = [ "lib/firmware/{{source_file_part}}" ]
}
}
fuchsia_driver_package(package_name) {
driver_components = [ ":${driver_component_target}" ]
deps = []
if (defined(invoker.gdc_config_files)) {
deps += [ ":firmware-configs-$package_name" ]
}
if (defined(invoker.watermark_files)) {
deps += [ ":firmware-watermarks-$package_name" ]
}
}
}