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

Commit 1b3c907b authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Camera: Setup vendors tags when initializing ProviderInfo

Add new VendorTagDescriptor member to ProviderInfo, allowing it to cache
the descriptor

Test: Use torch, camera, and run cameraservice_test
Change-Id: Iba5af5dc890b3188a9e55ff5c71421aceec14cbb
parent 04228920
Loading
Loading
Loading
Loading
+44 −31
Original line number Diff line number Diff line
@@ -254,37 +254,7 @@ status_t CameraProviderManager::setUpVendorTags() {
    sp<VendorTagDescriptorCache> tagCache = new VendorTagDescriptorCache();

    for (auto& provider : mProviders) {
        hardware::hidl_vec<VendorTagSection> vts;
        Status status;
        hardware::Return<void> ret;
        ret = provider->mInterface->getVendorTags(
            [&](auto s, const auto& vendorTagSecs) {
                status = s;
                if (s == Status::OK) {
                    vts = vendorTagSecs;
                }
        });
        if (!ret.isOk()) {
            ALOGE("%s: Transaction error getting vendor tags from provider '%s': %s",
                    __FUNCTION__, provider->mProviderName.c_str(), ret.description().c_str());
            return DEAD_OBJECT;
        }
        if (status != Status::OK) {
            return mapToStatusT(status);
        }

        // Read all vendor tag definitions into a descriptor
        sp<VendorTagDescriptor> desc;
        status_t res;
        if ((res = HidlVendorTagDescriptor::createDescriptorFromHidl(vts, /*out*/desc))
                != OK) {
            ALOGE("%s: Could not generate descriptor from vendor tag operations,"
                  "received error %s (%d). Camera clients will not be able to use"
                  "vendor tags", __FUNCTION__, strerror(res), res);
            return res;
        }

        tagCache->addVendorDescriptor(provider->mProviderTagid, desc);
        tagCache->addVendorDescriptor(provider->mProviderTagid, provider->mVendorTagDescriptor);
    }

    VendorTagDescriptorCache::setAsGlobalVendorTagCache(tagCache);
@@ -750,6 +720,13 @@ status_t CameraProviderManager::ProviderInfo::initialize() {
        }
    }

    res = setUpVendorTags();
    if (res != OK) {
        ALOGE("%s: Unable to set up vendor tags from provider '%s'",
                __FUNCTION__, mProviderName.c_str());
        return res;
    }

    ALOGI("Camera provider %s ready with %zu camera devices",
            mProviderName.c_str(), mDevices.size());

@@ -994,6 +971,42 @@ void CameraProviderManager::ProviderInfo::serviceDied(uint64_t cookie,
    mManager->removeProvider(mProviderName);
}

status_t CameraProviderManager::ProviderInfo::setUpVendorTags() {
    if (mVendorTagDescriptor != nullptr)
        return OK;

    hardware::hidl_vec<VendorTagSection> vts;
    Status status;
    hardware::Return<void> ret;
    ret = mInterface->getVendorTags(
        [&](auto s, const auto& vendorTagSecs) {
            status = s;
            if (s == Status::OK) {
                vts = vendorTagSecs;
            }
    });
    if (!ret.isOk()) {
        ALOGE("%s: Transaction error getting vendor tags from provider '%s': %s",
                __FUNCTION__, mProviderName.c_str(), ret.description().c_str());
        return DEAD_OBJECT;
    }
    if (status != Status::OK) {
        return mapToStatusT(status);
    }

    // Read all vendor tag definitions into a descriptor
    status_t res;
    if ((res = HidlVendorTagDescriptor::createDescriptorFromHidl(vts, /*out*/mVendorTagDescriptor))
            != OK) {
        ALOGE("%s: Could not generate descriptor from vendor tag operations,"
                "received error %s (%d). Camera clients will not be able to use"
                "vendor tags", __FUNCTION__, strerror(res), res);
        return res;
    }

    return OK;
}

template<class DeviceInfoT>
std::unique_ptr<CameraProviderManager::ProviderInfo::DeviceInfo>
    CameraProviderManager::ProviderInfo::initializeDeviceInfo(
+6 −0
Original line number Diff line number Diff line
@@ -266,6 +266,7 @@ private:
        const std::string mProviderName;
        const sp<hardware::camera::provider::V2_4::ICameraProvider> mInterface;
        const metadata_vendor_id_t mProviderTagid;
        sp<VendorTagDescriptor> mVendorTagDescriptor;

        ProviderInfo(const std::string &providerName,
                sp<hardware::camera::provider::V2_4::ICameraProvider>& interface,
@@ -294,6 +295,11 @@ private:
        // hidl_death_recipient interface - this locks the parent mInterfaceMutex
        virtual void serviceDied(uint64_t cookie, const wp<hidl::base::V1_0::IBase>& who) override;

        /**
         * Setup vendor tags for this provider
         */
        status_t setUpVendorTags();

        // Basic device information, common to all camera devices
        struct DeviceInfo {
            const std::string mName;  // Full instance name