1 /*
2  * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
3  * Not a contribution.
4  *
5  * Copyright (C) 2013 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef AUDIO_PLATFORM_API_H
21 #define AUDIO_PLATFORM_API_H
22 #include <sound/voice_params.h>
23 
24 #define CODEC_BACKEND_DEFAULT_BIT_WIDTH 16
25 #define CODEC_BACKEND_DEFAULT_SAMPLE_RATE 48000
26 
27 void *platform_init(struct audio_device *adev);
28 void platform_deinit(void *platform);
29 int platform_is_acdb_initialized(void *platform);
30 int platform_acdb_init(void *platform);
31 const char *platform_get_snd_device_name(snd_device_t snd_device);
32 int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device,
33                                       char *device_name);
34 void platform_add_backend_name(char *mixer_path, snd_device_t snd_device);
35 int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type);
36 int platform_get_snd_device_index(char *snd_device_index_name);
37 int platform_set_fluence_type(void *platform, char *value);
38 int platform_get_fluence_type(void *platform, char *value, uint32_t len);
39 int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id);
40 int platform_get_snd_device_acdb_id(snd_device_t snd_device);
41 int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width);
42 int platform_get_snd_device_bit_width(snd_device_t snd_device);
43 int platform_send_audio_calibration(void *platform, struct audio_usecase *usecase,
44                                     int app_type, int sample_rate);
45 int platform_get_default_app_type(void *platform);
46 int platform_switch_voice_call_device_pre(void *platform);
47 int platform_switch_voice_call_enable_device_config(void *platform,
48                                                     snd_device_t out_snd_device,
49                                                     snd_device_t in_snd_device);
50 int platform_switch_voice_call_device_post(void *platform,
51                                            snd_device_t out_snd_device,
52                                            snd_device_t in_snd_device);
53 int platform_switch_voice_call_usecase_route_post(void *platform,
54                                                   snd_device_t out_snd_device,
55                                                   snd_device_t in_snd_device);
56 int platform_start_voice_call(void *platform, uint32_t vsid);
57 int platform_stop_voice_call(void *platform, uint32_t vsid);
58 int platform_set_voice_volume(void *platform, int volume);
59 int platform_set_mic_mute(void *platform, bool state);
60 int platform_get_sample_rate(void *platform, uint32_t *rate);
61 int platform_set_device_mute(void *platform, bool state, char *dir);
62 snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices);
63 snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device);
64 int platform_set_hdmi_channels(void *platform, int channel_count);
65 int platform_edid_get_max_channels(void *platform);
66 void platform_get_parameters(void *platform, struct str_parms *query,
67                              struct str_parms *reply);
68 int platform_set_parameters(void *platform, struct str_parms *parms);
69 int platform_set_incall_recording_session_id(void *platform, uint32_t session_id,
70                                              int rec_mode);
71 int platform_stop_incall_recording_usecase(void *platform);
72 int platform_start_incall_music_usecase(void *platform);
73 int platform_stop_incall_music_usecase(void *platform);
74 int platform_update_lch(void *platform, struct voice_session *session,
75                         enum voice_lch_mode lch_mode);
76 /* returns the latency for a usecase in Us */
77 int64_t platform_render_latency(audio_usecase_t usecase);
78 int platform_update_usecase_from_source(int source, audio_usecase_t usecase);
79 
80 bool platform_listen_device_needs_event(snd_device_t snd_device);
81 bool platform_listen_usecase_needs_event(audio_usecase_t uc_id);
82 
83 bool platform_sound_trigger_device_needs_event(snd_device_t snd_device);
84 bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id);
85 
86 int platform_set_snd_device_backend(snd_device_t snd_device, const char * backend);
87 
88 /* From platform_info_parser.c */
89 int platform_info_init(const char *filename);
90 
91 struct audio_offload_info_t;
92 uint32_t platform_get_compress_offload_buffer_size(audio_offload_info_t* info);
93 uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info);
94 
95 bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, struct audio_usecase *usecase);
96 int platform_get_usecase_index(const char * usecase);
97 int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id);
98 void platform_set_echo_reference(void *platform, bool enable);
99 void platform_get_device_to_be_id_map(int **be_id_map, int *length);
100 
101 int platform_set_audio_device_interface(const char * device_name, const char *intf_name,
102                                         const char * codec_type);
103 #endif // AUDIO_PLATFORM_API_H
104