1 /* 2 * Copyright (C) 2015 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 17 #pragma once 18 19 #include "DeviceDescriptor.h" 20 #include <utils/RefBase.h> 21 #include <utils/String8.h> 22 #include <utils/Errors.h> 23 #include <utils/Vector.h> 24 #include <system/audio.h> 25 #include <cutils/config_utils.h> 26 27 namespace android { 28 29 class IOProfile; 30 31 class HwModule : public RefBase 32 { 33 public: 34 HwModule(const char *name); 35 ~HwModule(); 36 37 status_t loadOutput(cnode *root); 38 status_t loadInput(cnode *root); 39 status_t loadDevice(cnode *root); 40 41 status_t addOutputProfile(String8 name, const audio_config_t *config, 42 audio_devices_t device, String8 address); 43 status_t removeOutputProfile(String8 name); 44 status_t addInputProfile(String8 name, const audio_config_t *config, 45 audio_devices_t device, String8 address); 46 status_t removeInputProfile(String8 name); 47 getHandle()48 audio_module_handle_t getHandle() const { return mHandle; } 49 50 void dump(int fd); 51 52 const char *const mName; // base name of the audio HW module (primary, a2dp ...) 53 uint32_t mHalVersion; // audio HAL API version 54 audio_module_handle_t mHandle; 55 Vector < sp<IOProfile> > mOutputProfiles; // output profiles exposed by this module 56 Vector < sp<IOProfile> > mInputProfiles; // input profiles exposed by this module 57 DeviceVector mDeclaredDevices; // devices declared in audio_policy.conf 58 }; 59 60 class HwModuleCollection : public Vector< sp<HwModule> > 61 { 62 public: 63 sp<HwModule> getModuleFromName(const char *name) const; 64 65 sp <HwModule> getModuleForDevice(audio_devices_t device) const; 66 67 sp<DeviceDescriptor> getDeviceDescriptor(const audio_devices_t device, 68 const char *device_address, 69 const char *device_name) const; 70 71 status_t dump(int fd) const; 72 }; 73 74 }; // namespace android 75