{"id":656,"url":"https://patchwork.libcamera.org/api/patches/656/?format=json","web_url":"https://patchwork.libcamera.org/patch/656/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190228162913.6508-4-laurent.pinchart@ideasonboard.com>","date":"2019-02-28T16:29:06","name":"[libcamera-devel,03/10] libcamera: pipeline: vimc: Create VimcCameraData","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d850ebe64ef11b97eaf266b846a6072b24d7bef1","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/656/mbox/","series":[{"id":196,"url":"https://patchwork.libcamera.org/api/series/196/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=196","date":"2019-02-28T16:29:03","name":"Rework request completion handling","version":1,"mbox":"https://patchwork.libcamera.org/series/196/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/656/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/656/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E0B0D610C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:25 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7787C67\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 17:29:25 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551371365;\n\tbh=hlkmkfRM9+S1PU/wHE3+cyeS34RAqRsKI2YBLlTpJME=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=rSrD91m0dEi2i2gy+eAjbjFzs0BOaTxSsSHhB6kznF0L7kpe6s0RQbpcs5ZpF39Q9\n\t31UFp1munb0iYLt8gEX7fgiwCRFGr9WiCi2sinM00Exd2RXRNf/yb2LdxM/FmnqSUF\n\tFpkMVadwDmIx+DH0ntOcfsdtyw/8GH+e5sVdEnXI=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 28 Feb 2019 18:29:06 +0200","Message-Id":"<20190228162913.6508-4-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.19.2","In-Reply-To":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","References":"<20190228162913.6508-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 03/10] libcamera: pipeline: vimc: Create\n\tVimcCameraData","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 28 Feb 2019 16:29:26 -0000"},"content":"Subclassing CameraData will become mandatory for pipeline handlers.\nCreate a new VimcCameraData class and instantiate it when creating\ncameras to prepare for that change. The video_ and stream_ fields of the\nVIMC pipeline handler belong to the camera data, move them there.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/pipeline/vimc.cpp | 73 +++++++++++++++++++++++++--------\n 1 file changed, 56 insertions(+), 17 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 640fca5cb0e7..ef47e7f96436 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -13,6 +13,7 @@\n #include \"log.h\"\n #include \"media_device.h\"\n #include \"pipeline_handler.h\"\n+#include \"utils.h\"\n #include \"v4l2_device.h\"\n \n namespace libcamera {\n@@ -42,20 +43,38 @@ public:\n \tbool match(DeviceEnumerator *enumerator);\n \n private:\n+\tclass VimcCameraData : public CameraData\n+\t{\n+\tpublic:\n+\t\tVimcCameraData()\n+\t\t{\n+\t\t}\n+\n+\t\t~VimcCameraData()\n+\t\t{\n+\t\t\tdelete video_;\n+\t\t}\n+\n+\t\tV4L2Device *video_;\n+\t\tStream stream_;\n+\t};\n+\n+\tVimcCameraData *cameraData(const Camera *camera)\n+\t{\n+\t\treturn static_cast<VimcCameraData *>(\n+\t\t\tPipelineHandler::cameraData(camera));\n+\t}\n+\n \tstd::shared_ptr<MediaDevice> media_;\n-\tV4L2Device *video_;\n-\tStream stream_;\n };\n \n PipelineHandlerVimc::PipelineHandlerVimc(CameraManager *manager)\n-\t: PipelineHandler(manager), media_(nullptr), video_(nullptr)\n+\t: PipelineHandler(manager), media_(nullptr)\n {\n }\n \n PipelineHandlerVimc::~PipelineHandlerVimc()\n {\n-\tdelete video_;\n-\n \tif (media_)\n \t\tmedia_->release();\n }\n@@ -64,6 +83,7 @@ std::map<Stream *, StreamConfiguration>\n PipelineHandlerVimc::streamConfiguration(Camera *camera,\n \t\t\t\t     std::vector<Stream *> &streams)\n {\n+\tVimcCameraData *data = cameraData(camera);\n \tstd::map<Stream *, StreamConfiguration> configs;\n \n \tStreamConfiguration config{};\n@@ -74,7 +94,7 @@ PipelineHandlerVimc::streamConfiguration(Camera *camera,\n \tconfig.pixelFormat = V4L2_PIX_FMT_RGB24;\n \tconfig.bufferCount = 4;\n \n-\tconfigs[&stream_] = config;\n+\tconfigs[&data->stream_] = config;\n \n \treturn configs;\n }\n@@ -82,7 +102,8 @@ PipelineHandlerVimc::streamConfiguration(Camera *camera,\n int PipelineHandlerVimc::configureStreams(Camera *camera,\n \t\t\t\t      std::map<Stream *, StreamConfiguration> &config)\n {\n-\tStreamConfiguration *cfg = &config[&stream_];\n+\tVimcCameraData *data = cameraData(camera);\n+\tStreamConfiguration *cfg = &config[&data->stream_];\n \tint ret;\n \n \tLOG(VIMC, Debug) << \"Configure the camera for resolution \"\n@@ -93,7 +114,7 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,\n \tformat.height = cfg->height;\n \tformat.fourcc = cfg->pixelFormat;\n \n-\tret = video_->setFormat(&format);\n+\tret = data->video_->setFormat(&format);\n \tif (ret)\n \t\treturn ret;\n \n@@ -107,31 +128,36 @@ int PipelineHandlerVimc::configureStreams(Camera *camera,\n \n int PipelineHandlerVimc::allocateBuffers(Camera *camera, Stream *stream)\n {\n+\tVimcCameraData *data = cameraData(camera);\n \tconst StreamConfiguration &cfg = stream->configuration();\n \n \tLOG(VIMC, Debug) << \"Requesting \" << cfg.bufferCount << \" buffers\";\n \n-\treturn video_->exportBuffers(&stream->bufferPool());\n+\treturn data->video_->exportBuffers(&stream->bufferPool());\n }\n \n int PipelineHandlerVimc::freeBuffers(Camera *camera, Stream *stream)\n {\n-\treturn video_->releaseBuffers();\n+\tVimcCameraData *data = cameraData(camera);\n+\treturn data->video_->releaseBuffers();\n }\n \n int PipelineHandlerVimc::start(const Camera *camera)\n {\n-\treturn video_->streamOn();\n+\tVimcCameraData *data = cameraData(camera);\n+\treturn data->video_->streamOn();\n }\n \n void PipelineHandlerVimc::stop(const Camera *camera)\n {\n-\tvideo_->streamOff();\n+\tVimcCameraData *data = cameraData(camera);\n+\tdata->video_->streamOff();\n }\n \n int PipelineHandlerVimc::queueRequest(const Camera *camera, Request *request)\n {\n-\tBuffer *buffer = request->findBuffer(&stream_);\n+\tVimcCameraData *data = cameraData(camera);\n+\tBuffer *buffer = request->findBuffer(&data->stream_);\n \tif (!buffer) {\n \t\tLOG(VIMC, Error)\n \t\t\t<< \"Attempt to queue request with invalid stream\";\n@@ -139,7 +165,7 @@ int PipelineHandlerVimc::queueRequest(const Camera *camera, Request *request)\n \t\treturn -ENOENT;\n \t}\n \n-\tvideo_->queueBuffer(buffer);\n+\tdata->video_->queueBuffer(buffer);\n \n \treturn 0;\n }\n@@ -164,13 +190,26 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \n \tmedia_->acquire();\n \n-\tvideo_ = new V4L2Device(media_->getEntityByName(\"Raw Capture 1\"));\n-\tif (video_->open())\n+\tstd::unique_ptr<VimcCameraData> data = utils::make_unique<VimcCameraData>();\n+\n+\t/* Locate and open the capture video node. */\n+\tMediaEntity *entity = media_->getEntityByName(\"Raw Capture 1\");\n+\tif (!entity) {\n+\t\tLOG(VIMC, Error)\n+\t\t\t<< \"Can't find 'Raw Capture 1' entity\";\n+\t\treturn false;\n+\t}\n+\n+\tdata->video_ = new V4L2Device(entity);\n+\tif (data->video_->open())\n \t\treturn false;\n \n-\tstd::vector<Stream *> streams{ &stream_ };\n+\t/* Create and register the camera. */\n+\tstd::vector<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera = Camera::create(this, \"VIMC Sensor B\",\n \t\t\t\t\t\t\tstreams);\n+\n+\tsetCameraData(camera.get(), std::move(data));\n \tregisterCamera(std::move(camera));\n \n \treturn true;\n","prefixes":["libcamera-devel","03/10"]}