From patchwork Fri Aug 30 11:12:04 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: 21075 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 13407C324C for ; Fri, 30 Aug 2024 11:12:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B6ED863466; Fri, 30 Aug 2024 13:12:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="MRWp0mIq"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B8CC61E4A for ; Fri, 30 Aug 2024 13:12:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725016337; 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=4W7ZThR/dyiUIbE2HsTpMHCQFFk/uOGVEopPUEpRKPE=; b=MRWp0mIqOBwEft13vi9S2yh3GlATPlDNKG15IJgOm4t+siPRPUa26Dm/471bA8yiHeCLfZ SvQzakjtMfiKleh1Uh1BwvWSokNxzPpYAtLIoelx4bfl/MNqKAuK+vsKCaCAQjAOoRRS6W +4pbOZ6mJ1CboL3DAZH67f75VLt5Tvs= Received: from mx-prod-mc-01.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-408-8oAO3IrbN36m_yIbvOvyDg-1; Fri, 30 Aug 2024 07:12:16 -0400 X-MC-Unique: 8oAO3IrbN36m_yIbvOvyDg-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32C211954B07 for ; Fri, 30 Aug 2024 11:12:15 +0000 (UTC) Received: from localhost.localdomain (unknown [10.39.193.217]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 99E8B1955F1B; Fri, 30 Aug 2024 11:12:13 +0000 (UTC) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Maxime Ripard , Hans de Goede Subject: [PATCH v3 0/3] Fix uvcvideo pipelinehandler keeping /dev/video# open Date: Fri, 30 Aug 2024 13:12:04 +0200 Message-ID: <20240830111207.46455-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 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 v3 of my series making the uvcvideo pipeline handler open /dev/video# on acquire and close it on release to fix this. Changes in v3: - s/method/function/ in commit msg - Put MutexLocker locker(data_->openLock_); in a { } context to reduce the time the lock is held to the minimum time necessary - Add Reviewed-by-s 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 *** BLURB HERE *** Hans de Goede (3): pipeline_handler: Add acquireDevice() function 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 | 54 ++++++++++++++++- src/libcamera/pipeline_handler.cpp | 60 ++++++++++++++----- 4 files changed, 104 insertions(+), 24 deletions(-)