Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 644676a5 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

camera: Add support for toggling HAL buffer manager as a result of session configuration



Currently, whether the HAL buffer manager is used or not is decided
based on the presence of a static camera characteristics key -
ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION. This behavior cannot
be toggled depending on stream configuration / session parameters.

The HAL buffer manager does reduce memory consumption at the cost of
extra IPC calls, which may not be always desirable.

Therefore, a new API - 'configureStreamsV2()' is introduced to give the
camera HAL the ability to inform the camera framework whether it must
use the HAL buffer manager for the particular session configured.

Bug: 311263114

Test: VtsAidlHalCameraProvider_TargetTest on cuttlefish
Test: builds

Change-Id: Ibce6d64c3c9cc8e0ebc40522369291d03053cce2
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 80a60c0f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ aidl_interface {
    name: "android.hardware.camera.device",
    vendor_available: true,
    srcs: ["android/hardware/camera/device/*.aidl"],
    frozen: true,
    frozen: false,
    stability: "vintf",
    imports: [
        "android.hardware.common-V2",
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.camera.device;
@VintfStability
parcelable ConfigureStreamsRet {
  android.hardware.camera.device.HalStream[] halStreams;
  boolean enableHalBufferManager = false;
}
+1 −0
Original line number Diff line number Diff line
@@ -45,4 +45,5 @@ interface ICameraDeviceSession {
  oneway void signalStreamFlush(in int[] streamIds, in int streamConfigCounter);
  android.hardware.camera.device.ICameraOfflineSession switchToOffline(in int[] streamsToKeep, out android.hardware.camera.device.CameraOfflineSessionInfo offlineSessionInfo);
  void repeatingRequestEnd(in int frameNumber, in int[] streamIds);
  android.hardware.camera.device.ConfigureStreamsRet configureStreamsV2(in android.hardware.camera.device.StreamConfiguration requestedConfiguration);
}
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.camera.device;

import android.hardware.camera.device.HalStream;

/**
 * ConfigureStreamsRet.
 *
 * Parcelable returned by the 'configureStreamsV2' call.
 * This contains information which informs the camera framework
 * about properties of each stream configured and also whether the
 * the hal buffer manager must be used for the session configured.
 */
@VintfStability
parcelable ConfigureStreamsRet {
    /**
     * A vector of HalStream Parcelables, which contain information
     * about the stream parameters desired by the HAL such as usage flags,
     * overridden format, maximum buffers etc.
     */
    HalStream[] halStreams;
    /**
     * A boolean informing the camera framework whether the HAL buffer manager
     * must be used for the session configured.
     */
    boolean enableHalBufferManager = false;
}
+35 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.hardware.camera.device.BufferCache;
import android.hardware.camera.device.CameraMetadata;
import android.hardware.camera.device.CameraOfflineSessionInfo;
import android.hardware.camera.device.CaptureRequest;
import android.hardware.camera.device.ConfigureStreamsRet;
import android.hardware.camera.device.HalStream;
import android.hardware.camera.device.ICameraOfflineSession;
import android.hardware.camera.device.RequestTemplate;
@@ -88,6 +89,13 @@ interface ICameraDeviceSession {
     * with processCaptureResult (and its respective releaseFence has been
     * signaled) the framework may free or reuse it at any time.
     *
     * This method wil only be called by the framework if
     * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION is either not advertised or is
     * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_AIDL. If the value of
     * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION is
     * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE, configureStreamsV2
     * will be called instead.
     *
     * ------------------------------------------------------------------------
     *
     * Preconditions:
@@ -386,8 +394,8 @@ interface ICameraDeviceSession {
     *          error.
     * @return true in case the stream reconfiguration is required, false otherwise.
     */
    boolean isReconfigurationRequired(in CameraMetadata oldSessionParams,
                                      in CameraMetadata newSessionParams);
    boolean isReconfigurationRequired(
            in CameraMetadata oldSessionParams, in CameraMetadata newSessionParams);

    /**
     * processCaptureRequest:
@@ -576,4 +584,29 @@ interface ICameraDeviceSession {
     */
    void repeatingRequestEnd(in int frameNumber, in int[] streamIds);

    /**
     *
     * configureStreamsV2:
     *
     * Performs the same function as 'configureStreams'. This function returns a
     * 'ConfigureStreamsRet' Parcelable. This tells the framework about the desired stream
     * parameters such as usage flags, maximum buffers, overridden format etc. It also informs
     * camera framework whether the HAL will use the HAL buffer manager APIs 'requestStreamBuffers'
     * and 'returnStreamBuffers' to request and return buffers to the framework.
     *
     * This method is only supported if
     * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION is
     * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_SESSION_CONFIGURABLE. It must not be
     * called by the camera framework if it isn't supported. That is, the framework will only
     * ever call one of 'configureStreams' or 'configureStreamsV2' depending on the value of
     * ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION.
     *
     * @param requestedConfiguration The stream configuration requested by the camera framework to
     *        be configured by the camera HAL.
     * @return A ConfigureStreamsRet Parcelable containing a vector of HalStreams and a boolean
     *         specifying whether the HAL buffer manager must be used for this session
     *         configuration.
     *
     */
    ConfigureStreamsRet configureStreamsV2(in StreamConfiguration requestedConfiguration);
}
Loading