• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define LOG_TAG "ExtCamDev@3.6"
18 //#define LOG_NDEBUG 0
19 #include <log/log.h>
20 
21 #include "ExternalCameraDevice_3_6.h"
22 
23 namespace android {
24 namespace hardware {
25 namespace camera {
26 namespace device {
27 namespace V3_6 {
28 namespace implementation {
29 
ExternalCameraDevice(const std::string & cameraId,const ExternalCameraConfig & cfg)30 ExternalCameraDevice::ExternalCameraDevice(
31         const std::string& cameraId, const ExternalCameraConfig& cfg) :
32         V3_5::implementation::ExternalCameraDevice(cameraId, cfg) {}
33 
~ExternalCameraDevice()34 ExternalCameraDevice::~ExternalCameraDevice() {}
35 
createSession(const sp<V3_2::ICameraDeviceCallback> & cb,const ExternalCameraConfig & cfg,const std::vector<SupportedV4L2Format> & sortedFormats,const CroppingType & croppingType,const common::V1_0::helper::CameraMetadata & chars,const std::string & cameraId,unique_fd v4l2Fd)36 sp<V3_4::implementation::ExternalCameraDeviceSession> ExternalCameraDevice::createSession(
37         const sp<V3_2::ICameraDeviceCallback>& cb,
38         const ExternalCameraConfig& cfg,
39         const std::vector<SupportedV4L2Format>& sortedFormats,
40         const CroppingType& croppingType,
41         const common::V1_0::helper::CameraMetadata& chars,
42         const std::string& cameraId,
43         unique_fd v4l2Fd) {
44     return new ExternalCameraDeviceSession(
45             cb, cfg, sortedFormats, croppingType, chars, cameraId, std::move(v4l2Fd));
46 }
47 
48 #define UPDATE(tag, data, size)                    \
49 do {                                               \
50   if (metadata->update((tag), (data), (size))) {   \
51     ALOGE("Update " #tag " failed!");              \
52     return -EINVAL;                                \
53   }                                                \
54 } while (0)
55 
initAvailableCapabilities(::android::hardware::camera::common::V1_0::helper::CameraMetadata * metadata)56 status_t ExternalCameraDevice::initAvailableCapabilities(
57         ::android::hardware::camera::common::V1_0::helper::CameraMetadata* metadata) {
58     status_t res =
59             V3_4::implementation::ExternalCameraDevice::initAvailableCapabilities(metadata);
60 
61     if (res != OK) {
62         return res;
63     }
64 
65     camera_metadata_entry caps = metadata->find(ANDROID_REQUEST_AVAILABLE_CAPABILITIES);
66     std::vector<uint8_t> availableCapabilities;
67 
68     for (size_t i = 0; i < caps.count; i++) {
69         uint8_t capability = caps.data.u8[i];
70         availableCapabilities.push_back(capability);
71     }
72 
73     // Add OFFLINE_PROCESSING capability to device 3.6
74     availableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_OFFLINE_PROCESSING);
75 
76     UPDATE(ANDROID_REQUEST_AVAILABLE_CAPABILITIES,
77            availableCapabilities.data(),
78            availableCapabilities.size());
79 
80     return OK;
81 }
82 
83 #undef UPDATE
84 
85 }  // namespace implementation
86 }  // namespace V3_6
87 }  // namespace device
88 }  // namespace camera
89 }  // namespace hardware
90 }  // namespace android
91 
92