libcamera/test/controls/control_info_map.cpp
Niklas Söderlund 75a9aebee5 libcamera: pipelines: Use sensor ID as camera name
Use the CameraSensor ID as the camera name in pipelines that uses a
CameraSensors, this is done in preparation of turning the camera name
into an ID. The CameraSensor ID meets the requirements that will be put
on camera ID.

Before this change example of camera names:

* OF based systems
    ov5695 7-0036
    ov2685 7-003c

* ACPI based systems
    ov13858 8-0010
    ov5670 10-0036

* VIMC
    VIMC Sensor B

After this change the same cameras are:

* OF based systems
    /base/i2c@ff160000/camera@36
    /base/i2c@ff160000/camera@36

* ACPI based systems
    \_SB_.PCI0.I2C2.CAM0
    \_SB_.PCI0.I2C4.CAM1

* VIMC
    platform/vimc.0 Sensor B

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2020-08-05 20:07:13 +02:00

82 lines
1.8 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* control_info.cpp - ControlInfoMap tests
*/
#include <iostream>
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include "libcamera/internal/camera_controls.h"
#include "camera_test.h"
#include "test.h"
using namespace std;
using namespace libcamera;
class ControlInfoMapTest : public CameraTest, public Test
{
public:
ControlInfoMapTest()
: CameraTest("platform/vimc.0 Sensor B")
{
}
protected:
int init() override
{
return status_;
}
int run() override
{
const ControlInfoMap &infoMap = camera_->controls();
/* Test looking up a valid control by ControlId. */
if (infoMap.count(&controls::Brightness) != 1) {
cerr << "count() on valid control failed" << endl;
return TestFail;
}
if (infoMap.find(&controls::Brightness) == infoMap.end()) {
cerr << "find() on valid control failed" << endl;
return TestFail;
}
infoMap.at(&controls::Brightness);
/* Test looking up a valid control by numerical ID. */
if (infoMap.count(controls::Brightness.id()) != 1) {
cerr << "count() on valid ID failed" << endl;
return TestFail;
}
if (infoMap.find(controls::Brightness.id()) == infoMap.end()) {
cerr << "find() on valid ID failed" << endl;
return TestFail;
}
infoMap.at(controls::Brightness.id());
/* Test looking up an invalid control by numerical ID. */
if (infoMap.count(12345) != 0) {
cerr << "count() on invalid ID failed" << endl;
return TestFail;
}
if (infoMap.find(12345) != infoMap.end()) {
cerr << "find() on invalid ID failed" << endl;
return TestFail;
}
return TestPass;
}
};
TEST_REGISTER(ControlInfoMapTest)