From patchwork Tue Aug 8 12:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 18936 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 15CF2C32B3 for ; Tue, 8 Aug 2023 12:52:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 82470627F6; Tue, 8 Aug 2023 14:52:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1691499179; bh=bVaPL/jKTBsyEmGOyaB8CwG8+poD9A6OtASWtadqCw4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=mi7Ff+/HW1hj/q+GqByY1rtKLLblV0zBGRneP4NcSB2wlAGfG0wZPXAIbXQCKEA0Y tb3/BAX8yH6WDea9F8x0N65r0/22TfLaQOxjDh+QgX5Tf34cIDAzZDHBYgum68ezBo gKXaEP6rMslRNcZpiaFzWZV5EGAucpISbMO/0TVkiEkoD1cGrjwPxdO104lsjK3E7r ClJsHcu84FdVGU3KXeFX+GZb4ac1EL+DC7E/KuTXI3hoqvhIX+CpXCrhDZcGz1Yg6L v0nr31XxUROHt4ZAlzneU4P41M+jbGGoW954GqijxFMSf1IZZG8lDBjdQdXVzokzwE ax83mZHlZkvXA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BCD49627F0 for ; Tue, 8 Aug 2023 14:52:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WMy/mt9Q"; dkim-atps=neutral Received: from uno.localdomain (mob-5-90-60-22.net.vodafone.it [5.90.60.22]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CC15B87CC; Tue, 8 Aug 2023 14:51:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1691499104; bh=bVaPL/jKTBsyEmGOyaB8CwG8+poD9A6OtASWtadqCw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WMy/mt9Q0VIC2pwET4rg3CDLAq6DxE9D8cPbwGJQjreeQ3v9Ona+QjJs06XP5Wlg3 lV5zsgSxqUWikZ+XL/tys0YhrcXUuD5LKS+Ap+1UF6RykvG2ve+puOrVUVMRpJEeRw cTK16uq2nObX0F0TBky2nIqyFwVxWqEuH+3X/rdg= To: libcamera-devel@lists.libcamera.org, Sophie Friedrich Date: Tue, 8 Aug 2023 14:52:28 +0200 Message-Id: <20230808125228.29043-10-jacopo.mondi@ideasonboard.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230808125228.29043-1-jacopo.mondi@ideasonboard.com> References: <20230808125228.29043-1-jacopo.mondi@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 9/9] [HACK] libcamera: pipeline: Add usb-test pipeline 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-Patchwork-Original-From: Jacopo Mondi via libcamera-devel From: Jacopo Mondi Reply-To: Jacopo Mondi Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a test pipeline to match on a USBDevice. This is a proof of concept as the pipeline handler matches on my mouse VID/PID pair. Signed-off-by: Jacopo Mondi --- meson_options.txt | 1 + src/libcamera/pipeline/usb-test/meson.build | 5 ++ src/libcamera/pipeline/usb-test/usb_test.cpp | 93 ++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/libcamera/pipeline/usb-test/meson.build create mode 100644 src/libcamera/pipeline/usb-test/usb_test.cpp diff --git a/meson_options.txt b/meson_options.txt index fad928af4b62..e706484be109 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -46,6 +46,7 @@ option('pipelines', 'rkisp1', 'rpi/vc4', 'simple', + 'usb-test', 'uvcvideo', 'vimc' ], diff --git a/src/libcamera/pipeline/usb-test/meson.build b/src/libcamera/pipeline/usb-test/meson.build new file mode 100644 index 000000000000..bafff18e7b0b --- /dev/null +++ b/src/libcamera/pipeline/usb-test/meson.build @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: CC0-1.0 + +libcamera_sources += files([ + 'usb_test.cpp', +]) diff --git a/src/libcamera/pipeline/usb-test/usb_test.cpp b/src/libcamera/pipeline/usb-test/usb_test.cpp new file mode 100644 index 000000000000..5df1a137f81f --- /dev/null +++ b/src/libcamera/pipeline/usb-test/usb_test.cpp @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2023, Ideas On Board Oy + * + * usb_test.cpp - Test USB device matching + */ + +#include + +#include +#include + +#include "libcamera/internal/camera.h" +#include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/usb_device.h" + +namespace libcamera { + +LOG_DEFINE_CATEGORY(USBTest) + +class USBCameraData : public Camera::Private +{ +public: + USBCameraData(PipelineHandler *pipe) + : Camera::Private(pipe) + { + } + + Stream stream_; +}; + +class PipelineHandlerUSB : public PipelineHandler +{ +public: + PipelineHandlerUSB(CameraManager *manager) + : PipelineHandler(manager) + { + } + + std::unique_ptr generateConfiguration([[maybe_unused]] Camera *camera, + [[maybe_unused]] Span roles) override + { + return {}; + } + int configure([[maybe_unused]] Camera *camera, [[maybe_unused]] CameraConfiguration *config) override + { + return 0; + } + + int exportFrameBuffers([[maybe_unused]] Camera *camera, [[maybe_unused]] Stream *stream, + [[maybe_unused]] std::vector> *buffers) override + { + return 0; + } + + int start([[maybe_unused]] Camera *camera, [[maybe_unused]] const ControlList *controls) override + { + return 0; + } + void stopDevice([[maybe_unused]] Camera *camera) override + { + } + + int queueRequestDevice([[maybe_unused]] Camera *camera, [[maybe_unused]] Request *request) override + { + return 0; + } + + bool match(DeviceEnumerator *enumerator) override; +}; + +bool PipelineHandlerUSB::match(DeviceEnumerator *enumerator) +{ + USBDeviceMatch dm("046d", "c52b"); + USBDevice *usbDev = acquireUSBDevice(enumerator, dm); + if (!usbDev) + return false; + + std::unique_ptr data = std::make_unique(this); + std::string id = usbDev->vid() + "/" + usbDev->pid(); + std::set streams{ &data->stream_ }; + + std::shared_ptr camera = + Camera::create(std::move(data), id, streams); + registerCamera(std::move(camera)); + + return true; +} + +REGISTER_PIPELINE_HANDLER(PipelineHandlerUSB) + +} /* namespace libcamera */