blob: e8d14b56dd8203d761f2e7ee27cffe5903cfee17 [file] [log] [blame]
Yin-Chia Yehee238402018-11-04 16:30:11 -08001/*
2 * Copyright (C) 2018 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.5"
18//#define LOG_NDEBUG 0
19#include <log/log.h>
20
21#include "ExternalCameraDevice_3_5.h"
22
23namespace android {
24namespace hardware {
25namespace camera {
26namespace device {
27namespace V3_5 {
28namespace implementation {
29
30ExternalCameraDevice::ExternalCameraDevice(
31 const std::string& cameraId, const ExternalCameraConfig& cfg) :
32 V3_4::implementation::ExternalCameraDevice(cameraId, cfg) {}
33
34ExternalCameraDevice::~ExternalCameraDevice() {}
35
36Return<void> ExternalCameraDevice::getPhysicalCameraCharacteristics(const hidl_string&,
37 V3_5::ICameraDevice::getPhysicalCameraCharacteristics_cb _hidl_cb) {
38 CameraMetadata cameraCharacteristics;
39 // External camera HAL doesn't support physical camera functions
40 _hidl_cb(Status::ILLEGAL_ARGUMENT, cameraCharacteristics);
41 return Void();
42}
43
44sp<V3_4::implementation::ExternalCameraDeviceSession> ExternalCameraDevice::createSession(
45 const sp<V3_2::ICameraDeviceCallback>& cb,
46 const ExternalCameraConfig& cfg,
47 const std::vector<SupportedV4L2Format>& sortedFormats,
48 const CroppingType& croppingType,
49 const common::V1_0::helper::CameraMetadata& chars,
50 const std::string& cameraId,
51 unique_fd v4l2Fd) {
52 return new ExternalCameraDeviceSession(
53 cb, cfg, sortedFormats, croppingType, chars, cameraId, std::move(v4l2Fd));
54}
55
56#define UPDATE(tag, data, size) \
57do { \
58 if (metadata->update((tag), (data), (size))) { \
59 ALOGE("Update " #tag " failed!"); \
60 return -EINVAL; \
61 } \
62} while (0)
63
64status_t ExternalCameraDevice::initDefaultCharsKeys(
65 ::android::hardware::camera::common::V1_0::helper::CameraMetadata* metadata) {
66 status_t res =
67 V3_4::implementation::ExternalCameraDevice::initDefaultCharsKeys(metadata);
68
69 if (res != OK) {
70 return res;
71 }
72
73 const uint8_t bufMgrVer = ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION_HIDL_DEVICE_3_5;
74 UPDATE(ANDROID_INFO_SUPPORTED_BUFFER_MANAGEMENT_VERSION, &bufMgrVer, 1);
75
76 std::vector<int> availableCharacteristicsKeys = AVAILABLE_CHARACTERISTICS_KEYS_3_4;
77 availableCharacteristicsKeys.reserve(availableCharacteristicsKeys.size() +
78 EXTRA_CHARACTERISTICS_KEYS_3_5.size());
79 for (const auto& key : EXTRA_CHARACTERISTICS_KEYS_3_5) {
80 availableCharacteristicsKeys.push_back(key);
81 }
82 UPDATE(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS,
83 availableCharacteristicsKeys.data(),
84 availableCharacteristicsKeys.size());
85
86 return OK;
87}
88
89#undef UPDATE
90
91} // namespace implementation
92} // namespace V3_5
93} // namespace device
94} // namespace camera
95} // namespace hardware
96} // namespace android
97