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) From patchwork Tue Apr 21 20:39:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 3506 Return-Path: Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BFAB462E67 for ; Tue, 21 Apr 2020 22:40:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WgZKmtnS"; dkim-atps=neutral Received: by mail-lf1-x142.google.com with SMTP id x23so12232885lfq.1 for ; Tue, 21 Apr 2020 13:40:15 -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=Km8odjCrSkpyc4WjaccZ2TZziaQHbv4cKBm5v4L6khc=; b=WgZKmtnSQcz72xytlB4WAVjzocijojULiEnS0b0fnxkzMvsIEn5WtEfonCrufxzVgm 888icIIVPszySHZclPL/DOZcWi/tqydYF7uKpchGmSESWZLsoZexSa5/praIEoWpA/GX zI2QGoncBjCkr5nWSUL/zOWmpkgY21VyLlYg7g8ckR6CC0k+dCKYiKQ5zzb9NMKLSNGF pgyzT8Ml/pbyuUSw7Es8QZcYHF0KdwssklW6NXlec1G/Hl/8IMvBqCT0jzJ+sIo/x0oK 6vQ1Z649dpTKrG9E9SDdaSlMAMzCGdYKW4LHC0x/qk104manN2o2k5wkVTgEI9JusyZA sNuA== 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=Km8odjCrSkpyc4WjaccZ2TZziaQHbv4cKBm5v4L6khc=; b=m/MMoxf4iUzlKcicFpLILkRVwAjjPya0B5nKyWviM4x0F5Pnj5md/kVGCbKNXHMRlo uWOk4mCRCir9VWQw1IcL0Ay+B7vYQ8Hm8uMm9y0MSSr6tzY8wfHxAu1bVI7nYxqp98CY +oo2FA1ci9EBPqunOsNHfts0cbOsTs9DcmM3Frxom8ZS6UvZlRxO8EG2Lm/cxWE0OqIO kQcKZRt3RAJZaEOU3kVIYB0DPsiwENOhAf0ObE2bpARcsNd7ysJSgjF5eCpM8KwCwS2D knQywezHbsSu+kIBwHrahRyiFYoSh0yiXlSGtBXAPjggCyoAaduvWD2Xbf60kRu1kb/+ 9oiQ== X-Gm-Message-State: AGi0PuaE2SQXJ89yeDDYhgFRr2f9TIS89SKyw2r5eg5dTQDF8SHDodWq mJYf89mI4vGfn8sC/O0BgPgiROGp6XI= X-Google-Smtp-Source: APiQypKZBEI3mKPkRYIeZo3j22Dg/myA3KUVUVMKApHORjnLdJvRKWEIVZyGrJAE3ca20hVtyeZe0Q== X-Received: by 2002:a19:f614:: with SMTP id x20mr14806309lfe.84.1587501614791; Tue, 21 Apr 2020 13:40:14 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Apr 2020 13:40:14 -0700 (PDT) From: Andrey Konovalov To: libcamera-devel@lists.libcamera.org Date: Tue, 21 Apr 2020 23:39:54 +0300 Message-Id: <20200421203954.15585-3-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 2/2] libcamera: pipeline: simple: try next mbus code if setupFormats() fails 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:16 -0000 Now SimpleCameraData::setupFormats() can fail if the camera sensor supports media bus code which some entities down the pipeline don't. When this happens continue with the next media bus code instead of aborting the enumeration of the possible pipeline configurations. Signed-off-by: Andrey Konovalov Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/simple/simple.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 8212bd9..1a31e18 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -265,10 +265,11 @@ int SimpleCameraData::init() ret = setupFormats(&format, V4L2Subdevice::TryFormat); if (ret < 0) { - LOG(SimplePipeline, Error) + LOG(SimplePipeline, Warning) << "Failed to setup pipeline for media bus code " << utils::hex(code, 4); - return ret; + /* Try next mbus_code supported by the sensor */ + continue; } std::map> videoFormats =