blob: f5ea56459fc08bf263c19ea94979ee455ea2f765 [file] [log] [blame]
Yin-Chia Yehfaef8f92016-10-31 12:53:56 -07001/*
2 * Copyright (C) 2016 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#ifndef HARDWARE_INTERFACES_CAMERA_DEVICE_V3_2_DEFAULT_INCLUDE_CONVERT_H_
18
19#define HARDWARE_INTERFACES_CAMERA_DEVICE_V3_2_DEFAULT_INCLUDE_CONVERT_H_
20
21#include <set>
22
23
24#include <android/hardware/graphics/common/1.0/types.h>
25#include <android/hardware/camera/device/3.2/types.h>
26#include "hardware/camera3.h"
27
28namespace android {
29namespace hardware {
30namespace camera {
31namespace device {
32namespace V3_2 {
33namespace implementation {
34
35// Cacheing the buffer/fence from camera service so HAL can reference the pointer after the
36// processCaptureRequest call has returned.
37// Remove the cache when:
38// 1. HAL API call failed, or
39// 2. HAL returns the buffer and the callback to camera service has returned
40struct StreamBufferCache {
41 buffer_handle_t mBuffer;
42 camera3_stream_buffer_t mStreamBuffer;
43};
44
45// The camera3_stream_t sent to conventional HAL. Added mId fields to enable stream ID lookup
46// fromt a downcasted camera3_stream
47struct Camera3Stream : public camera3_stream {
48 int mId;
49};
50
51// *dst will point to the data owned by src, but src still owns the data after this call returns.
52bool convertFromHidl(const CameraMetadata &src, const camera_metadata_t** dst);
53void convertToHidl(const camera_metadata_t* src, CameraMetadata* dst);
54
55void convertFromHidl(const Stream &src, Camera3Stream* dst);
56void convertToHidl(const Camera3Stream* src, HalStream* dst);
57
58// dst->mStreamBuffer.buffer will be pointing to dst->mBuffer.
59// Most likely dst will be passed to HAL and HAL will try to access mStreamBuffer.buffer
60// after the API call returns. In that case caller must not use a local variable
61// within the scope of the API call to hold dst, because then dst->mStreamBuffer.buffer will be
62// invalid after the API call returns.
63void convertFromHidl(
64 buffer_handle_t, BufferStatus, camera3_stream_t*, int acquireFence, // inputs
65 StreamBufferCache* dst);
66
67void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst);
68
69// The camera3_stream_t* in src must be the same as what wrapper HAL passed to conventional
70// HAL, or the ID lookup will return garbage. Caller should validate the ID in ErrorMsg is
71// indeed one of active stream IDs
72void convertToHidl(const camera3_notify_msg* src, NotifyMsg* dst);
73
74} // namespace implementation
75} // namespace V3_2
76} // namespace device
77} // namespace camera
78} // namespace hardware
79} // namespace android
80
81#endif // HARDWARE_INTERFACES_CAMERA_DEVICE_V3_2_DEFAULT_INCLUDE_CONVERT_H_