summaryrefslogtreecommitdiff
path: root/test/pipeline/ipu3
AgeCommit message (Collapse)Author
2019-10-23libcamera: Standardise on C compatibility headersLaurent Pinchart
Now that our usage of C compatibility header is documented, use them consistently through the source code. While at it, group the C and C++ include statements as defined in the coding style, and fix a handful of #include ordering issues. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-08-19libcamera: camera_manager: Construct CameraManager instances manuallyLaurent Pinchart
The CameraManager class is not supposed to be instantiated multiple times, which led to a singleton implementation. This requires a global instance of the CameraManager, which is destroyed when the global destructors are executed. Relying on global instances causes issues with cleanup, as the order in which the global destructors are run can't be controlled. In particular, the Android camera HAL implementation ends up destroying the CameraHalManager after the CameraManager, which leads to use-after-free problems. To solve this, remove the CameraManager::instance() method and make the CameraManager class instantiable directly. Multiple instances are still not allowed, and this is enforced by storing the instance pointer internally to be checked when an instance is created. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2019-05-23meson: Create and use a dependency for libcamera and its headersLaurent Pinchart
Instead of manually adding the libcamera library and include path to every target that requires it, declare a dependency that groups the headers as source, the library and the include path, and use it through the project. This simplifies handling of the dependency. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2019-05-23meson: Fix coding style in meson.build filesLaurent Pinchart
Consistently go for 4 spaces indentation, and always put a space between the colon in argument lists, as per the examples from the meson documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-05-17libcamera: media_device: Open and close media device inside populate()Niklas Söderlund
Remove the need for the caller to open and close the media device when populating the MediaDevice. This is done as an effort to make the usage of the MediaDevice less error prone and the interface stricter. The rework also revealed and fixes a potential memory leak in MediaDevice::populate() where resources would not be deleted if the second MEDIA_IOC_G_TOPOLOGY would fail. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2019-01-24libcamera: device_enumerator: Reference-count MediaDevice instancesLaurent Pinchart
The MediaDevice class will be the entry point to hot-unplug, as it corresponds to the kernel devices that will report device removal events. The class will signal media device disconnection to pipeline handlers, which will clean up resources as a result. This can't be performed synchronously as references may exist to the related Camera objects in applications. The MediaDevice object thus needs to be reference-counted in order to support unplugging, as otherwise pipeline handlers would be required to drop all the references to the media device they have borrowed synchronously with the disconnection signal handler, which would be very error prone (if even possible at all in a sane way). Handle MedieDevice instances with std::shared_ptr<> to support this. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-01-22libcamera: Global s/devnode/deviceNode renameJacopo Mondi
Do not use the abreviated version for members, variables and getter methods. Library-wise rename, no intended functional changes. Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
2019-01-22test: pipeline: IPU3: Add IPU3 pipeline testJacopo Mondi
Add test for the Intel IPU3 pipeline that lists all the cameras registered in the system and verifies the result matches the expected. This test is meant to be run on IPU3 platforms, it gets skipped otherwise. Acked-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
an class="hl ppc">#include <string.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <libcamera/base/log.h> #include <libcamera/logging.h> #include "test.h" using namespace std; using namespace libcamera; LOG_DEFINE_CATEGORY(LogAPITest) class LogAPITest : public Test { protected: void doLogging() { logSetLevel("LogAPITest", "DEBUG"); LOG(LogAPITest, Info) << "good 1"; logSetLevel("LogAPITest", "WARN"); LOG(LogAPITest, Info) << "bad"; logSetLevel("LogAPITest", "ERROR"); LOG(LogAPITest, Error) << "good 3"; LOG(LogAPITest, Info) << "bad"; logSetLevel("LogAPITest", "WARN"); LOG(LogAPITest, Warning) << "good 5"; LOG(LogAPITest, Info) << "bad"; } int verifyOutput(istream &is) { list<int> goodList = { 1, 3, 5 }; string line; while (getline(is, line)) { if (goodList.empty()) { cout << "Too many log lines" << endl; return TestFail; } unsigned int digit = line.back() - '0'; unsigned int expect = goodList.front(); goodList.pop_front(); if (digit != expect) { cout << "Incorrect log line" << endl; return TestFail; } } if (!goodList.empty()) { cout << "Too few log lines" << endl; return TestFail; } return TestPass; } int testFile() { int fd = open("/tmp", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR); if (fd < 0) { cerr << "Failed to open tmp log file" << endl; return TestFail; } char path[32]; snprintf(path, sizeof(path), "/proc/self/fd/%u", fd); if (logSetFile(path) < 0) { cerr << "Failed to set log file" << endl; close(fd); return TestFail; } doLogging(); char buf[1000]; memset(buf, 0, sizeof(buf)); lseek(fd, 0, SEEK_SET); if (read(fd, buf, sizeof(buf)) < 0) { cerr << "Failed to read tmp log file" << endl; close(fd); return TestFail; } close(fd); istringstream iss(buf); return verifyOutput(iss); } int testStream() { stringstream log; /* Never fails, so no need to check return value */ logSetStream(&log); doLogging(); return verifyOutput(log); } int testTarget() { logSetTarget(LoggingTargetNone); logSetLevel("LogAPITest", "DEBUG"); LOG(LogAPITest, Info) << "don't crash please"; if (!logSetTarget(LoggingTargetFile)) return TestFail; if (!logSetTarget(LoggingTargetStream)) return TestFail; return TestPass; } int run() override { int ret = testFile(); if (ret != TestPass) return TestFail; ret = testStream(); if (ret != TestPass) return TestFail; ret = testTarget(); if (ret != TestPass) return TestFail; return TestPass; } }; TEST_REGISTER(LogAPITest)