Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 1 | /* |
Kevin Rocard | 96d2cd9 | 2018-11-14 16:22:07 -0800 | [diff] [blame] | 2 | * Copyright (C) 2018 The Android Open Source Project |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 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 | |
Kevin Rocard | 96d2cd9 | 2018-11-14 16:22:07 -0800 | [diff] [blame] | 17 | #ifndef android_hardware_audio_Hidl_Utils_H_ |
| 18 | #define android_hardware_audio_Hidl_Utils_H_ |
| 19 | |
| 20 | #include PATH(android/hardware/audio/common/FILE_VERSION/types.h) |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 21 | |
| 22 | #include <memory> |
| 23 | |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 24 | #include <system/audio.h> |
| 25 | |
Kevin Rocard | 55b1061 | 2018-11-12 12:33:16 -0800 | [diff] [blame] | 26 | using ::android::hardware::hidl_vec; |
Kevin Rocard | 96d2cd9 | 2018-11-14 16:22:07 -0800 | [diff] [blame] | 27 | using ::android::hardware::audio::common::CPP_VERSION::AudioConfig; |
| 28 | using ::android::hardware::audio::common::CPP_VERSION::AudioGain; |
| 29 | using ::android::hardware::audio::common::CPP_VERSION::AudioGainConfig; |
| 30 | using ::android::hardware::audio::common::CPP_VERSION::AudioOffloadInfo; |
| 31 | using ::android::hardware::audio::common::CPP_VERSION::AudioPort; |
| 32 | using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig; |
| 33 | using ::android::hardware::audio::common::CPP_VERSION::Uuid; |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 34 | |
| 35 | namespace android { |
Kevin Rocard | 6891d7e | 2017-12-14 18:39:39 -0800 | [diff] [blame] | 36 | namespace hardware { |
| 37 | namespace audio { |
| 38 | namespace common { |
Kevin Rocard | 96d2cd9 | 2018-11-14 16:22:07 -0800 | [diff] [blame] | 39 | namespace CPP_VERSION { |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 40 | |
| 41 | class HidlUtils { |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame] | 42 | public: |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 43 | static void audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config); |
| 44 | static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig); |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame] | 45 | static void audioGainConfigFromHal(const struct audio_gain_config& halConfig, |
| 46 | AudioGainConfig* config); |
| 47 | static void audioGainConfigToHal(const AudioGainConfig& config, |
| 48 | struct audio_gain_config* halConfig); |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 49 | static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain); |
| 50 | static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain); |
Kevin Rocard | 9733136 | 2018-02-23 18:43:39 -0800 | [diff] [blame] | 51 | static AudioUsage audioUsageFromHal(const audio_usage_t halUsage); |
| 52 | static audio_usage_t audioUsageToHal(const AudioUsage usage); |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame] | 53 | static void audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, |
| 54 | AudioOffloadInfo* offload); |
| 55 | static void audioOffloadInfoToHal(const AudioOffloadInfo& offload, |
| 56 | audio_offload_info_t* halOffload); |
| 57 | static void audioPortConfigFromHal(const struct audio_port_config& halConfig, |
| 58 | AudioPortConfig* config); |
| 59 | static void audioPortConfigToHal(const AudioPortConfig& config, |
| 60 | struct audio_port_config* halConfig); |
| 61 | static void audioPortConfigsFromHal(unsigned int numHalConfigs, |
| 62 | const struct audio_port_config* halConfigs, |
| 63 | hidl_vec<AudioPortConfig>* configs); |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 64 | static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal( |
Kevin Rocard | dc874e0 | 2017-12-14 18:50:12 -0800 | [diff] [blame] | 65 | const hidl_vec<AudioPortConfig>& configs); |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 66 | static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port); |
| 67 | static void audioPortToHal(const AudioPort& port, struct audio_port* halPort); |
| 68 | static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid); |
| 69 | static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid); |
| 70 | }; |
| 71 | |
Kevin Rocard | 96d2cd9 | 2018-11-14 16:22:07 -0800 | [diff] [blame] | 72 | } // namespace CPP_VERSION |
Kevin Rocard | 6891d7e | 2017-12-14 18:39:39 -0800 | [diff] [blame] | 73 | } // namespace common |
| 74 | } // namespace audio |
| 75 | } // namespace hardware |
Mikhail Naganov | 6e81e9b | 2016-11-16 16:30:17 -0800 | [diff] [blame] | 76 | } // namespace android |
Kevin Rocard | 96d2cd9 | 2018-11-14 16:22:07 -0800 | [diff] [blame] | 77 | |
| 78 | #endif // android_hardware_audio_Hidl_Utils_H_ |