summaryrefslogtreecommitdiff
path: root/utils/gen-ipa-priv-key.sh
AgeCommit message (Expand)Author
2024-05-08libcamera: Drop file name from header comment blocksLaurent Pinchart
2020-09-24libcamera: ipa: Move key generation to utilsKieran Bingham
='#n18'>18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
# SPDX-License-Identifier: CC0-1.0

libcamera_ipa_include_dir = libcamera_include_dir / 'ipa'

libcamera_ipa_headers = files([
    'ipa_controls.h',
    'ipa_interface.h',
    'ipa_module_info.h',
])

install_headers(libcamera_ipa_headers,
                subdir : libcamera_ipa_include_dir)

ipa_headers_install_dir = get_option('includedir') / libcamera_ipa_include_dir

#
# Prepare IPA/IPC generation components
#

core_mojom_file = 'core.mojom'
ipa_mojom_core = custom_target(core_mojom_file.split('.')[0] + '_mojom_module',
                               input : core_mojom_file,
                               output : core_mojom_file + '-module',
                               command : [
                                   mojom_parser,
                                   '--output-root', meson.project_build_root(),
                                   '--input-root', meson.project_source_root(),
                                   '--mojoms', '@INPUT@'
                               ],
                               env : py_build_env)

# core_ipa_interface.h
libcamera_ipa_headers += custom_target('core_ipa_interface_h',
                  input : ipa_mojom_core,
                  output : 'core_ipa_interface.h',
                  depends : mojom_templates,
                  install : true,
                  install_dir : ipa_headers_install_dir,
                  command : [
                      mojom_generator, 'generate',
                      '-g', 'libcamera',
                      '--bytecode_path', mojom_templates_dir,
                      '--libcamera_generate_core_header',
                      '--libcamera_output_path=@OUTPUT@',
                      './' +'@INPUT@'
                  ],
                  env : py_build_env)

# core_ipa_serializer.h
libcamera_ipa_headers += custom_target('core_ipa_serializer_h',
                  input : ipa_mojom_core,
                  output : 'core_ipa_serializer.h',
                  depends : mojom_templates,
                  command : [
                      mojom_generator, 'generate',
                      '-g', 'libcamera',
                      '--bytecode_path', mojom_templates_dir,
                      '--libcamera_generate_core_serializer',
                      '--libcamera_output_path=@OUTPUT@',
                      './' +'@INPUT@'
                  ],
                  env : py_build_env)

# Mapping from pipeline handler name to mojom file
pipeline_ipa_mojom_mapping = {
    'ipu3': 'ipu3.mojom',
    'rkisp1': 'rkisp1.mojom',
    'rpi/vc4': 'raspberrypi.mojom',
    'simple': 'soft.mojom',
    'vimc': 'vimc.mojom',
}

#
# Generate headers from templates.
#

# TODO Define per-pipeline ControlInfoMap with yaml?

ipa_mojoms = []
mojoms_built = []
foreach pipeline, file : pipeline_ipa_mojom_mapping
    name = file.split('.')[0]

    # Avoid building duplicate mojom interfaces with the same interface file
    if name in mojoms_built
        continue
    endif

    if pipeline not in pipelines
        continue
    endif

    mojoms_built += name

    # {interface}.mojom-module
    mojom = custom_target(name + '_mojom_module',
                          input : file,
                          output : file + '-module',
                          depends : ipa_mojom_core,
                          command : [
                              mojom_parser,
                              '--output-root', meson.project_build_root(),
                              '--input-root', meson.project_source_root(),
                              '--mojoms', '@INPUT@'
                          ],
                          env : py_build_env)

    # {interface}_ipa_interface.h
    header = custom_target(name + '_ipa_interface_h',
                           input : mojom,
                           output : name + '_ipa_interface.h',
                           depends : mojom_templates,
                           install : true,
                           install_dir : ipa_headers_install_dir,
                           command : [
                               mojom_generator, 'generate',
                               '-g', 'libcamera',
                               '--bytecode_path', mojom_templates_dir,
                               '--libcamera_generate_header',
                               '--libcamera_output_path=@OUTPUT@',
                               './' +'@INPUT@'
                           ],
                           env : py_build_env)

    # {interface}_ipa_serializer.h
    serializer = custom_target(name + '_ipa_serializer_h',
                               input : mojom,
                               output : name + '_ipa_serializer.h',
                               depends : mojom_templates,
                               command : [
                                   mojom_generator, 'generate',
                                   '-g', 'libcamera',
                                   '--bytecode_path', mojom_templates_dir,
                                   '--libcamera_generate_serializer',
                                   '--libcamera_output_path=@OUTPUT@',
                                   './' +'@INPUT@'
                               ],
                               env : py_build_env)

    # {interface}_ipa_proxy.h
    proxy_header = custom_target(name + '_proxy_h',
                                 input : mojom,
                                 output : name + '_ipa_proxy.h',
                                 depends : mojom_templates,
                                 command : [
                                     mojom_generator, 'generate',
                                     '-g', 'libcamera',
                                     '--bytecode_path', mojom_templates_dir,
                                     '--libcamera_generate_proxy_h',
                                     '--libcamera_output_path=@OUTPUT@',
                                     './' +'@INPUT@'
                                 ],
                                 env : py_build_env)

    ipa_mojoms += {
        'name': name,
        'mojom': mojom,
    }

    libcamera_ipa_headers += [header, serializer, proxy_header]
endforeach

ipa_mojom_files = []
foreach pipeline, file : pipeline_ipa_mojom_mapping
    if file not in ipa_mojom_files
        ipa_mojom_files += file
    endif
endforeach
ipa_mojom_files = files(ipa_mojom_files)

# Pass this to the documentation generator in src/libcamera/ipa
ipa_mojom_files += files(['core.mojom'])