From patchwork Tue Aug 27 16:42:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 21044 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 DB5BAC323E for ; Tue, 27 Aug 2024 16:43:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFC4563469; Tue, 27 Aug 2024 18:43:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="IxOIM3Mi"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D23816345D for ; Tue, 27 Aug 2024 18:43:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724776987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=eB7JnFQ/nUQiKmDHODaZCQNZUgBBa50sREzFZZPS2Ag=; b=IxOIM3MiNurqRfD2JKgTXD/kQq6/eGYCIgpbOBVbj6QTBZO+pAF28EVlr1mlAAZZXsClUZ VTFGhIrUB9Fne5dHvuqlF7Dlybxhkw+4KggLHcj5dtrLPpO7v/euM256ldTNxYFCzSHn7D LtBhFEcGrwSHfUKyZJm9oRVoUwzyEY0= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-IfSBOt3XMSKk9oUMhuQPuQ-1; Tue, 27 Aug 2024 12:43:06 -0400 X-MC-Unique: IfSBOt3XMSKk9oUMhuQPuQ-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 67F831955D4D for ; Tue, 27 Aug 2024 16:43:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.192.136]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 16E741955D89; Tue, 27 Aug 2024 16:43:03 +0000 (UTC) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Maxime Ripard , Hans de Goede Subject: [PATCH v2 0/3] Fix uvcvideo pipelinehandler keeping /dev/video# open Date: Tue, 27 Aug 2024 18:42:52 +0200 Message-ID: <20240827164255.314432-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi all, The uvcvideo pipeline handler always keeps the uvcvideo /dev/video# device for a pipeline open after enumerating the camera. This is a problem for uvcvideo, as keeping the /dev/video# node open stops the underlying USB device and the USB bus controller from being able to enter runtime-suspend causing significant unnecessary power-usage. Here is v2 of my series making the uvcvideo pipeline handler open /dev/video# on acquire and close it on release to fix this. Changes in v2: - Drop the first 2 patches these have already been merged - Add a note to both the doxygen documentation as well as to the commit messages that opening/closing /dev/video# from acquire()/release() as done by the uvcvideo pipeline handler is an exception and that this behavior should not be copied by other pipeline handlers - Other doxygen doc fixes / improvements - Only unlock media devices on acquireDevice() failure if useCount_ == 0 - Drop PipelineHandler::lock_, update "\context" in doxygen docs I've pushed this to the software-isp gitlab repo for CI: https://gitlab.freedesktop.org/camera/libcamera-softisp/-/commits/pipeline-acquireDevice-v2 and it has passed CI. Regards, Hans Hans de Goede (3): pipeline_handler: Add acquireDevice() method to mirror existing releaseDevice() camera: Use invokeMethod() for pipe_->acquire() and pipe_->release() uvcvideo: Implement acquireDevice() + releaseDevice() include/libcamera/internal/pipeline_handler.h | 8 +-- src/libcamera/camera.cpp | 6 +- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 45 ++++++++++++++ src/libcamera/pipeline_handler.cpp | 60 ++++++++++++++----- 4 files changed, 98 insertions(+), 21 deletions(-)