blob: e14ae992b8776f3bc03a5bbd3b1ea58353bc1f12 [file] [log] [blame]
Yin-Chia Yeh4da7c6c2020-01-16 17:06:36 -08001/*
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 "ExtCamDevSsn@3.6"
18#include <android/log.h>
19
20#include <utils/Trace.h>
21#include "ExternalCameraDeviceSession.h"
22
23namespace android {
24namespace hardware {
25namespace camera {
26namespace device {
27namespace V3_6 {
28namespace implementation {
29
30ExternalCameraDeviceSession::ExternalCameraDeviceSession(
31 const sp<V3_2::ICameraDeviceCallback>& callback,
32 const ExternalCameraConfig& cfg,
33 const std::vector<SupportedV4L2Format>& sortedFormats,
34 const CroppingType& croppingType,
35 const common::V1_0::helper::CameraMetadata& chars,
36 const std::string& cameraId,
37 unique_fd v4l2Fd) :
38 V3_5::implementation::ExternalCameraDeviceSession(
39 callback, cfg, sortedFormats, croppingType, chars, cameraId, std::move(v4l2Fd)) {
40}
41
42ExternalCameraDeviceSession::~ExternalCameraDeviceSession() {}
43
44
45Return<void> ExternalCameraDeviceSession::configureStreams_3_6(
46 const StreamConfiguration& requestedConfiguration,
47 ICameraDeviceSession::configureStreams_3_6_cb _hidl_cb) {
48 V3_2::StreamConfiguration config_v32;
49 V3_3::HalStreamConfiguration outStreams_v33;
50 V3_6::HalStreamConfiguration outStreams;
51 const V3_4::StreamConfiguration& requestedConfiguration_3_4 = requestedConfiguration.v3_4;
52 Mutex::Autolock _il(mInterfaceLock);
53
54 config_v32.operationMode = requestedConfiguration_3_4.operationMode;
55 config_v32.streams.resize(requestedConfiguration_3_4.streams.size());
56 uint32_t blobBufferSize = 0;
57 int numStallStream = 0;
58 for (size_t i = 0; i < config_v32.streams.size(); i++) {
59 config_v32.streams[i] = requestedConfiguration_3_4.streams[i].v3_2;
60 if (config_v32.streams[i].format == PixelFormat::BLOB) {
61 blobBufferSize = requestedConfiguration_3_4.streams[i].bufferSize;
62 numStallStream++;
63 }
64 }
65
66 // Fail early if there are multiple BLOB streams
67 if (numStallStream > kMaxStallStream) {
68 ALOGE("%s: too many stall streams (expect <= %d, got %d)", __FUNCTION__,
69 kMaxStallStream, numStallStream);
70 _hidl_cb(Status::ILLEGAL_ARGUMENT, outStreams);
71 return Void();
72 }
73
74 Status status = configureStreams(config_v32, &outStreams_v33, blobBufferSize);
75
76 outStreams.streams.resize(outStreams_v33.streams.size());
77 for (size_t i = 0; i < outStreams.streams.size(); i++) {
78 outStreams.streams[i].v3_4.v3_3 = outStreams_v33.streams[i];
79 // TODO: implement it later
80 outStreams.streams[i].supportOffline = false;
81 }
82 _hidl_cb(status, outStreams);
83 return Void();
84}
85
86Return<void> ExternalCameraDeviceSession::switchToOffline(
87 const hidl_vec<int32_t>& streamsToKeep,
88 ICameraDeviceSession::switchToOffline_cb _hidl_cb) {
89 // TODO: implement this
90 (void) streamsToKeep;
91 (void) _hidl_cb;
92 return Void();
93}
94
95} // namespace implementation
96} // namespace V3_6
97} // namespace device
98} // namespace camera
99} // namespace hardware
100} // namespace android