1 // Copyright (C) 2024 The Android Open Source Project
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 
6 // http://www.apache.org/licenses/LICENSE-2.0
7 
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
14 #pragma once
15 
16 #ifndef TARGET_FLOSS
17 #include <bluetooth/constants/aics/GainMode.h>
18 #include <bluetooth/constants/aics/Mute.h>
19 #endif
20 
21 #include <bluetooth/log.h>
22 
23 #include <cstdint>
24 
25 namespace bluetooth::aics {
26 
27 #ifndef TARGET_FLOSS
28 using Mute = bluetooth::constants::aics::Mute;
29 using GainMode = bluetooth::constants::aics::GainMode;
30 #else
31 // TODO: b/376941621 Support the aidl generation in FLOSS
32 enum class Mute : uint8_t { NOT_MUTED = 0x00, MUTED = 0x01, DISABLED = 0x02 };
33 enum class GainMode : uint8_t {
34   MANUAL_ONLY = 0x00,
35   AUTOMATIC_ONLY = 0x01,
36   MANUAL = 0x02,
37   AUTOMATIC = 0x03
38 };
39 #endif
40 
41 /** Check if the data is a correct Mute value */
42 bool isValidAudioInputMuteValue(uint8_t data);
43 
44 /** Convert valid data into a Mute value. Abort if data is not valid */
45 Mute parseMuteField(uint8_t data);
46 
47 /** Check if the data is a correct GainMode value */
48 bool isValidAudioInputGainModeValue(uint8_t data);
49 
50 /** Convert valid data into a Mute value. Abort if data is not valid */
51 GainMode parseGainModeField(uint8_t data);
52 }  // namespace bluetooth::aics
53 
54 namespace std {
55 template <>
56 struct formatter<bluetooth::aics::Mute> : enum_formatter<bluetooth::aics::Mute> {};
57 template <>
58 struct formatter<bluetooth::aics::GainMode> : enum_formatter<bluetooth::aics::GainMode> {};
59 }  // namespace std
60