/* SPDX-License-Identifier: GPL-2.0-or-later *//* * Copyright (C) 2019, Google Inc. * * media_device_link_test.cpp - Tests link handling on VIMC media device */#include <iostream>#include"media_device_test.h"using namespace libcamera;using namespace std;/* * This link test requires a vimc device in order to exercise the * MediaObject link handling API on a graph with a predetermined topology. * * vimc is a Media Controller kernel driver that creates virtual devices. * From a userspace point of view they appear as normal media controller * devices, but are not backed by any particular piece of hardware. They can * thus be used for testing purpose without depending on a particular hardware * platform. * * If no vimc device is found (most likely because the vimc driver is not * loaded) the test is skipped. */class MediaDeviceLinkTest :public MediaDeviceTest
{intinit(){int ret =MediaDeviceTest::init();if(ret)return ret;if(!media_->acquire()) {
cerr <<"Unable to acquire media device "<< media_->deviceNode() << endl;return TestFail;}return TestPass;}intrun(){/* * First of all disable all links in the media graph to * ensure we start from a known state. */if(media_->disableLinks()) {
cerr <<"Failed to disable all links in the media graph";return TestFail;}/* * Test if link can be consistently retrieved through the * different functions the media device offers. */
string linkName("'Debayer A':[1] -> 'Scaler':[0]'");
MediaLink *link = media_->link("Debayer A",1,"Scaler",0);if(!link) {
cerr <<"Unable to find link: "<< linkName
<<" using lookup by name"<< endl;return TestFail;}
MediaEntity *source = media_->getEntityByName("Debayer A");if(!source) {
cerr <<"Unable to find entity: 'Debayer A'"<< endl;return TestFail;}