[{"id":10927,"web_url":"https://patchwork.libcamera.org/comment/10927/","msgid":"<20200628094556.GL6954@pendragon.ideasonboard.com>","date":"2020-06-28T09:45:56","subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: pipeline: simple: make\n\tsure the formats at the link's pads match","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Andrey,\n\nThank you for the patch.\n\nOn Tue, Apr 21, 2020 at 11:39:53PM +0300, Andrey Konovalov wrote:\n> Change SimpleCameraData::setupFormats() to return -EINVAL if the sink\n> pad of the link doesn't support the format set on the source pad of this\n> link.\n\nNote that there's at least one driver (omap3isp) that supports different\nformats on the two ends of a link (it's used at the input of the CCDC\nblock to model bits being dropped on the bus, for instance when\nconnecting D[9:2] of a 10-bit sensor to D[7:0] of the CCDC input). This\nis a bit of a hack and shouldn't be encouraged. The OMAP3 ISP would also\nneed its own pipeline handler anyway. I think your patch is thus fine.\n\n> Signed-off-by: Andrey Konovalov <andrey.konovalov@linaro.org>\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 12 ++++++++++++\n>  1 file changed, 12 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index b5f9177..8212bd9 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -372,6 +372,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format,\n>  \t\tMediaLink *link = e.link;\n>  \t\tMediaPad *source = link->source();\n>  \t\tMediaPad *sink = link->sink();\n> +\t\tV4L2SubdeviceFormat source_format;\n\ns/source_format/sourceFormat/\n\n>  \n>  \t\tif (source->entity() != sensor_->entity()) {\n>  \t\t\tV4L2Subdevice *subdev = pipe->subdev(source->entity());\n> @@ -380,11 +381,22 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format,\n>  \t\t\t\treturn ret;\n>  \t\t}\n>  \n> +\t\tsource_format = *format;\n\nYou can move this and the variable declaration within the if () below.\n\n>  \t\tif (sink->entity()->function() != MEDIA_ENT_F_IO_V4L) {\n>  \t\t\tV4L2Subdevice *subdev = pipe->subdev(sink->entity());\n>  \t\t\tret = subdev->setFormat(sink->index(), format, whence);\n>  \t\t\tif (ret < 0)\n>  \t\t\t\treturn ret;\n> +\n> +\t\t\tif (format->mbus_code != source_format.mbus_code\n> +\t\t\t    || format->size != source_format.size) {\n\nWe usually put the || at the end of the line.\n\n> +\t\t\t\tLOG(SimplePipeline, Debug)\n> +\t\t\t\t\t<< \"Source pad format isn't supported \"\n> +\t\t\t\t\t<< \"by the sink pad of the link: \"\n> +\t\t\t\t\t<< \"Source: \" << source_format.toString()\n> +\t\t\t\t\t<< \"Sink: \" << format->toString();\n\nIt could be useful to tell which link this is related to. How about\n\n\t\t\t\t\t<< \"Source '\" << source->entity()->name()\n\t\t\t\t\t<< \"':\" << source->index()\n\t\t\t\t\t<< \" produces \" << sourceFormat.toString()\n\t\t\t\t\t<< \", sink '\" << sink->entity()->name()\n\t\t\t\t\t<< \"':\" << sink->index()\n\t\t\t\t\t<< \" requires \" << format->toString();\n\nWith those changes,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nI can fix when applying if you're fine with this.\n\n> +\t\t\t\treturn -EINVAL;\n> +\t\t\t}\n>  \t\t}\n>  \n>  \t\tLOG(SimplePipeline, Debug)","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 82623C2E69\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 28 Jun 2020 09:46:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id ED2AB609C8;\n\tSun, 28 Jun 2020 11:46:00 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E23C603B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 28 Jun 2020 11:45:59 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BAE2A4FB;\n\tSun, 28 Jun 2020 11:45:58 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"BZF1Jk07\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593337558;\n\tbh=F6LwLPuDaO5gb2xXu8jKde+jnu90pBDqmsms7ZMlk/o=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=BZF1Jk07W2c1PW134nYRPiLZasppmgKFwCem2lNo5q+HP7vjdrIqtdmNnpMfEeES4\n\tE+yk2OCNIlbCszD9OxrXZNEfaqxB13xDmZb4eywPEG3kISV+dFbYcSCCgAeJWMTBhR\n\tCSBIcCs7beePz4toeeX4sLXxmEhYuu2tOzUmv9ik=","Date":"Sun, 28 Jun 2020 12:45:56 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Andrey Konovalov <andrey.konovalov@linaro.org>","Message-ID":"<20200628094556.GL6954@pendragon.ideasonboard.com>","References":"<20200421203954.15585-1-andrey.konovalov@linaro.org>\n\t<20200421203954.15585-2-andrey.konovalov@linaro.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200421203954.15585-2-andrey.konovalov@linaro.org>","Subject":"Re: [libcamera-devel] [PATCH 1/2] libcamera: pipeline: simple: make\n\tsure the formats at the link's pads match","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]