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

Commit 317e9d4e authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I2ca96002,I8f9c076e into main

* changes:
  Add the abstraction layer for the camera classes
  Add EVS Camera Device Type to the Default Implementation
parents 1f299c75 c5d5d756
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -25,8 +25,10 @@

#include <tinyxml2.h>

#include <limits>
#include <string>
#include <string_view>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <vector>
@@ -54,6 +56,15 @@ class ConfigManager final {
    /* Camera device's capabilities and metadata */
    class CameraInfo {
      public:
        enum class DeviceType : std::int32_t {
            NONE = 0,
            MOCK = 1,
            V4L2 = 2,
            VIDEO = 3,

            UNKNOWN = std::numeric_limits<std::underlying_type_t<DeviceType>>::max(),
        };

        CameraInfo() : characteristics(nullptr) {}

        virtual ~CameraInfo();
@@ -69,6 +80,10 @@ class ConfigManager final {
            return characteristics != nullptr;
        }

        static DeviceType deviceTypeFromSV(const std::string_view sv);

        DeviceType deviceType{DeviceType::NONE};

        /*
         * List of supported controls that the primary client can program.
         * Paraemters are stored with its valid range
+43 −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.
 */

#pragma once

#include <aidl/android/hardware/automotive/evs/BnEvsCamera.h>

namespace aidl::android::hardware::automotive::evs::implementation {

class EvsCameraBase : public evs::BnEvsCamera {
  private:
    using Base = evs::BnEvsCamera;
    using Self = EvsCameraBase;

  public:
    using Base::Base;

    ~EvsCameraBase() override = default;

    virtual void shutdown() = 0;

  protected:
    // This is used for the derived classes and it prevents constructors from direct access
    // while it allows this class to be instantiated via ndk::SharedRefBase::make<>.
    struct Sigil {
        explicit Sigil() = default;
    };
};

}  // namespace aidl::android::hardware::automotive::evs::implementation
+2 −2
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
#pragma once

#include "ConfigManager.h"
#include "EvsCameraBase.h"
#include "EvsGlDisplay.h"
#include "EvsMockCamera.h"

#include <aidl/android/frameworks/automotive/display/ICarDisplayProxy.h>
#include <aidl/android/hardware/automotive/evs/BnEvsEnumerator.h>
@@ -73,7 +73,7 @@ class EvsEnumerator final : public ::aidl::android::hardware::automotive::evs::B
  private:
    struct CameraRecord {
        evs::CameraDesc desc;
        std::weak_ptr<EvsMockCamera> activeInstance;
        std::weak_ptr<EvsCameraBase> activeInstance;

        CameraRecord(const char* cameraId) : desc() { desc.id = cameraId; }
    };
+5 −10
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
#pragma once

#include "ConfigManager.h"
#include "EvsCameraBase.h"

#include <aidl/android/hardware/automotive/evs/BnEvsCamera.h>
#include <aidl/android/hardware/automotive/evs/BufferDesc.h>
#include <aidl/android/hardware/automotive/evs/CameraDesc.h>
#include <aidl/android/hardware/automotive/evs/CameraParam.h>
@@ -36,14 +36,7 @@

namespace aidl::android::hardware::automotive::evs::implementation {

class EvsMockCamera : public evs::BnEvsCamera {
    // This prevents constructors from direct access while it allows this class to
    // be instantiated via ndk::SharedRefBase::make<>.
  private:
    struct Sigil {
        explicit Sigil() = default;
    };

class EvsMockCamera : public EvsCameraBase {
  public:
    // Methods from ::android::hardware::automotive::evs::IEvsCamera follow.
    ndk::ScopedAStatus doneWithFrame(const std::vector<evs::BufferDesc>& buffers) override;
@@ -81,7 +74,9 @@ class EvsMockCamera : public evs::BnEvsCamera {
    EvsMockCamera& operator=(const EvsMockCamera&) = delete;

    virtual ~EvsMockCamera() override;
    void shutdown();

    // Methods from EvsCameraBase follow.
    void shutdown() override;

    const evs::CameraDesc& getDesc() { return mDescription; }

+16 −0
Original line number Diff line number Diff line
@@ -40,6 +40,18 @@ std::string_view ConfigManager::sConfigDefaultPath =
std::string_view ConfigManager::sConfigOverridePath =
        "/vendor/etc/automotive/evs/evs_configuration_override.xml";

ConfigManager::CameraInfo::DeviceType ConfigManager::CameraInfo::deviceTypeFromSV(
        const std::string_view sv) {
    using namespace std::string_view_literals;
    static const std::unordered_map<std::string_view, DeviceType> nameToType = {
            {"mock"sv, DeviceType::MOCK},
            {"v4l2"sv, DeviceType::V4L2},
            {"video"sv, DeviceType::VIDEO},
    };
    const auto search = nameToType.find(sv);
    return search == nameToType.end() ? DeviceType::UNKNOWN : search->second;
}

void ConfigManager::printElementNames(const XMLElement* rootElem, const std::string& prefix) const {
    const XMLElement* curElem = rootElem;

@@ -128,6 +140,10 @@ bool ConfigManager::readCameraDeviceInfo(CameraInfo* aCamera, const XMLElement*
        return false;
    }

    if (const auto typeAttr = aDeviceElem->FindAttribute("type")) {
        aCamera->deviceType = CameraInfo::deviceTypeFromSV(typeAttr->Value());
    }

    /* size information to allocate camera_metadata_t */
    size_t totalEntries = 0;
    size_t totalDataSize = 0;
Loading