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"));