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

Commit f906b3bb authored by Yin-Chia Yeh's avatar Yin-Chia Yeh
Browse files

Camera: Add default camera provider 2.4

Supports legacy camera HAL modules; also exports ICameraDevice
instances.

Test: compile
Bug: 30985004
Change-Id: I2b9624a412de95dd43979a5e6650b170010c577a
parent faef8f92
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -7,4 +7,5 @@ subdirs = [
    "device/3.2/default",
    "metadata/3.2",
    "provider/2.4",
    "provider/2.4/default",
]
+24 −10
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ int CameraModule::open(const char* id, struct hw_device_t** device) {
    return res;
}

bool CameraModule::isOpenLegacyDefined() {
bool CameraModule::isOpenLegacyDefined() const {
    if (getModuleApiVersion() < CAMERA_MODULE_API_VERSION_2_3) {
        return false;
    }
@@ -376,7 +376,7 @@ int CameraModule::setCallbacks(const camera_module_callbacks_t *callbacks) {
    return res;
}

bool CameraModule::isVendorTagDefined() {
bool CameraModule::isVendorTagDefined() const {
    return mModule->get_vendor_tag_ops != NULL;
}

@@ -388,11 +388,25 @@ void CameraModule::getVendorTagOps(vendor_tag_ops_t* ops) {
    }
}

bool CameraModule::isSetTorchModeSupported() const {
    if (getModuleApiVersion() >= CAMERA_MODULE_API_VERSION_2_4) {
        if (mModule->set_torch_mode == NULL) {
            ALOGE("%s: Module 2.4 device must support set torch API!",
                    __FUNCTION__);
            return false;
        }
        return true;
    }
    return false;
}

int CameraModule::setTorchMode(const char* camera_id, bool enable) {
    int res;
    int res = INVALID_OPERATION;
    if (mModule->set_torch_mode != NULL) {
        ATRACE_BEGIN("camera_module->set_torch_mode");
        res = mModule->set_torch_mode(camera_id, enable);
        ATRACE_END();
    }
    return res;
}

@@ -409,19 +423,19 @@ status_t CameraModule::filterOpenErrorCode(status_t err) {
    return -ENODEV;
}

uint16_t CameraModule::getModuleApiVersion() {
uint16_t CameraModule::getModuleApiVersion() const {
    return mModule->common.module_api_version;
}

const char* CameraModule::getModuleName() {
const char* CameraModule::getModuleName() const {
    return mModule->common.name;
}

uint16_t CameraModule::getHalApiVersion() {
uint16_t CameraModule::getHalApiVersion() const {
    return mModule->common.hal_api_version;
}

const char* CameraModule::getModuleAuthor() {
const char* CameraModule::getModuleAuthor() const {
    return mModule->common.author;
}

+7 −6
Original line number Diff line number Diff line
@@ -49,16 +49,17 @@ public:
    int getDeviceVersion(int cameraId);
    int getNumberOfCameras(void);
    int open(const char* id, struct hw_device_t** device);
    bool isOpenLegacyDefined();
    bool isOpenLegacyDefined() const;
    int openLegacy(const char* id, uint32_t halVersion, struct hw_device_t** device);
    int setCallbacks(const camera_module_callbacks_t *callbacks);
    bool isVendorTagDefined();
    bool isVendorTagDefined() const;
    void getVendorTagOps(vendor_tag_ops_t* ops);
    bool isSetTorchModeSupported() const;
    int setTorchMode(const char* camera_id, bool enable);
    uint16_t getModuleApiVersion();
    const char* getModuleName();
    uint16_t getHalApiVersion();
    const char* getModuleAuthor();
    uint16_t getModuleApiVersion() const;
    const char* getModuleName() const;
    uint16_t getHalApiVersion() const;
    const char* getModuleAuthor() const;
    // Only used by CameraModuleFixture native test. Do NOT use elsewhere.
    void *getDso();

+0 −5
Original line number Diff line number Diff line
@@ -78,11 +78,6 @@ interface ICameraDevice {
     */
    getCameraInfo() generates (Status status, CameraInfo info);

    // TODO: add query setTorch mode support so camera service can tell whether
    //       it needs to simulate torch or not (without calling setTorchMode
    //       which is visible to end user)
    //       Should this be put to device hal or provider hal?

    /**
     * setTorchMode:
     *
+24 −0
Original line number Diff line number Diff line
@@ -119,6 +119,30 @@ interface ICameraProvider {
    getCameraIdList()
            generates (Status status, vec<string> cameraDeviceNames);

    /**
     * isSetTorchModeSupported:
     *
     * Returns if the camera devices known to this camera provider support
     * setTorchMode API or not. If the provider does not support setTorchMode
     * API, calling to setTorchMode will return METHOD_NOT_SUPPORTED.
     *
     * Note that not every camera device has a flash unit, so even this API
     * returns true, setTorchMode call might still fail due to the camera device
     * does not have a flash unit. In such case, the returned status will be
     * OPERATION_NOT_SUPPORTED.
     *
     * @return status Status code for the operation, one of:
     *     OK:
     *         On a succesful call
     *     INTERNAL_ERROR:
     *         Torch API support cannot be queried. This may be due to
     *         a failure to initialize the camera subsystem, for example.
     * @return support Whether the camera devices known to this provider
     *     supports setTorchMode API or not.
     *
     */
    isSetTorchModeSupported() generates (Status status, bool support);

    /**
     * getCameraDeviceInterface_VN_x:
     *
Loading