From patchwork Sat Aug 10 01:13:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1773 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 55A2361582 for ; Sat, 10 Aug 2019 03:13:57 +0200 (CEST) X-Halon-ID: 1afbd467-bb0c-11e9-bdc3-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from wyvern.dyn.berto.se (unknown [155.4.79.45]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 1afbd467-bb0c-11e9-bdc3-005056917a89; Sat, 10 Aug 2019 03:13:48 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 10 Aug 2019 03:13:32 +0200 Message-Id: <20190810011333.8731-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190810011333.8731-1-niklas.soderlund@ragnatech.se> References: <20190810011333.8731-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 3/4] tests: v4l2_videodevice: Set media bus and pixel formats for vimc X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Aug 2019 01:13:57 -0000 Most of the video device tests are based on vimc and Linux commit 85ab1aa1fac17bcd ("media: vimc: deb: fix default sink bayer format") changes the default media bus format for the debayer subdevices. This leads to a -EPIPE error when trying to use the raw capture video device nodes. Fix this by explicitly setting media bus and pixel formats to known good values which works before and after the upstream change. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- .../v4l2_videodevice_test.cpp | 26 +++++++++++++++++++ test/v4l2_videodevice/v4l2_videodevice_test.h | 7 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.cpp b/test/v4l2_videodevice/v4l2_videodevice_test.cpp index b26d06ad45197c8f..a0d269fef7f43895 100644 --- a/test/v4l2_videodevice/v4l2_videodevice_test.cpp +++ b/test/v4l2_videodevice/v4l2_videodevice_test.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include "v4l2_videodevice_test.h" #include "device_enumerator.h" @@ -69,6 +71,28 @@ int V4L2VideoDeviceTest::init() if (capture_->getFormat(&format)) return TestFail; + if (driver_ == "vimc") { + sensor_ = new CameraSensor(media_->getEntityByName("Sensor A")); + if (sensor_->init()) + return TestFail; + + debayer_ = new V4L2Subdevice(media_->getEntityByName("Debayer A")); + if (debayer_->open()) + return TestFail; + + format.fourcc = V4L2_PIX_FMT_SBGGR8; + + V4L2SubdeviceFormat subformat = {}; + subformat.mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8; + subformat.size = format.size; + + if (sensor_->setFormat(&subformat)) + return TestFail; + + if (debayer_->setFormat(0, &subformat)) + return TestFail; + } + format.size.width = 640; format.size.height = 480; if (capture_->setFormat(&format)) @@ -83,5 +107,7 @@ void V4L2VideoDeviceTest::cleanup() capture_->releaseBuffers(); capture_->close(); + delete debayer_; + delete sensor_; delete capture_; }; diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.h b/test/v4l2_videodevice/v4l2_videodevice_test.h index 3321b5a4f98fdb1d..34dd231c6d9d108d 100644 --- a/test/v4l2_videodevice/v4l2_videodevice_test.h +++ b/test/v4l2_videodevice/v4l2_videodevice_test.h @@ -13,8 +13,10 @@ #include "test.h" +#include "camera_sensor.h" #include "device_enumerator.h" #include "media_device.h" +#include "v4l2_subdevice.h" #include "v4l2_videodevice.h" using namespace libcamera; @@ -23,7 +25,8 @@ class V4L2VideoDeviceTest : public Test { public: V4L2VideoDeviceTest(const char *driver, const char *entity) - : driver_(driver), entity_(entity), capture_(nullptr) + : driver_(driver), entity_(entity), sensor_(nullptr), + debayer_(nullptr), capture_(nullptr) { } @@ -35,6 +38,8 @@ protected: std::string entity_; std::unique_ptr enumerator_; std::shared_ptr media_; + CameraSensor *sensor_; + V4L2Subdevice *debayer_; V4L2VideoDevice *capture_; BufferPool pool_; };