1 /*
2  * Copyright (C) 2020 Arm Limited.
3  *
4  * Copyright 2016 The Android Open Source Project
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef GRALLOC_COMMON_SHARED_METADATA_H
20 #define GRALLOC_COMMON_SHARED_METADATA_H
21 
22 #include <optional>
23 #include <vector>
24 #include "gralloctypes/Gralloc4.h"
25 #include "mali_gralloc_buffer.h"
26 #include "allocator/mali_gralloc_shared_memory.h"
27 #include "core/mali_gralloc_bufferdescriptor.h"
28 #include "gralloc_helper.h"
29 
30 #include "4.x/gralloc_mapper_hidl_header.h"
31 
32 #include "SharedMetadata_struct.h"
33 
34 namespace arm
35 {
36 namespace mapper
37 {
38 namespace common
39 {
40 
41 using android::hardware::hidl_vec;
42 using aidl::android::hardware::graphics::common::Rect;
43 using aidl::android::hardware::graphics::common::Smpte2086;
44 using aidl::android::hardware::graphics::common::Cta861_3;
45 using aidl::android::hardware::graphics::common::BlendMode;
46 using aidl::android::hardware::graphics::common::Dataspace;
47 
48 void shared_metadata_init(void *memory, std::string_view name);
49 size_t shared_metadata_size();
50 
51 void get_name(const private_handle_t *hnd, std::string *name);
52 
53 void get_crop_rect(const private_handle_t *hnd, std::optional<Rect> *crop);
54 android::status_t set_crop_rect(const private_handle_t *hnd, const Rect &crop_rectangle);
55 
56 void get_dataspace(const private_handle_t *hnd, std::optional<Dataspace> *dataspace);
57 void set_dataspace(const private_handle_t *hnd, const Dataspace &dataspace);
58 
59 void get_blend_mode(const private_handle_t *hnd, std::optional<BlendMode> *blend_mode);
60 void set_blend_mode(const private_handle_t *hnd, const BlendMode &blend_mode);
61 
62 void get_smpte2086(const private_handle_t *hnd, std::optional<Smpte2086> *smpte2086);
63 android::status_t set_smpte2086(const private_handle_t *hnd, const std::optional<Smpte2086> &smpte2086);
64 
65 void get_cta861_3(const private_handle_t *hnd, std::optional<Cta861_3> *cta861_3);
66 android::status_t set_cta861_3(const private_handle_t *hnd, const std::optional<Cta861_3> &cta861_3);
67 
68 void get_smpte2094_40(const private_handle_t *hnd, std::optional<std::vector<uint8_t>> *smpte2094_40);
69 android::status_t set_smpte2094_40(const private_handle_t *hnd, const std::optional<std::vector<uint8_t>> &smpte2094_40);
70 
71 } // namespace common
72 } // namespace mapper
73 } // namespace arm
74 
75 #endif
76