mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +03:00
Source files in libcamera start by a comment block header, which includes the file name and a one-line description of the file contents. While the latter is useful to get a quick overview of the file contents at a glance, the former is mostly a source of inconvenience. The name in the comments can easily get out of sync with the file name when files are renamed, and copy & paste during development have often lead to incorrect names being used to start with. Readers of the source code are expected to know which file they're looking it. Drop the file name from the header comment block. The change was generated with the following script: ---------------------------------------- dirs="include/libcamera src test utils" declare -rA patterns=( ['c']=' \* ' ['cpp']=' \* ' ['h']=' \* ' ['py']='# ' ['sh']='# ' ) for ext in ${!patterns[@]} ; do files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done) pattern=${patterns[${ext}]} for file in $files ; do name=$(basename ${file}) sed -i "s/^\(${pattern}\)${name} - /\1/" "$file" done done ---------------------------------------- This misses several files that are out of sync with the comment block header. Those will be addressed separately and manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
68 lines
1.5 KiB
C++
68 lines
1.5 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* VIMC-based V4L2 subdevice test
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <string.h>
|
|
#include <sys/stat.h>
|
|
|
|
#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_;
|
|
}
|