1 /* 2 * Copyright (C) 2019 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 HW_EMULATOR_CAMERA_BASE_H 18 #define HW_EMULATOR_CAMERA_BASE_H 19 20 #include <log/log.h> 21 22 #include <memory> 23 24 #include "aidl/android/hardware/graphics/common/Dataspace.h" 25 #include "android/hardware/graphics/common/1.1/types.h" 26 #include "hwl_types.h" 27 28 namespace android { 29 30 using android::hardware::graphics::common::V1_1::PixelFormat; 31 using google_camera_hal::HwlPipelineCallback; 32 using google_camera_hal::StreamBuffer; 33 34 struct YCbCrPlanes { 35 uint8_t* img_y = nullptr; 36 uint8_t* img_cb = nullptr; 37 uint8_t* img_cr = nullptr; 38 uint32_t y_stride = 0; 39 uint32_t cbcr_stride = 0; 40 uint32_t cbcr_step = 0; 41 size_t bytesPerPixel = 1; 42 }; 43 44 struct SinglePlane { 45 uint8_t* img = nullptr; 46 uint32_t stride_in_bytes = 0; 47 uint32_t buffer_size = 0; 48 }; 49 50 struct SensorBuffer { 51 uint32_t width, height; 52 uint32_t frame_number; 53 uint32_t pipeline_id; 54 uint32_t camera_id; 55 PixelFormat format; 56 android_dataspace_t dataSpace; 57 int32_t color_space; 58 int32_t use_case; 59 StreamBuffer stream_buffer; 60 HwlPipelineCallback callback; 61 int acquire_fence_fd; 62 bool is_input; 63 bool is_failed_request; 64 65 union Plane { 66 SinglePlane img; 67 YCbCrPlanes img_y_crcb; 68 } plane; 69 SensorBufferSensorBuffer70 SensorBuffer() 71 : width(0), 72 height(0), 73 frame_number(0), 74 pipeline_id(0), 75 camera_id(0), 76 format(PixelFormat::RGBA_8888), 77 dataSpace(HAL_DATASPACE_UNKNOWN), 78 color_space( 79 ANDROID_REQUEST_AVAILABLE_COLOR_SPACE_PROFILES_MAP_UNSPECIFIED), 80 use_case(ANDROID_SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT), 81 acquire_fence_fd(-1), 82 is_input(false), 83 is_failed_request(false), 84 plane{} { 85 } 86 87 SensorBuffer(const SensorBuffer&) = delete; 88 SensorBuffer& operator=(const SensorBuffer&) = delete; 89 ~SensorBufferSensorBuffer90 virtual ~SensorBuffer() { 91 } 92 }; 93 94 typedef std::vector<std::unique_ptr<SensorBuffer>> Buffers; 95 96 } // namespace android 97 98 #endif 99