1 /* 2 * Copyright (C) 2017 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 #ifndef AUDIO_PROXY_INTERFACE_H 18 #define AUDIO_PROXY_INTERFACE_H 19 20 21 /* Volume Type */ 22 enum { 23 VOLUME_TYPE_OFFLOAD = 0, 24 }; 25 26 /* Compress Function Type */ 27 enum { 28 COMPRESS_TYPE_WAIT = 0, 29 COMPRESS_TYPE_NEXTTRACK, 30 COMPRESS_TYPE_PARTIALDRAIN, 31 COMPRESS_TYPE_DRAIN, 32 }; 33 34 /* Special Audio Device Type */ 35 enum { 36 BUILTIN_HANDSET = 0, 37 BUILTIN_SPEAKER, 38 BUILTIN_MIC, 39 PROXIMITY_SENSOR, 40 }; 41 42 /* Audio Device Configuration Type */ 43 enum { 44 DEVICE_CONFIG_NONE = 0, 45 DEVICE_CONFIG_INTERNAL, 46 DEVICE_CONFIG_EXTERNAL, 47 }; 48 49 enum { 50 DEVICE_BLUETOOTH = 0, 51 DEVICE_FMRADIO, 52 }; 53 54 /* A-Box Configuration Type */ 55 enum { 56 NEED_VOICEPCM_REOPEN = 0, 57 SUPPORT_USB_BY_PRIMARY, 58 SUPPORT_A2DP_BY_PRIMARY, 59 60 }; 61 62 63 // Audio Capability Check Utility Functions 64 int get_supported_device_number(void *proxy, int device_type); 65 int get_supported_config(void *proxy, int device_type); 66 bool is_needed_config(void *proxy, int config_type); 67 68 // Audio Usage Check Utility Functions 69 bool is_active_usage_APCall(void *proxy); 70 bool is_usage_CPCall(audio_usage ausage); 71 bool is_active_usage_CPCall(void *proxy); 72 bool is_usage_APCall(audio_usage ausage); 73 74 // Audio Stream Proxy Get/Set Fungtions 75 uint32_t proxy_get_actual_channel_count(void *proxy_stream); // Return Actual Channel Count 76 uint32_t proxy_get_actual_sampling_rate(void *proxy_stream); // Return Actual Samplung Rate 77 uint32_t proxy_get_actual_period_size(void *proxy_stream); 78 uint32_t proxy_get_actual_period_count(void *proxy_stream); 79 int32_t proxy_get_actual_format(void *proxy_stream); // Return Actual Android Audio Format, not PCM Format 80 81 // Audio Stream Proxy Offload Functions 82 void proxy_offload_set_nonblock(void *proxy_stream); 83 int proxy_offload_compress_func(void *proxy_stream, int func_type); 84 int proxy_offload_pause(void *proxy_stream); 85 int proxy_offload_resume(void *proxy_stream); 86 87 // Audio Stream Proxy Playback Stream Functions 88 void *proxy_create_playback_stream(void *proxy, int type, void *config, char *address); 89 void proxy_destroy_playback_stream(void *proxy_stream); 90 int proxy_close_playback_stream(void *proxy_stream); 91 int proxy_open_playback_stream(void *proxy_stream, int32_t min_size_frames, void *mmap_info); 92 int proxy_start_playback_stream(void *proxy_stream); 93 int proxy_write_playback_buffer(void *proxy_stream, void *buffer, int bytes); 94 int proxy_stop_playback_stream(void *proxy_stream); 95 int proxy_reconfig_playback_stream(void *proxy_stream, int type, void *config); 96 int proxy_get_render_position(void *proxy_stream, uint32_t *frames); 97 int proxy_get_presen_position(void *proxy_stream, uint64_t *frames, struct timespec *timestamp); 98 char *proxy_getparam_playback_stream(void *proxy_stream, const char *keys); 99 int proxy_setparam_playback_stream(void *proxy_stream, void *parameters); 100 uint32_t proxy_get_playback_latency(void *proxy_stream); 101 void proxy_dump_playback_stream(void *proxy_stream, int fd); 102 103 // Audio Stream Proxy Capture Stream Functions 104 void *proxy_create_capture_stream(void *proxy, int type, int usage, void *config, char *address); 105 void proxy_destroy_capture_stream(void *proxy_stream); 106 int proxy_close_capture_stream(void *proxy_stream); 107 int proxy_open_capture_stream(void *proxy_stream, int32_t min_size_frames, void *mmap_info); 108 int proxy_start_capture_stream(void *proxy_stream); 109 int proxy_read_capture_buffer(void *proxy_stream, void *buffer, int bytes); 110 int proxy_stop_capture_stream(void *proxy_stream); 111 int proxy_reconfig_capture_stream(void *proxy_stream, int type, int usage); 112 int __proxy_get_capture_position(void *proxy_stream, int64_t *frames, int64_t *time); 113 char *proxy_getparam_capture_stream(void *proxy_stream, const char *keys); 114 int proxy_setparam_capture_stream(void *proxy_stream, void *parameters); 115 void proxy_dump_capture_stream(void *proxy_stream, int fd); 116 117 int proxy_get_mmap_position(void *proxy_stream, void *pos); 118 119 // Audio Device Proxy Path Route Functions 120 bool proxy_init_route(void *proxy, char *path); 121 void proxy_deinit_route(void *proxy); 122 bool proxy_update_route(void *proxy, int ausage, int device); 123 bool proxy_set_route(void *proxy, int ausage, int device, int modifier, bool set); 124 125 // Audio Device Proxy Functions 126 void proxy_stop_voice_call(void *proxy); 127 void proxy_start_voice_call(void *proxy); 128 void proxy_stop_fm_radio(void *proxy); 129 void proxy_start_fm_radio(void *proxy); 130 131 int proxy_get_mixer_value_int(void *proxy, const char *name); 132 int proxy_get_mixer_value_array(void *proxy, const char *name, void *value, int count); 133 void proxy_set_mixer_value_int(void *proxy, const char *name, int value); 134 void proxy_set_mixer_value_string(void *proxy, const char *name, const char *value); 135 void proxy_set_mixer_value_array(void *proxy, const char *name, const void *value, int count); 136 137 void proxy_set_audiomode(void *proxy, int audiomode); 138 void proxy_set_volume(void *proxy, int volume_type, float left, float right); 139 void proxy_set_upscale(void *proxy, int sampling_rate, int pcm_format); 140 #ifdef SUPPORT_STHAL_INTERFACE 141 int proxy_check_sthalstate(void *proxy); 142 #endif 143 void proxy_call_status(void *proxy, int status); 144 int proxy_set_parameters(void *proxy, void *parameters); 145 146 void proxy_init_offload_effect_lib(void *proxy); 147 void proxy_update_offload_effect(void *proxy_stream, int type); 148 149 // Audio Device Proxy Dump Function 150 int proxy_fw_dump(int fd); 151 152 // Audio Device Proxy Creation/Destruction 153 bool proxy_is_initialized(void); 154 void *proxy_init(void); 155 void proxy_deinit(void *proxy); 156 157 #endif /* AUDIO_PROXY_INTERFACE_H */ 158