diff options
Diffstat (limited to 'include')
-rwxr-xr-x | include/libcamera/gen-formats.py | 118 | ||||
-rwxr-xr-x | include/libcamera/gen-header.sh | 32 | ||||
-rw-r--r-- | include/libcamera/meson.build | 6 |
3 files changed, 0 insertions, 156 deletions
diff --git a/include/libcamera/gen-formats.py b/include/libcamera/gen-formats.py deleted file mode 100755 index 60dcecc3..00000000 --- a/include/libcamera/gen-formats.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: GPL-2.0-or-later -# Copyright (C) 2020, Google Inc. -# -# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com> -# -# gen-formats.py - Generate formats definitions from YAML - -import argparse -import re -import string -import sys -import yaml - - -class DRMFourCC(object): - format_regex = re.compile(r"#define (DRM_FORMAT_[A-Z0-9_]+)[ \t]+fourcc_code\(('.', '.', '.', '.')\)") - mod_vendor_regex = re.compile(r"#define DRM_FORMAT_MOD_VENDOR_([A-Z0-9_]+)[ \t]+([0-9a-fA-Fx]+)") - mod_regex = re.compile(r"#define ([A-Za-z0-9_]+)[ \t]+fourcc_mod_code\(([A-Z0-9_]+), ([0-9a-fA-Fx]+)\)") - - def __init__(self, filename): - self.formats = {} - self.vendors = {} - self.mods = {} - - for line in open(filename, 'rb').readlines(): - line = line.decode('utf-8') - - match = DRMFourCC.format_regex.match(line) - if match: - format, fourcc = match.groups() - self.formats[format] = fourcc - continue - - match = DRMFourCC.mod_vendor_regex.match(line) - if match: - vendor, value = match.groups() - self.vendors[vendor] = int(value, 0) - continue - - match = DRMFourCC.mod_regex.match(line) - if match: - mod, vendor, value = match.groups() - self.mods[mod] = (vendor, int(value, 0)) - continue - - def fourcc(self, name): - return self.formats[name] - - def mod(self, name): - vendor, value = self.mods[name] - return self.vendors[vendor], value - - -def generate_h(formats, drm_fourcc): - template = string.Template('constexpr PixelFormat ${name}{ __fourcc(${fourcc}), __mod(${mod}) };') - - fmts = [] - - for format in formats: - name, format = format.popitem() - - data = { - 'name': name, - 'fourcc': drm_fourcc.fourcc(format['fourcc']), - 'mod': '0, 0', - } - - mod = format.get('mod') - if mod: - data['mod'] = '%u, %u' % drm_fourcc.mod(mod) - - fmts.append(template.substitute(data)) - - return {'formats': '\n'.join(fmts)} - - -def fill_template(template, data): - - template = open(template, 'rb').read() - template = template.decode('utf-8') - template = string.Template(template) - return template.substitute(data) - - -def main(argv): - - # Parse command line arguments - parser = argparse.ArgumentParser() - parser.add_argument('-o', dest='output', metavar='file', type=str, - help='Output file name. Defaults to standard output if not specified.') - parser.add_argument('input', type=str, - help='Input file name.') - parser.add_argument('template', type=str, - help='Template file name.') - parser.add_argument('drm_fourcc', type=str, - help='Path to drm_fourcc.h.') - args = parser.parse_args(argv[1:]) - - data = open(args.input, 'rb').read() - formats = yaml.safe_load(data)['formats'] - drm_fourcc = DRMFourCC(args.drm_fourcc) - - data = generate_h(formats, drm_fourcc) - data = fill_template(args.template, data) - - if args.output: - output = open(args.output, 'wb') - output.write(data.encode('utf-8')) - output.close() - else: - sys.stdout.write(data) - - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/include/libcamera/gen-header.sh b/include/libcamera/gen-header.sh deleted file mode 100755 index fcb9c5e1..00000000 --- a/include/libcamera/gen-header.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -src_dir="$1" -dst_file="$2" - -cat <<EOF > "$dst_file" -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* This file is auto-generated, do not edit! */ -/* - * Copyright (C) 2018-2019, Google Inc. - * - * libcamera.h - libcamera public API - */ -#ifndef __LIBCAMERA_LIBCAMERA_H__ -#define __LIBCAMERA_LIBCAMERA_H__ - -EOF - -headers=$(for header in "$src_dir"/*.h "$src_dir"/*.h.in ; do - header=$(basename "$header") - header="${header%.in}" - echo "$header" -done | sort) - -for header in $headers ; do - echo "#include <libcamera/$header>" >> "$dst_file" -done - -cat <<EOF >> "$dst_file" - -#endif /* __LIBCAMERA_LIBCAMERA_H__ */ -EOF diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index cdb8e037..692931a5 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -34,8 +34,6 @@ install_headers(libcamera_public_headers, # # control_ids.h and property_ids.h -gen_controls = files('../../src/libcamera/gen-controls.py') - control_source_files = [ 'control_ids', 'property_ids', @@ -57,8 +55,6 @@ endforeach libcamera_public_headers += control_headers # formats.h -gen_formats = files('gen-formats.py') - formats_h = custom_target('formats_h', input : files( '../../src/libcamera/formats.yaml', @@ -72,8 +68,6 @@ formats_h = custom_target('formats_h', libcamera_public_headers += formats_h # libcamera.h -gen_header = files('gen-header.sh') - libcamera_h = custom_target('gen-header', input : 'meson.build', output : 'libcamera.h', |