[{"id":4883,"web_url":"https://patchwork.libcamera.org/comment/4883/","msgid":"<20200522005544.GA2165767@oden.dyn.berto.se>","date":"2020-05-22T00:55:44","subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: pipeline: simple:\n\tAdd stride support","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-05-19 19:55:41 +0300, Laurent Pinchart wrote:\n> Report the stride when configuring the camera. The stride is retrieved\n> from the capture device first, and overridden by the converter if used.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/pipeline/simple/converter.cpp | 13 ++++++++-----\n>  src/libcamera/pipeline/simple/converter.h   |  4 ++--\n>  src/libcamera/pipeline/simple/simple.cpp    |  5 +++--\n>  3 files changed, 13 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> index 02443e7f78ed..7a9d67b37624 100644\n> --- a/src/libcamera/pipeline/simple/converter.cpp\n> +++ b/src/libcamera/pipeline/simple/converter.cpp\n> @@ -12,6 +12,7 @@\n>  #include <libcamera/buffer.h>\n>  #include <libcamera/geometry.h>\n>  #include <libcamera/signal.h>\n> +#include <libcamera/stream.h>\n>  \n>  #include \"libcamera/internal/log.h\"\n>  #include \"libcamera/internal/media_device.h\"\n> @@ -93,14 +94,14 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n>  }\n>  \n>  int SimpleConverter::configure(PixelFormat inputFormat,\n> -\t\t\t       PixelFormat outputFormat, const Size &size)\n> +\t\t\t       StreamConfiguration *cfg)\n>  {\n>  \tV4L2DeviceFormat format;\n>  \tint ret;\n>  \n>  \tV4L2PixelFormat videoFormat = m2m_->output()->toV4L2PixelFormat(inputFormat);\n>  \tformat.fourcc = videoFormat;\n> -\tformat.size = size;\n> +\tformat.size = cfg->size;\n>  \n>  \tret = m2m_->output()->setFormat(&format);\n>  \tif (ret < 0) {\n> @@ -109,7 +110,7 @@ int SimpleConverter::configure(PixelFormat inputFormat,\n>  \t\treturn ret;\n>  \t}\n>  \n> -\tif (format.fourcc != videoFormat || format.size != size) {\n> +\tif (format.fourcc != videoFormat || format.size != cfg->size) {\n>  \t\tLOG(SimplePipeline, Error)\n>  \t\t\t<< \"Input format not supported\";\n>  \t\treturn -EINVAL;\n> @@ -119,7 +120,7 @@ int SimpleConverter::configure(PixelFormat inputFormat,\n>  \t * Set the pixel format on the output, the size is identical to the\n>  \t * input as we don't support scaling.\n>  \t */\n> -\tvideoFormat = m2m_->capture()->toV4L2PixelFormat(outputFormat);\n> +\tvideoFormat = m2m_->capture()->toV4L2PixelFormat(cfg->pixelFormat);\n>  \tformat.fourcc = videoFormat;\n>  \n>  \tret = m2m_->capture()->setFormat(&format);\n> @@ -129,12 +130,14 @@ int SimpleConverter::configure(PixelFormat inputFormat,\n>  \t\treturn ret;\n>  \t}\n>  \n> -\tif (format.fourcc != videoFormat || format.size != size) {\n> +\tif (format.fourcc != videoFormat || format.size != cfg->size) {\n>  \t\tLOG(SimplePipeline, Error)\n>  \t\t\t<< \"Output format not supported\";\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> +\tcfg->stride = format.planes[0].bpl;\n> +\n>  \treturn 0;\n>  }\n>  \n> diff --git a/src/libcamera/pipeline/simple/converter.h b/src/libcamera/pipeline/simple/converter.h\n> index a33071fa8578..0beb96a55d5b 100644\n> --- a/src/libcamera/pipeline/simple/converter.h\n> +++ b/src/libcamera/pipeline/simple/converter.h\n> @@ -20,6 +20,7 @@ namespace libcamera {\n>  class FrameBuffer;\n>  class MediaDevice;\n>  struct Size;\n> +struct StreamConfiguration;\n>  class V4L2M2MDevice;\n>  \n>  class SimpleConverter\n> @@ -33,8 +34,7 @@ public:\n>  \n>  \tstd::vector<PixelFormat> formats(PixelFormat input);\n>  \n> -\tint configure(PixelFormat inputFormat, PixelFormat outputFormat,\n> -\t\t      const Size &size);\n> +\tint configure(PixelFormat inputFormat, StreamConfiguration *cfg);\n>  \tint exportBuffers(unsigned int count,\n>  \t\t\t  std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n>  \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 2565190082c8..68595bc29726 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -549,12 +549,13 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n>  \t\treturn -EINVAL;\n>  \t}\n>  \n> +\tcfg.stride = captureFormat.planes[0].bpl;\n> +\n>  \t/* Configure the converter if required. */\n>  \tuseConverter_ = config->needConversion();\n>  \n>  \tif (useConverter_) {\n> -\t\tint ret = converter_->configure(pipeConfig.pixelFormat,\n> -\t\t\t\t\t\tcfg.pixelFormat, cfg.size);\n> +\t\tint ret = converter_->configure(pipeConfig.pixelFormat, &cfg);\n>  \t\tif (ret < 0) {\n>  \t\t\tLOG(SimplePipeline, Error)\n>  \t\t\t\t<< \"Unable to configure converter\";\n> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x236.google.com (mail-lj1-x236.google.com\n\t[IPv6:2a00:1450:4864:20::236])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 81A90603D3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 May 2020 02:55:47 +0200 (CEST)","by mail-lj1-x236.google.com with SMTP id w10so10659268ljo.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 May 2020 17:55:47 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\th8sm734168ljg.28.2020.05.21.17.55.45\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 21 May 2020 17:55:45 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"Wm46+Npi\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=auPbjUp+EAUSRt09HQbV2oQ+5QSb0Solaha4V8jjsUU=;\n\tb=Wm46+NpiBRE3r+kQiJqCfanaIgjEzQLXdMB+4Azn4iMBLof+gRCkZSzM3WU8ick4ml\n\t35p1fp3sM/cydxDjocA6Nm588c000+JJqZRgD1CE/NdMl3ORa6gXoEqVs9WZBzthTpLQ\n\tXbAyKy45DFh4pi/u56wjnveS9fVmfe17yQ2y3pegXqMVp/h0TPeJRXcUS+dcpnzxB+HG\n\tFHuN1IlwvBzdiop+AEiEB6NEcVD2b2fjBcLkN16niRlWL8erF6WHv9UzAJWHc/bYpVzN\n\thBuQzjka3E95yOj+Bv+7h/BtTh/fXKR3B+yY3dkpbOFKWPwfHZ1bgKAjntOR5HJRduAz\n\tpzvQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=auPbjUp+EAUSRt09HQbV2oQ+5QSb0Solaha4V8jjsUU=;\n\tb=qIJGSkQcrV0kQ2ePMZdAoWfNzfWedPV7ZH6BMLpxbqeLaRv9EDlGpPzUI9HnnaTVBW\n\tWT8x9oUyHiqtTfBswiqSykGU1h8ZuoLR7E8MWEKwFyE1sFHZqylJTG7/Ad0+4csZcnpN\n\t+dEeeoAT0YH24aAxkhlU33CBv2X+cT09LK8jamefuXicf6CAF/3ZCxk12uNPwIT7tY7N\n\tRCDc4G4RJD7sLWujtUP2UJA6g8PP4fD3u2zrNy8U0fAElQqCXPasJZk3jcsbyzUZZX0L\n\ti9LB87w5QP5fp/jfpoZOXPQj427qian3TCGL9hGHdJtQNKcdW6Fduq9fbGwEaRBUK5F0\n\tCN3g==","X-Gm-Message-State":"AOAM5316WAbr6GsyW2V3bKc4SjP121igIsD37LzLSZ1sh01f0/bG+bLu\n\t/fYXPfEDPGkjDd2fDZ74VBc0mWAQ8DiP9w==","X-Google-Smtp-Source":"ABdhPJz0328/UAmQGH8/J6rMLn022/+U+DreIEI3reKh5iVF2ieW9874ziHz2qr5qLJ1JEcYZLnzng==","X-Received":"by 2002:a05:651c:1067:: with SMTP id\n\ty7mr3980952ljm.372.1590108946546; \n\tThu, 21 May 2020 17:55:46 -0700 (PDT)","Date":"Fri, 22 May 2020 02:55:44 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200522005544.GA2165767@oden.dyn.berto.se>","References":"<20200519165543.30465-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200519165543.30465-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 1/3] libcamera: pipeline: simple:\n\tAdd stride support","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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":"Fri, 22 May 2020 00:55:47 -0000"}}]