From patchwork Mon Feb 27 08:54:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattijs Korpershoek X-Patchwork-Id: 18309 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 13328BE08A for ; Mon, 27 Feb 2023 09:49:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 393FA62676; Mon, 27 Feb 2023 10:49:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1677491367; bh=GpQVOI8Sm5rf1HVtXTPCZteBN3nlTkIw7C0ZaSPrQCs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=QGh059hcnoAv7EclYzZmpfGhMOW2OnsxoEhYTxsDTfO5KW9kTYOK1a7V3nyOeYC4P UrDOS0YT+ROR9/e9SctlT1Pu5XgeY2sguBlVlb4u+Ti2bILdM1nCpm2BcdrPaCR2VG laBDf6Kp+CDv0L1EchAvvkEnbw+PNJqTszaFgAgprRgdwtPLTlKZCs4SqQ9AZsKTES OjF9A+lTslrLG3PYE7u7yL78syTmE6SkwcppAaZtMUledmug43Ki8AAFsgimiIdJHE 4wjFOnsPvJaXUAC9/0szdKPC3fKbKqFH3Am3owLQfJmhCkZCH07z5uXXF3RCc3RNcX lQESTo0yuHU6Q== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3CA4F603B2 for ; Mon, 27 Feb 2023 09:54:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="fnCcznX6"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so6516500wmb.5 for ; Mon, 27 Feb 2023 00:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=BcOJBX9WszM5q7bHGN8nZjRydRRzvnmWiBanyVRkc+g=; b=fnCcznX6gNxUHLZjvYKcheksYg+R7Y1X0tMBUfJFhP2I86wpw/oRmtA6mPOG44iRM2 kz5TZKwh4l5vjQzAlVa2LALze+WlpCtKkukjdbSR9LMUSHPuYd5jKBZ7tJhrVs6c9gxM rFumDOSQVD1RMsLhLVULGRhwArDo+G5RE81eV0SrxoOxnJrbqMNzl6JAoOhGO4MkHJdX wI91Iiy4wrTRDV/d8JQBbykP3+B3lyb2kd9F3YhB6J+YT3JPHtDbRTvbKLvjOJRGcGtS Nj1YrpITCfC4EMxBdFXKOR3SkcvUyU7167cfzLePmcLYBcmbFGxHuDD1mFejz8OEow45 T9SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BcOJBX9WszM5q7bHGN8nZjRydRRzvnmWiBanyVRkc+g=; b=2bDoCi+Wcg+bv32yZdJgJvmhCHqS9fNlMoe551kEdvXrmQuMwXr/penI3YBpohkA3l K1Fmn/6ZMR5MqZcDunL2KDCtbn4VnjKofIa73ketxi52r4aE5rh4kNWjg9iC3RZMW0b8 t9nhxkBIJ9BN9wjJpGw0xbZeT+mb6d4ltYSwqtQ3h8aav1Zl3GEog4ZaVRDBnPKK8dM0 UxcfQ52aO3HrqdaQHd/bqeqhJDdnpD7vyFuelpWuvn0lDTmNPpJ7m8qz2tz3T2XIJe1+ NLM1yqQRZQzLvgnkqC6nyNfvMAr4GW3JPwfCrxMw/4Zg/uLgD8RcfrjB9l6ZfD/do+Fp 3DWw== X-Gm-Message-State: AO0yUKXFP7pJ8a9CXsSRgwcUgs/mXwPVAQ2vM1DQNk8FhLBvZmIKgx6O //QaBSCb8xQ9ylrL5n9T5S/gmA== X-Google-Smtp-Source: AK7set8/LjMND7Bdhb2iSVZPc424TbqHU/CH1MvnXlzEQVMcN3JXGrXsGquoRShNKWYCiAQYs/mplg== X-Received: by 2002:a05:600c:90a:b0:3eb:2b88:a69a with SMTP id m10-20020a05600c090a00b003eb2b88a69amr6638113wmp.14.1677488049657; Mon, 27 Feb 2023 00:54:09 -0800 (PST) Received: from mkorpershoek-xps13.local ([2a01:cb19:85e6:1900:5f1e:d910:dd1e:5b09]) by smtp.gmail.com with ESMTPSA id d24-20020a1c7318000000b003dc522dd25esm8224632wmb.30.2023.02.27.00.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 00:54:09 -0800 (PST) Date: Mon, 27 Feb 2023 09:54:02 +0100 MIME-Version: 1.0 Message-Id: <20230227-android-gralloc-v1-1-3360fcfa7c0d@baylibre.com> X-B4-Tracking: v=1; b=H4sIAKlv/GMC/x2NywrCQAwAf6XkbGC79YVXwQ/wKh7STWwDdVcSE aH03916HIZhZnAxFYdTM4PJR11LrtBuGkgj5UFQuTLEELsQ4wEpsxVlHIymqSQMW+la3gmn/RF q1ZML9kY5jWv3JH+LreJl8tDvf3WD6+UM92X5AR9ilWJ/AAAA To: libcamera-devel@lists.libcamera.org X-Mailer: b4 0.12.1 X-Mailman-Approved-At: Mon, 27 Feb 2023 10:49:26 +0100 Subject: [libcamera-devel] [PATCH RFC] android: mm: generic: use GRALLOC_HARDWARE_MODULE_ID 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: Mattijs Korpershoek via libcamera-devel From: Mattijs Korpershoek Reply-To: Mattijs Korpershoek Cc: Mattijs Korpershoek Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" PlatformFrameBufferAllocator is an abstraction over gralloc. Right now hardwareModule_ points towards a CAMERA_HARDWARE_MODULE_ID. When gralloc_open() is called we observe: libcamera: DEBUG HAL camera3_hal.cpp:75 Open camera gpu0 libcamera: ERROR Camera camera.cpp:524 Camera in Configured state trying acquire() requiring state Available 01-23 14:14:04.742 370 416 E libcamera: FATAL HAL generic_frame_buffer_allocator.cpp:105 gralloc_open() failed: -87 Which is wrong, gralloc_open() is attempting to re-open the camera HAL, instead of the gralloc HAL. Point to a GRALLOC_HARDWARE_MODULE_ID instead so that we can request buffers from gralloc in android. Note: this add a new dependency on android's libhardware [1] [1] https://android.googlesource.com/platform/hardware/libhardware Fixes: c58662c5770e ("android: Introduce PlatformFrameBufferAllocator") Signed-off-by: Mattijs Korpershoek --- RFC as this adds an additional link-time dependency on an AOSP project (libhardware) and I'm unsure how to handle this. I thought of using the subprojects structure as done for libyuv but since libhardware has other AOSP deps (like libvnksupport) I'm not sure this is appropriate. Any thoughts on this? --- src/android/mm/generic_frame_buffer_allocator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- base-commit: 58e0b6e18c425072a47594f42fc0b61801403aca change-id: 20230227-android-gralloc-04e31d5edc68 Best regards, diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp index 3750e1bf52a9..58e6c68c4998 100644 --- a/src/android/mm/generic_frame_buffer_allocator.cpp +++ b/src/android/mm/generic_frame_buffer_allocator.cpp @@ -72,9 +72,10 @@ class PlatformFrameBufferAllocator::Private : public Extensible::Private public: Private(CameraDevice *const cameraDevice) : cameraDevice_(cameraDevice), - hardwareModule_(cameraDevice->camera3Device()->common.module), + hardwareModule_(nullptr), allocDevice_(nullptr) { + hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hardwareModule_); ASSERT(hardwareModule_); } @@ -85,7 +86,7 @@ public: private: const CameraDevice *const cameraDevice_; - struct hw_module_t *const hardwareModule_; + const struct hw_module_t *hardwareModule_; struct alloc_device_t *allocDevice_; };