blob: ef6dee37067a1f052cac798afa1ed9f543d370a4 [file] [log] [blame]
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -08001/*
Kevin Rocard96d2cd92018-11-14 16:22:07 -08002 * Copyright (C) 2018 The Android Open Source Project
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -08003 *
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 Rocard96d2cd92018-11-14 16:22:07 -080017#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 Naganov6e81e9b2016-11-16 16:30:17 -080021
22#include <memory>
23
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080024#include <system/audio.h>
25
Kevin Rocard55b10612018-11-12 12:33:16 -080026using ::android::hardware::hidl_vec;
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080027
28namespace android {
Kevin Rocard6891d7e2017-12-14 18:39:39 -080029namespace hardware {
30namespace audio {
31namespace common {
Kevin Rocard96d2cd92018-11-14 16:22:07 -080032namespace CPP_VERSION {
Mikhail Naganov543bf9c2018-12-11 16:36:53 -080033namespace implementation {
34
35using namespace ::android::hardware::audio::common::CPP_VERSION;
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080036
37class HidlUtils {
Andy Hungc91b6792020-02-14 15:39:55 -080038 public:
39 // A failure here indicates a platform config that is incompatible with
40 // the compiled HIDL interface version.
41 static status_t audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config);
42
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080043 static void audioConfigToHal(const AudioConfig& config, audio_config_t* halConfig);
Kevin Rocarddc874e02017-12-14 18:50:12 -080044 static void audioGainConfigFromHal(const struct audio_gain_config& halConfig,
45 AudioGainConfig* config);
46 static void audioGainConfigToHal(const AudioGainConfig& config,
47 struct audio_gain_config* halConfig);
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080048 static void audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain);
49 static void audioGainToHal(const AudioGain& gain, struct audio_gain* halGain);
Kevin Rocard97331362018-02-23 18:43:39 -080050 static AudioUsage audioUsageFromHal(const audio_usage_t halUsage);
51 static audio_usage_t audioUsageToHal(const AudioUsage usage);
Andy Hungc91b6792020-02-14 15:39:55 -080052 // A failure here indicates a platform offload info that is incompatible with
53 // the compiled HIDL interface version.
54 static status_t audioOffloadInfoFromHal(const audio_offload_info_t& halOffload,
55 AudioOffloadInfo* offload);
Kevin Rocarddc874e02017-12-14 18:50:12 -080056 static void audioOffloadInfoToHal(const AudioOffloadInfo& offload,
57 audio_offload_info_t* halOffload);
58 static void audioPortConfigFromHal(const struct audio_port_config& halConfig,
59 AudioPortConfig* config);
60 static void audioPortConfigToHal(const AudioPortConfig& config,
61 struct audio_port_config* halConfig);
62 static void audioPortConfigsFromHal(unsigned int numHalConfigs,
63 const struct audio_port_config* halConfigs,
64 hidl_vec<AudioPortConfig>* configs);
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080065 static std::unique_ptr<audio_port_config[]> audioPortConfigsToHal(
Andy Hungc91b6792020-02-14 15:39:55 -080066 const hidl_vec<AudioPortConfig>& configs);
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080067 static void audioPortFromHal(const struct audio_port& halPort, AudioPort* port);
68 static void audioPortToHal(const AudioPort& port, struct audio_port* halPort);
69 static void uuidFromHal(const audio_uuid_t& halUuid, Uuid* uuid);
70 static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid);
71};
72
Mikhail Naganov543bf9c2018-12-11 16:36:53 -080073} // namespace implementation
Kevin Rocard96d2cd92018-11-14 16:22:07 -080074} // namespace CPP_VERSION
Kevin Rocard6891d7e2017-12-14 18:39:39 -080075} // namespace common
76} // namespace audio
77} // namespace hardware
Mikhail Naganov6e81e9b2016-11-16 16:30:17 -080078} // namespace android
Kevin Rocard96d2cd92018-11-14 16:22:07 -080079
80#endif // android_hardware_audio_Hidl_Utils_H_