From patchwork Tue Apr 21 20:39:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 3505 Return-Path: Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1295C62E5D for ; Tue, 21 Apr 2020 22:40:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="PqfAQpxh"; dkim-atps=neutral Received: by mail-lf1-x141.google.com with SMTP id h6so12252519lfc.0 for ; Tue, 21 Apr 2020 13:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Jp8I93rfYbbgqNsWDUtvye4rtb6PlZHefKLZKxV+ZFI=; b=PqfAQpxhlqqQZxshqgP77mXYdkyhlEe1Ly0JLeTH6qe9KZFXBmxJE544O3sZn5rGfQ Df2wnBAcIMfdYQXgZSqMiWOG21yTVdBtXI2iGRl5+zEDeruX2m1uH4A/0T89SiR5AnZb z100iQa60wTnDXdN5U3wmWIUFeTy/tNbRT4Y+9J3hqdIOLBe/r6uPFd/ZweAp5tjCM7P Ccvsv4M4vLz6NsjnuImD8F3fj7L+FSBMR0n7QhXq2AP9b4n1aF2sEf0J3ECcQfHHFt1c qxZnO3PChqLrxfKDQ+8k9guW+7G70f0C7sqWUN+G7ce/rd2BgpAvDklgpTBpbL/KS5Np DVjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Jp8I93rfYbbgqNsWDUtvye4rtb6PlZHefKLZKxV+ZFI=; b=NVOgUx2KIvrd5VEYtbBVbBFydSIYJOQjZ5JRG0J7JBFg3W0KMMHUCivV/P+662QJwf Jr9NjHLPMIDY1aaFZKn899QalBtOhivBnHB+o3pdxSOZsoFmJSdtDqTzVp0KW+9kiych 1wehoHbLWwdY39DCUtF3CGuwmwMMzSeEKxRbHIYu3aMGo2xJvoOQck1xlA/FRwwVY0/b JW/JNVI8ywjFAJ5P2QfYhHDudBCCAAMLuqBEfPCbe70Dl/PrjAnDNEzy++MVI0S4LUJx +m2nTZ+eXeQQd4qOX5m/XbcpjHJHWOp7JWfZ1jMaWcXnRAySVRiqWtmK3VpeqZeAqnCH VKQA== X-Gm-Message-State: AGi0PuaGJU1XeBVyx2/3BM3Q2UBCTw6aQJyxJh1Ew33mc74rvnzVthO9 /ecv499GbAugNUrj8PTwYHZOdCexfzY= X-Google-Smtp-Source: APiQypIHJ9KByf+3+AeDpycG2zQaXlvRb66eX6evb1q5YlBOf5cp3gsbT2nRWRAw5e+c4kzibFcjeQ== X-Received: by 2002:a05:6512:3189:: with SMTP id i9mr14894381lfe.178.1587501613032; Tue, 21 Apr 2020 13:40:13 -0700 (PDT) Received: from localhost.localdomain (37-144-159-139.broadband.corbina.ru. [37.144.159.139]) by smtp.googlemail.com with ESMTPSA id g6sm476176ljj.78.2020.04.21.13.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 13:40:12 -0700 (PDT) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Apr 2020 23:39:53 +0300 Message-Id: <20200421203954.15585-2-andrey.konovalov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421203954.15585-1-andrey.konovalov@linaro.org> References: <20200421203954.15585-1-andrey.konovalov@linaro.org> Subject: [libcamera-devel] [PATCH 1/2] libcamera: pipeline: simple: make sure 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Apr 2020 20:40:14 -0000 Change SimpleCameraData::setupFormats() to return -EINVAL if the sink pad of the link doesn't support the format set on the source pad of this link. Signed-off-by: Andrey Konovalov Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index b5f9177..8212bd9 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -372,6 +372,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, MediaLink *link = e.link; MediaPad *source = link->source(); MediaPad *sink = link->sink(); + V4L2SubdeviceFormat source_format; if (source->entity() != sensor_->entity()) { V4L2Subdevice *subdev = pipe->subdev(source->entity()); @@ -380,11 +381,22 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format, return ret; } + source_format = *format; if (sink->entity()->function() != MEDIA_ENT_F_IO_V4L) { V4L2Subdevice *subdev = pipe->subdev(sink->entity()); ret = subdev->setFormat(sink->index(), format, whence); if (ret < 0) return ret; + + if (format->mbus_code != source_format.mbus_code + || format->size != source_format.size) { + LOG(SimplePipeline, Debug) + << "Source pad format isn't supported " + << "by the sink pad of the link: " + << "Source: " << source_format.toString() + << "Sink: " << format->toString(); + return -EINVAL; + } } LOG(SimplePipeline, Debug)