blob: f460addc54d3b3d811ff2e70bc0a497fca7775a8 [file] [log] [blame]
Kevin Rocard4bcd67f2018-02-28 14:33:38 -08001/*
2 * Copyright (C) 2016 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
Kevin Rocard51e076a2018-02-28 14:36:53 -080017#ifndef ANDROID_HARDWARE_DEVICE_HAL_HIDL_4_0_H
18#define ANDROID_HARDWARE_DEVICE_HAL_HIDL_4_0_H
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080019
Kevin Rocard51e076a2018-02-28 14:36:53 -080020#include <android/hardware/audio/4.0/IDevice.h>
21#include <android/hardware/audio/4.0/IPrimaryDevice.h>
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080022#include <media/audiohal/DeviceHalInterface.h>
23
24#include "ConversionHelperHidl.h"
25
Kevin Rocard51e076a2018-02-28 14:36:53 -080026using ::android::hardware::audio::V4_0::IDevice;
27using ::android::hardware::audio::V4_0::IPrimaryDevice;
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080028using ::android::hardware::Return;
29
30namespace android {
Kevin Rocard51e076a2018-02-28 14:36:53 -080031namespace V4_0 {
Kevin Rocard4bcd67f2018-02-28 14:33:38 -080032
33class DeviceHalHidl : public DeviceHalInterface, public ConversionHelperHidl
34{
35 public:
36 // Sets the value of 'devices' to a bitmask of 1 or more values of audio_devices_t.
37 virtual status_t getSupportedDevices(uint32_t *devices);
38
39 // Check to see if the audio hardware interface has been initialized.
40 virtual status_t initCheck();
41
42 // Set the audio volume of a voice call. Range is between 0.0 and 1.0.
43 virtual status_t setVoiceVolume(float volume);
44
45 // Set the audio volume for all audio activities other than voice call.
46 virtual status_t setMasterVolume(float volume);
47
48 // Get the current master volume value for the HAL.
49 virtual status_t getMasterVolume(float *volume);
50
51 // Called when the audio mode changes.
52 virtual status_t setMode(audio_mode_t mode);
53
54 // Muting control.
55 virtual status_t setMicMute(bool state);
56 virtual status_t getMicMute(bool *state);
57 virtual status_t setMasterMute(bool state);
58 virtual status_t getMasterMute(bool *state);
59
60 // Set global audio parameters.
61 virtual status_t setParameters(const String8& kvPairs);
62
63 // Get global audio parameters.
64 virtual status_t getParameters(const String8& keys, String8 *values);
65
66 // Returns audio input buffer size according to parameters passed.
67 virtual status_t getInputBufferSize(const struct audio_config *config,
68 size_t *size);
69
70 // Creates and opens the audio hardware output stream. The stream is closed
71 // by releasing all references to the returned object.
72 virtual status_t openOutputStream(
73 audio_io_handle_t handle,
74 audio_devices_t devices,
75 audio_output_flags_t flags,
76 struct audio_config *config,
77 const char *address,
78 sp<StreamOutHalInterface> *outStream);
79
80 // Creates and opens the audio hardware input stream. The stream is closed
81 // by releasing all references to the returned object.
82 virtual status_t openInputStream(
83 audio_io_handle_t handle,
84 audio_devices_t devices,
85 struct audio_config *config,
86 audio_input_flags_t flags,
87 const char *address,
88 audio_source_t source,
89 sp<StreamInHalInterface> *inStream);
90
91 // Returns whether createAudioPatch and releaseAudioPatch operations are supported.
92 virtual status_t supportsAudioPatches(bool *supportsPatches);
93
94 // Creates an audio patch between several source and sink ports.
95 virtual status_t createAudioPatch(
96 unsigned int num_sources,
97 const struct audio_port_config *sources,
98 unsigned int num_sinks,
99 const struct audio_port_config *sinks,
100 audio_patch_handle_t *patch);
101
102 // Releases an audio patch.
103 virtual status_t releaseAudioPatch(audio_patch_handle_t patch);
104
105 // Fills the list of supported attributes for a given audio port.
106 virtual status_t getAudioPort(struct audio_port *port);
107
108 // Set audio port configuration.
109 virtual status_t setAudioPortConfig(const struct audio_port_config *config);
110
111 virtual status_t dump(int fd);
112
113 private:
114 friend class DevicesFactoryHalHidl;
115 sp<IDevice> mDevice;
116 sp<IPrimaryDevice> mPrimaryDevice; // Null if it's not a primary device.
117
118 // Can not be constructed directly by clients.
119 explicit DeviceHalHidl(const sp<IDevice>& device);
120
121 // The destructor automatically closes the device.
122 virtual ~DeviceHalHidl();
123};
124
Kevin Rocard51e076a2018-02-28 14:36:53 -0800125} // namespace V4_0
Kevin Rocard4bcd67f2018-02-28 14:33:38 -0800126} // namespace android
127
Kevin Rocard51e076a2018-02-28 14:36:53 -0800128#endif // ANDROID_HARDWARE_DEVICE_HAL_HIDL_4_0_H