[{"id":1110,"web_url":"https://patchwork.libcamera.org/comment/1110/","msgid":"<20190323134146.GG4587@pendragon.ideasonboard.com>","date":"2019-03-23T13:41:46","subject":"Re: [libcamera-devel] [PATCH v4 18/31] libcamera: ipu3: Create\n\tcamera with 2 streams","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Wed, Mar 20, 2019 at 05:30:42PM +0100, Jacopo Mondi wrote:\n> Create each IPU3 camera with two streams: 'output' and 'viewfinder'\n> which represents the video stream from main and secondary ImgU output\n\ns/represents/represent/\ns/stream from main/streams for the main/\n\n> respectively.\n> \n> Return a default configuration for both streams in\n> streamConfiguration().\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 42 ++++++++++++++++++----------\n>  1 file changed, 28 insertions(+), 14 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 43fa0e4a7f9d..44e5eb48549e 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -120,6 +120,10 @@ private:\n>  \tstatic constexpr unsigned int IPU3_CIO2_BUFFER_COUNT = 4;\n>  \tstatic constexpr unsigned int IPU3_IMGU_BUFFER_COUNT = 4;\n>  \n> +\tstatic constexpr unsigned int IPU3_STREAMS_COUNT = 2;\n> +\tstatic constexpr unsigned int IPU3_STREAM_OUTPUT = 0;\n> +\tstatic constexpr unsigned int IPU3_STREAM_VF = 1;\n> +\n>  \tclass IPU3CameraData : public CameraData\n>  \t{\n>  \tpublic:\n> @@ -135,7 +139,7 @@ private:\n>  \t\tCIO2Device cio2;\n>  \t\tImgUDevice *imgu;\n>  \n> -\t\tStream stream_;\n> +\t\tStream streams_[IPU3_STREAMS_COUNT];\n\nUnless you need to iterate over the streams array, it may be more\nreadable to use two variables (outputStream_ and viewfinderStream_ for\ninstance, or outStream_ and vfStream_ possibly).\n\n>  \t};\n>  \n>  \tIPU3CameraData *cameraData(const Camera *camera)\n> @@ -194,7 +198,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n>  \tstd::map<Stream *, StreamConfiguration> configs;\n>  \tIPU3CameraData *data = cameraData(camera);\n>  \tV4L2Subdevice *sensor = data->cio2.sensor;\n> -\tStreamConfiguration *config = &configs[&data->stream_];\n> +\tStreamConfiguration config = {};\n>  \tunsigned int bestSize = 0;\n>  \n>  \tconst FormatEnum formats = sensor->formats(0);\n> @@ -213,8 +217,8 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n>  \n>  \t\t\tbestSize = frameSize;\n>  \n> -\t\t\tconfig->width = range.maxWidth;\n> -\t\t\tconfig->height = range.maxHeight;\n> +\t\t\tconfig.width = range.maxWidth;\n> +\t\t\tconfig.height = range.maxHeight;\n>  \t\t}\n>  \t}\n>  \n> @@ -226,15 +230,22 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n>  \t *\n>  \t * \\todo Clarify ImgU alignement requirements.\n>  \t */\n> -\tconfig->width = 2560;\n> -\tconfig->height = 1920;\n> -\tconfig->pixelFormat = V4L2_PIX_FMT_NV12;\n> -\tconfig->bufferCount = IPU3_BUFFER_COUNT;\n> +\tconfig.width = 2560;\n> +\tconfig.height = 1920;\n> +\tconfig.pixelFormat = V4L2_PIX_FMT_NV12;\n> +\tconfig.bufferCount = IPU3_BUFFER_COUNT;\n> +\n> +\tconfigs[&data->streams_[IPU3_STREAM_OUTPUT]] = config;\n> +\tLOG(IPU3, Debug)\n> +\t\t<< \"Stream 'Output' format set to \" << config.width << \"x\"\n> +\t\t<< config.height << \"- 0x\" << std::hex << std::setfill('0')\n> +\t\t<< std::setw(8) << config.pixelFormat;\n>  \n> +\tconfigs[&data->streams_[IPU3_STREAM_VF]] = config;\n>  \tLOG(IPU3, Debug)\n> -\t\t<< \"Stream format set to: \" << config->width << \"x\"\n> -\t\t<< config->height << \"- 0x\" << std::hex << std::setfill('0')\n> -\t\t<< std::setw(8) << config->pixelFormat;\n> +\t\t<< \"Stream 'Viewfinder' format set to \" << config.width << \"x\"\n> +\t\t<< config.height << \"- 0x\" << std::hex << std::setfill('0')\n> +\t\t<< std::setw(8) << config.pixelFormat;\n>  \n>  \treturn configs;\n>  }\n> @@ -243,7 +254,7 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,\n>  \t\t\t\t\t  std::map<Stream *, StreamConfiguration> &config)\n>  {\n>  \tIPU3CameraData *data = cameraData(camera);\n> -\tconst StreamConfiguration &cfg = config[&data->stream_];\n> +\tconst StreamConfiguration &cfg = config[&data->streams_[0]];\n\nThis patch is difficult to review, it only contains a partial\nimplementation. The code seems to go in the right direction, but in\ngeneral the series isn't bisectable. I'm not sure a squashed patch would\nbe more difficult to review...\n\n>  \tV4L2Device *viewfinder = data->imgu->viewfinder;\n>  \tV4L2Device *output = data->imgu->output;\n>  \tV4L2Device *input = data->imgu->input;\n> @@ -506,7 +517,7 @@ int PipelineHandlerIPU3::queueRequest(Camera *camera, Request *request)\n>  \tV4L2Device *viewfinder = data->imgu->viewfinder;\n>  \tV4L2Device *output = data->imgu->output;\n>  \tV4L2Device *stat = data->imgu->stat;\n> -\tStream *stream = &data->stream_;\n> +\tStream *stream = &data->streams_[0];\n>  \tBuffer *tmpBuffer;\n>  \n>  \t/*\n> @@ -1097,7 +1108,10 @@ void PipelineHandlerIPU3::registerCameras()\n>  \tfor (unsigned int id = 0; id < 4 && numCameras < 2; ++id) {\n>  \t\tstd::unique_ptr<IPU3CameraData> data =\n>  \t\t\tutils::make_unique<IPU3CameraData>(this);\n> -\t\tstd::set<Stream *> streams{ &data->stream_ };\n> +\t\tstd::set<Stream *> streams = {\n> +\t\t\t&data->streams_[IPU3_STREAM_OUTPUT],\n> +\t\t\t&data->streams_[IPU3_STREAM_VF],\n> +\t\t};\n>  \t\tCIO2Device *cio2 = &data->cio2;\n>  \t\tint ret;\n>","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 3A8CE610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Mar 2019 14:41:59 +0100 (CET)","from pendragon.ideasonboard.com\n\t(p5269001-ipngn11702marunouchi.tokyo.ocn.ne.jp [114.158.195.1])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F83A49;\n\tSat, 23 Mar 2019 14:41:57 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1553348518;\n\tbh=kGyHNfUVOn0QWNWTejfAK7zwFiObFBpl0HTeg6gaBTo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=PCInlpxRV9P/KVX/V8lTb5HefD7y9huVx0KpFRzANJbgXtpTCZzDK9AFsuxGmIxV4\n\t09PlU0akKQtk/MRhVbSkWc+oQ48Ir9G1NNAwQiYFdgXJKxJq6+51Jfv4RQVMYvLmu0\n\tSFCd/EFUnLD2bLJ/SisUCfZVsQmXE6X4kgXk9yLM=","Date":"Sat, 23 Mar 2019 15:41:46 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190323134146.GG4587@pendragon.ideasonboard.com>","References":"<20190320163055.22056-1-jacopo@jmondi.org>\n\t<20190320163055.22056-19-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190320163055.22056-19-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v4 18/31] libcamera: ipu3: Create\n\tcamera with 2 streams","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":"Sat, 23 Mar 2019 13:41:59 -0000"}}]