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

Commit 579b5920 authored by Daniel Jacob Chittoor's avatar Daniel Jacob Chittoor
Browse files

Merge branch '1623-t-custom_scaler' into 'v2.1-t'

Camera: Allow using camera modes declared in Fairphone's custom scaler

See merge request !3
parents 66794ac3 b2210fc5
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -38,6 +38,10 @@ license {
cc_library_shared {
    name: "libcameraservice",

    defaults: [
        "camera_custom_scaler_configuration_defaults",
    ],

    // Camera service source

    srcs: [
+22 −5
Original line number Diff line number Diff line
@@ -159,15 +159,32 @@ bool roundBufferDimensionNearest(int32_t width, int32_t height,
    const int32_t heicSizesTag =
            getAppropriateModeTag(ANDROID_HEIC_AVAILABLE_HEIC_STREAM_CONFIGURATIONS, maxResolution);

    camera_metadata_ro_entry streamConfigs =
            (dataSpace == HAL_DATASPACE_DEPTH) ? info.find(depthSizesTag) :
            (dataSpace == static_cast<android_dataspace>(HAL_DATASPACE_HEIF)) ?
            info.find(heicSizesTag) :
            info.find(scalerSizesTag);

    bool isDepth = dataSpace == HAL_DATASPACE_DEPTH;
    bool isHeif = dataSpace == static_cast<android_dataspace>(HAL_DATASPACE_HEIF);
    int32_t selectedTag = isDepth ? depthSizesTag :
        isHeif ? heicSizesTag : scalerSizesTag;

    int32_t bestWidth = -1;
    int32_t bestHeight = -1;

    camera_metadata_ro_entry streamConfigs = info.find(selectedTag);

    if (TARGET_CAMERA_CUSTOM_SCALER_CONFIGURATION != "" && selectedTag == scalerSizesTag) {
        sp<VendorTagDescriptor> vTags;
        sp<VendorTagDescriptorCache> cache = VendorTagDescriptorCache::getGlobalVendorTagCache();
        if (cache.get()) {
            auto vendorId = const_cast<CameraMetadata*>(&info)->getVendorId();
            cache->getVendorTagDescriptor(vendorId, &vTags);
        }

        uint32_t vendorTag;
        status_t tagStatus = info.getTagFromName(TARGET_CAMERA_CUSTOM_SCALER_CONFIGURATION, vTags.get(), &vendorTag);
        ALOGD("Tag by name %s %d %x", TARGET_CAMERA_CUSTOM_SCALER_CONFIGURATION, tagStatus, vendorTag);
        if (tagStatus == OK)
            streamConfigs = info.find(vendorTag);
    }

    // Iterate through listed stream configurations and find the one with the smallest euclidean
    // distance from the given dimensions for the given format.
    for (size_t i = 0; i < streamConfigs.count; i += 4) {