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

Commit d750d90d authored by Emilian Peev's avatar Emilian Peev Committed by Android (Google) Code Review
Browse files

Merge "Camera: Add device 3.8 and HDR10 native APIs"

parents d3c23b0a b5f634fc
Loading
Loading
Loading
Loading
+65 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ namespace helper {
using aidl::android::hardware::graphics::common::PlaneLayout;
using aidl::android::hardware::graphics::common::PlaneLayoutComponent;
using aidl::android::hardware::graphics::common::PlaneLayoutComponentType;
using MetadataType = android::hardware::graphics::mapper::V4_0::IMapper::MetadataType;
using MapperErrorV2 = android::hardware::graphics::mapper::V2_0::Error;
using MapperErrorV3 = android::hardware::graphics::mapper::V3_0::Error;
using MapperErrorV4 = android::hardware::graphics::mapper::V4_0::Error;
@@ -123,6 +124,21 @@ YCbCrLayout HandleImporter::lockYCbCrInternal(const sp<M> mapper, buffer_handle_
    return layout;
}

bool isMetadataPesent(const sp<IMapperV4> mapper, const buffer_handle_t& buf,
        MetadataType metadataType) {
    auto buffer = const_cast<native_handle_t*>(buf);
    mapper->get(buffer, metadataType, [] (const auto& tmpError,
                const auto& tmpMetadata) {
                    if (tmpError == MapperErrorV4::NONE) {
                        return tmpMetadata.size() > 0;
                    } else {
                        ALOGE("%s: failed to get metadata %d!", __FUNCTION__, tmpError);
                        return false;
                    }});

    return false;
}

std::vector<PlaneLayout> getPlaneLayouts(const sp<IMapperV4> mapper, buffer_handle_t& buf) {
    auto buffer = const_cast<native_handle_t*>(buf);
    std::vector<PlaneLayout> planeLayouts;
@@ -449,6 +465,55 @@ int HandleImporter::unlock(buffer_handle_t& buf) {
    return -1;
}

bool HandleImporter::isSmpte2086Present(const buffer_handle_t& buf) {
    Mutex::Autolock lock(mLock);

    if (!mInitialized) {
        initializeLocked();
    }

    if (mMapperV4 != nullptr) {
        return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2086);
    } else {
        ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
    }

    return false;
}

bool HandleImporter::isSmpte2094_10Present(const buffer_handle_t& buf) {
    Mutex::Autolock lock(mLock);

    if (!mInitialized) {
        initializeLocked();
    }

    if (mMapperV4 != nullptr) {
        return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2094_10);
    } else {
        ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
    }

    return false;
}

bool HandleImporter::isSmpte2094_40Present(const buffer_handle_t& buf) {
    Mutex::Autolock lock(mLock);

    if (!mInitialized) {
        initializeLocked();
    }

    if (mMapperV4 != nullptr) {
        return isMetadataPesent(mMapperV4, buf, gralloc4::MetadataType_Smpte2094_40);
    } else {
        ALOGE("%s: mMapperV4 is null! Query not supported!", __FUNCTION__);
    }

    return false;
}


} // namespace helper
} // namespace V1_0
} // namespace common
+5 −0
Original line number Diff line number Diff line
@@ -61,6 +61,11 @@ public:

    int unlock(buffer_handle_t& buf); // returns release fence

    // Query Gralloc4 metadata
    bool isSmpte2086Present(const buffer_handle_t& buf);
    bool isSmpte2094_10Present(const buffer_handle_t& buf);
    bool isSmpte2094_40Present(const buffer_handle_t& buf);

private:
    void initializeLocked();
    void cleanup();
+2 −1
Original line number Diff line number Diff line
@@ -9,7 +9,6 @@ package {
    default_applicable_licenses: ["hardware_interfaces_license"],
}


hidl_interface {
    name: "android.hardware.camera.device@3.8",
    root: "android.hardware",
@@ -17,6 +16,7 @@ hidl_interface {
        "types.hal",
        "ICameraDevice.hal",
        "ICameraDeviceCallback.hal",
        "ICameraDeviceSession.hal",
    ],
    interfaces: [
        "android.hardware.camera.common@1.0",
@@ -31,6 +31,7 @@ hidl_interface {
        "android.hardware.camera.metadata@3.4",
        "android.hardware.camera.metadata@3.5",
        "android.hardware.camera.metadata@3.6",
        "android.hardware.camera.metadata@3.8",
        "android.hardware.graphics.common@1.0",
        "android.hidl.base@1.0",
    ],
+13 −2
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@ import @3.7::ICameraDevice;
 * API at LIMITED or better hardware level.
 *
 * ICameraDevice.open() must return @3.2::ICameraDeviceSession,
 * @3.5::ICameraDeviceSession, @3.6::ICameraDeviceSession, or
 * @3.7::ICameraDeviceSession.
 * @3.5::ICameraDeviceSession, @3.6::ICameraDeviceSession,
 * @3.7::ICameraDeviceSession, or @3.8::ICameraDeviceSession.
 */
interface ICameraDevice extends @3.7::ICameraDevice {
    /**
@@ -107,4 +107,15 @@ interface ICameraDevice extends @3.7::ICameraDevice {
     *
     */
    getTorchStrengthLevel() generates (Status status, int32_t torchStrength);

     /**
     * isStreamCombinationSupported_3_8:
     *
     * Identical to @3.7::ICameraDevice.isStreamCombinationSupported, except
     * that it takes a @3.8::StreamConfiguration parameter, which could contain
     * additional information about a specific 10-bit dynamic range profile.
     *
     */
    isStreamCombinationSupported_3_8(StreamConfiguration streams)
            generates (Status status, bool queryStatus);
};
+95 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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@3.8;

import android.hardware.camera.common@1.0::Status;
import @3.5::StreamConfiguration;
import @3.7::ICameraDeviceSession;
import @3.6::HalStreamConfiguration;

/**
 * Camera device active session interface.
 *
 * Obtained via ICameraDevice::open(), this interface contains the methods to
 * configure and request captures from an active camera device.
 */
interface ICameraDeviceSession extends @3.7::ICameraDeviceSession {
    /**
     * configureStreams_3_8:
     *
     * Identical to @3.7::ICameraDeviceSession.configureStreams_3_7, except that:
     *
     * - The requestedConfiguration allows the camera framework to configure
     *   10-bit dynamic range profile.
     *
     * @return status Status code for the operation, one of:
     *     OK:
     *         On successful stream configuration.
     *     INTERNAL_ERROR:
     *         If there has been a fatal error and the device is no longer
     *         operational. Only close() can be called successfully by the
     *         framework after this error is returned.
     *     ILLEGAL_ARGUMENT:
     *         If the requested stream configuration is invalid. Some examples
     *         of invalid stream configurations include:
     *           - Including more than 1 INPUT stream
     *           - Not including any OUTPUT streams
     *           - Including streams with unsupported formats, or an unsupported
     *             size for that format.
     *           - Including too many output streams of a certain format.
     *           - Unsupported rotation configuration
     *           - Stream sizes/formats don't satisfy the
     *             StreamConfigurationMode requirements
     *             for non-NORMAL mode, or the requested operation_mode is not
     *             supported by the HAL.
     *           - Unsupported usage flag
     *           - Unsupported stream groupIds, or unsupported multi-resolution
     *             input stream.
     *           - Invalid combination between a 10-bit dynamic range profile
     *             and none impl. defined 8-bit format for a particular stream.
     *         The camera service cannot filter out all possible illegal stream
     *         configurations, since some devices may support more simultaneous
     *         streams or larger stream resolutions than the minimum required
     *         for a given camera device hardware level. The HAL must return an
     *         ILLEGAL_ARGUMENT for any unsupported stream set, and then be
     *         ready to accept a future valid stream configuration in a later
     *         configureStreams call.
     * @return halConfiguration The stream parameters desired by the HAL for
     *     each stream, including maximum buffers, the usage flags, and the
     *     override format and dataspace.
     */
    configureStreams_3_8(StreamConfiguration requestedConfiguration)
        generates (Status status, @3.6::HalStreamConfiguration halConfiguration);

    /**
     * repeatingRequestEnd:
     *
     * Notification about the last frame number in a repeating request along with the
     * ids of all streams included in the repeating request.
     *
     * This can be called at any point after 'processCaptureRequest' in response
     * to camera clients disabling an active repeating request.
     *
     * Performance requirements:
     * The call must not be blocked for extensive periods and should be extremely lightweight. There
     * must be no frame rate degradation or frame jitter introduced.
     *
     * This method must always succeed, even if the device has encountered a
     * serious error.
     */
    repeatingRequestEnd(uint32_t frameNumber, vec<int32_t> streamIds);
};
Loading