/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2019, Google Inc. * * v4l2_subdevice_test.cpp - VIMC-based V4L2 subdevice test */ #include #include #include #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/v4l2_subdevice.h" #include "v4l2_subdevice_test.h" using namespace std; using namespace libcamera; /* * This test runs on vimc media device. For a description of vimc, in the * context of libcamera testing, please refer to * 'test/media_device/media_device_link_test.cpp' file. * * If the vimc module is not loaded, the test gets skipped. */ int V4L2SubdeviceTest::init() { enumerator_ = DeviceEnumerator::create(); if (!enumerator_) { cerr << "Failed to create device enumerator" << endl; return TestFail; } if (enumerator_->enumerate()) { cerr << "Failed to enumerate media devices" << endl; return TestFail; } DeviceMatch dm("vimc"); media_ = enumerator_->search(dm); if (!media_) { cerr << "Unable to find \'vimc\' media device node" << endl; return TestSkip; } MediaEntity *videoEntity = media_->getEntityByName("Scaler"); if (!videoEntity) { cerr << "Unable to find media entity 'Scaler'" << endl; return TestFail; } scaler_ = new V4L2Subdevice(videoEntity); if (scaler_->open()) { cerr << "Unable to open video subdevice " << scaler_->entity()->deviceNode() << endl; return TestSkip; } return 0; } void V4L2SubdeviceTest::cleanup() { delete scaler_; } evice-match-generalize'>jmondi/device-match-generalize Jacopo Mondi's clone of libcameragit repository hosting on libcamera.org
summaryrefslogtreecommitdiff
blob: a4a1f7b79337d6a2ad93dc113a648fe444445e19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020, Google Inc.
#
# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#
# ipa-gen-key.py - Generate the IPA module signing public key

import string
import subprocess
import sys


def main(argv):
    if len(argv) != 4:
        print('Usage: %s priv-key template output' % argv[0])
        return 1

    priv_key = argv[1]
    template = argv[2]
    output = argv[3]

    try:
        ret = subprocess.run(['openssl', 'rsa', '-pubout', '-in', priv_key,
                              '-outform', 'DER'],
                             stdout=subprocess.PIPE)
    except FileNotFoundError:
        print('Please install openssl to sign IPA modules')
        return 1

    ipa_key = ['0x%02x' % c for c in ret.stdout]
    ipa_key = [', '.join(ipa_key[bound:bound + 8]) for bound in range(0, len(ipa_key), 8)]
    ipa_key = ',\n\t'.join(ipa_key)
    data = {'ipa_key': ipa_key}

    template = open(template, 'rb').read()
    template = template.decode('utf-8')
    template = string.Template(template)

    f = open(output, 'wb')
    f.write(template.substitute(data).encode('utf-8'))
    f.close()

    return 0


if __name__ == '__main__':
    sys.exit(main(sys.argv))