From patchwork Mon Aug 5 15:51:30 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: 1728 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 60C81615FF for ; Mon, 5 Aug 2019 17:51:40 +0200 (CEST) X-Halon-ID: e907f936-b798-11e9-903a-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [145.14.112.32]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id e907f936-b798-11e9-903a-005056917f90; Mon, 05 Aug 2019 17:51:38 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Aug 2019 17:51:30 +0200 Message-Id: <20190805155133.11335-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> References: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] libcamera: pipeline: vimc: Initialize device pointers 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: Mon, 05 Aug 2019 15:51:40 -0000 As the device pointers are deleted in the pipelines destructor it's not a good idea to have them uninitialized. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/vimc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 61b68a32ea508af8..3d6808222a8a2c5d 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -35,7 +35,7 @@ class VimcCameraData : public CameraData { public: VimcCameraData(PipelineHandler *pipe) - : CameraData(pipe) + : CameraData(pipe), video_(nullptr), sensor_(nullptr) { } From patchwork Mon Aug 5 15:51:31 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: 1729 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EEF7261616 for ; Mon, 5 Aug 2019 17:51:40 +0200 (CEST) X-Halon-ID: e953e07e-b798-11e9-903a-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [145.14.112.32]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id e953e07e-b798-11e9-903a-005056917f90; Mon, 05 Aug 2019 17:51:39 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Aug 2019 17:51:31 +0200 Message-Id: <20190805155133.11335-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> References: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] libcamera: pipeline: vimc: Propagate media bus format 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: Mon, 05 Aug 2019 15:51:41 -0000 Linux commit 85ab1aa1fac17bcd ("media: vimc: deb: fix default sink bayer format") which is part of v5.2 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 propagating the media bus format used on the debayer subdevcie to the sensor. This allows the same code to function on kernels previous to the change and after it. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/vimc.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 3d6808222a8a2c5d..ae612b48436d1164 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -25,6 +25,7 @@ #include "pipeline_handler.h" #include "utils.h" #include "v4l2_controls.h" +#include "v4l2_subdevice.h" #include "v4l2_videodevice.h" namespace libcamera { @@ -35,13 +36,15 @@ class VimcCameraData : public CameraData { public: VimcCameraData(PipelineHandler *pipe) - : CameraData(pipe), video_(nullptr), sensor_(nullptr) + : CameraData(pipe), video_(nullptr), debayer_(nullptr), + sensor_(nullptr) { } ~VimcCameraData() { delete sensor_; + delete debayer_; delete video_; } @@ -49,6 +52,7 @@ public: void bufferReady(Buffer *buffer); V4L2VideoDevice *video_; + V4L2Subdevice *debayer_; CameraSensor *sensor_; Stream stream_; }; @@ -188,6 +192,17 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config) format.fourcc != cfg.pixelFormat) return -EINVAL; + V4L2SubdeviceFormat subformat = {}; + subformat.size = cfg.size; + + ret = data->debayer_->setFormat(0, &subformat); + if (ret) + return ret; + + ret = data->sensor_->setFormat(&subformat); + if (ret) + return ret; + cfg.setStream(&data->stream_); return 0; @@ -340,6 +355,10 @@ int VimcCameraData::init(MediaDevice *media) if (video_->open()) return -ENODEV; + debayer_ = new V4L2Subdevice(media->getEntityByName("Debayer B")); + if (debayer_->open()) + return -ENODEV; + video_->bufferReady.connect(this, &VimcCameraData::bufferReady); sensor_ = new CameraSensor(media->getEntityByName("Sensor B")); From patchwork Mon Aug 5 15:51: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: 1730 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 028CC61619 for ; Mon, 5 Aug 2019 17:51:40 +0200 (CEST) X-Halon-ID: e9c3971b-b798-11e9-903a-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [145.14.112.32]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id e9c3971b-b798-11e9-903a-005056917f90; Mon, 05 Aug 2019 17:51:39 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Aug 2019 17:51:32 +0200 Message-Id: <20190805155133.11335-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> References: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] tests: v4l2_videodevice: Propagate media bus format 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: Mon, 05 Aug 2019 15:51:41 -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 propagating the media bus format used on the debayer subdevcie to the sensor. This allows the same code to function on kernels previous to the change and after it. Signed-off-by: Niklas Söderlund --- .../v4l2_videodevice_test.cpp | 22 +++++++++++++++++++ test/v4l2_videodevice/v4l2_videodevice_test.h | 7 +++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/test/v4l2_videodevice/v4l2_videodevice_test.cpp b/test/v4l2_videodevice/v4l2_videodevice_test.cpp index b26d06ad45197c8f..b1d4eaf6e9e4a4b1 100644 --- a/test/v4l2_videodevice/v4l2_videodevice_test.cpp +++ b/test/v4l2_videodevice/v4l2_videodevice_test.cpp @@ -62,6 +62,26 @@ int V4L2VideoDeviceTest::init() if (ret) return TestFail; + if (driver_ == "vimc") { + V4L2SubdeviceFormat subformat = {}; + subformat.size.width = 640; + subformat.size.height = 480; + + sensor_ = new CameraSensor(media_->getEntityByName("Sensor A")); + if (sensor_->init()) + return TestFail; + + debayer_ = new V4L2Subdevice(media_->getEntityByName("Debayer A")); + if (debayer_->open()) + return TestFail; + + if (debayer_->setFormat(0, &subformat)) + return TestFail; + + if (sensor_->setFormat(&subformat)) + return TestFail; + } + if (capture_->open()) return TestFail; @@ -83,5 +103,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_; }; From patchwork Mon Aug 5 15:51:33 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: 1731 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 76F5961616 for ; Mon, 5 Aug 2019 17:51:41 +0200 (CEST) X-Halon-ID: ea336584-b798-11e9-903a-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [145.14.112.32]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id ea336584-b798-11e9-903a-005056917f90; Mon, 05 Aug 2019 17:51:40 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Aug 2019 17:51:33 +0200 Message-Id: <20190805155133.11335-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> References: <20190805155133.11335-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] tests: camera-sensor: Drop check on media bus format 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: Mon, 05 Aug 2019 15:51:41 -0000 Linux commit b6c61a6c37317efd ("media: vimc: propagate pixel format in the stream") changes the sensor in the vimc media graph to accept any media bus format set on it. This prevents the camera-sensor test case to verify that a supported media bus format is selected. In lack of a better fix remove the check for media bus format. Signed-off-by: Niklas Söderlund --- test/camera-sensor.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp index 092cbdd8111ce70d..a04b7333daecd9dd 100644 --- a/test/camera-sensor.cpp +++ b/test/camera-sensor.cpp @@ -87,10 +87,8 @@ protected: MEDIA_BUS_FMT_SBGGR10_1X10, MEDIA_BUS_FMT_BGR888_1X24 }, Size(1024, 768)); - if (format.mbus_code != MEDIA_BUS_FMT_SBGGR10_1X10 || - format.size != Size(4096, 2160)) { - cerr << "Failed to get a suitable format, expected 4096x2160-0x" - << std::hex << MEDIA_BUS_FMT_SBGGR10_1X10 + if (format.size != Size(4096, 2160)) { + cerr << "Failed to get a suitable format, expected 4096x2160" << ", got " << format.toString() << endl; return TestFail; }